can you create interface instance ?
Answer Posted / shankar patil
You can't create an object without method implementations.
Anonymous inner classes allow you to do.
public interface MyInterface {
public void myMethod() ;
}
MyInterface myIntfObj = new MyInterface() {
public void myMethod() {
}
};
myIntfObj.myMethod();
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What happens when a thrown exception is not handled?
What do you mean by mnemonics?
Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.
What is the functionality of the stub?
Is ++ operator is thread safe in java?
How do you initialize an arraylist in java?
Can we have this () and super () together?
How can you read content from file in java?
Is singleton set an interval?
Which methods are used during serialization and deserialization process?
What is defined as false sharing in the context of multithreading?
What happens to a static var that is defined within a method of a class?
What is difference between path and classpath?
How many boolean functions are there?
What is the buffer limit?