What are the issues with this code interface Kylnterface pri

What are the issues with this code? interface Kylnterface {private int age; private String name; public static void printAge(); public static void printName();} class C implements Kylnterface {public static void printAge() {System.out.printIn(\"age printed\");} public static void main(String arg[\') {Kylnterface myint ¦ new C(); myint .methodl ();}}

Solution

There is no method defined as method1() anywhere in the code so this is one compilation error.

The object creation is fine we can create object with reference to Interface but in case we want to call any method that is defined anywhere apart from Interface we should typecast the object first to be class C type.

 What are the issues with this code? interface Kylnterface {private int age; private String name; public static void printAge(); public static void printName();

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site