Interviewer And Interviewee Guide

Fresh Java Classes Interview Questions & Answers:

1. In this example class-var = new classname( );
The classname is the name of the class that is being instantiated.
A) True
B) False

whan we create an object so code are classname obj=new classname();classname is name of the classobj is objectnew is create new instances of class classnameso that ans is true...........what u say

2. Tell me Is it possible to declare an anonymous class while implementing an interface?

Interface i = new Interface(){/* Code}The above statement creates an instance of a class which implements the Interface "Interface". As name of class is not specified hence it is anonymous.

4. How to call two interfaces in one interface?

You can not call 2 interface in interface but you can extend interfaces in your interface.Example :
Interface I1{..}Interface I2 extends I1{..}Interface I3 extends I2{}

5. Explain when we are overloading or overriding the methods how we want to take care about the acess specifiers?

When we override a method in the child class, that method sould not be a private in parent class, but that method should be public or protected or default, those methods should have the same signature.

But we can overload the method within the same class or in the child class but they have some difference in having no of arguments or type of arguments. if we overload the method within the class we can use any access specifier, if we overload in child class dont use private.

6. What is enumeration?

public interface Enumeration . An object that implements the Enumeration interface generates a series of elements, one at a time. Successive calls to the nextElement method return successive elements of the series.

9. in Java, all class objects need not be dynamically allocated
A) True
B) False

I think it is true. Because, we use initalize some variables which are not dynamic.

For eg: int i = 10;

10. Static and Non-Static are the two types of nested classes
A) True
B) False

true.....class declared with static called static inner class....with out static called non static inner class..

Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.