In: Computer Science
public class N extends String, Integer
{
}
When you compile, you get the following message:
N.java:1: ‘{‘ expected
public class N extends String, Integer
^
1 error
Explain what the problem is and how to fix it.
interface String1 // here we take String1 class
{
void show(); // this is method for String1
}
interface Integer1 // here we take Integer1 class
{
void run(); // this is method for Integer1
}
public class Main implements String1,Integer1 // here we
implementing both classes
{
public void show(){ // here we are calling the method show() , to
show it's implementation
System.out.println("This is to show method1 for string");
}
public void run(){ // here we are calling the method show() , to
show it's implementation
System.out.println("This is to show method2 for Integer ");
}
public static void main(String args[])
{
Main obj = new Main(); //here , we are creating a object for
reference variable
obj.show(); // here , we are calling the method using reference
variable
obj.run(); // here , we are calling the method using reference
variable
}
}
Thank You...!