Problem statement:
Given java code, what will be the output of it?
Given java code, what will be the output of it?
- interface Car {
- public void startEngine();
- }
- class MySuzuki implements Car {
- public void startEngine() {
- System.out.println("MySuzuki");
- }
- }
- class MyFerrari implements Car {
- public void startEngine() {
- System.out.println("MyFerrari");
- }
- }
- public class OOPSExample {
- public static void main(String[] args) {
- MyFerrari obj = new MySuzuki();
- obj.startEngine();
- }
- }
Output:
Compile time error at line 16, due to Type mismatch: cannot convert from MySuzuki to MyFerrari
No comments:
Post a Comment