Output1.CompilationError.Objectofinterface cannot be created.2.No error
Answer: 1
This is a simple one. A instance/object of Interface can not be created. It will not be of any help actually. Since all the methods are abstract.
Output1.CompilationError.Class variable ininterface should be initialized.2.CompilationError.Class variable ininterface should be static.3.No error
Answer : 1
In a interface the variables should be public static and final. Java internally applies these attributes to a variable in an interface. So no need to define them.
A final variable needs to be initialized before it is used. That is the error.
1.02.CompilationError: localvariable not initialized.
Answer : 2.
In java the instance variable are by default given some default values. But not local variables.
They have to be initialized before used.
So intanceVariable is assigned 0 as it is a intance variable but localVariable is not initialized, hence it is mandatory to initialize it.
1.Cannot instantiate an interface2.CallAnimalofTest
Answer : 2.
Here actually we are creating a implementing class of the Interface. Which is also called as anonymous class. And we have overriden the eat() method
Since now a days the number of candidates appearing for a job has increased, companies have started keeping screening process. This screening process consist of objective questions which can be answered online. Only those candidates which score good marks in Objective questions are called for personal interviews.
This blog has multiple choice OOPS and Java questions. It is a mix of topics like Inheritance, overriding, static, constructor etc.
Read the question and try to solve it yourself. Then you can click on the Answer button to verify your answer.