Java Classes Interview Preparation Guide
Download PDF
Add New Question

Java Classes frequently Asked Questions in various Java Classes related job Interviews by interviewer. Get preparation of Java Classes job interview questions

76 Java Classes Questions and Answers:

1 :: A stack stores data using first-in, last-out ordering.

A) True
B) False

Yes it is true ... Stack works on the Startegy of First In First Out
Post Your Answer

2 :: The type of data returned by a method need not be compatible with the return type specified by the method

A) True
B) False

Explanation: The type of data returned by a method must be compatible with the return type specified by the method. For example, if the return type of some method is boolean, you could not return an integer

A) its False

The return type must be compatible
Post Your Answer

3 :: This can be used inside any method to refer to the current object

A) True
B) False

Answer is False and i got it wrong inspite of being correct!!

Explanation:

this cannot be used within a static method. It can be used only within non-static methods.So the question asks whether it can be used inside any method......
Post Your Answer

4 :: In System.out.println() explain it.My doubt, we call static method with Class name but here what is "out"?

Actually System is class define in java.lang package...

class System{ //Member variables... static PrintStream out;

.................................

//Member methods...

.................

}
so out is a static reference of PrintStream class,which is define in java.io package and println() is a method of PrintStream class...
So ultimately, we can call println() method of static out reference of System class.
Syste.out.println();
Post Your Answer

5 :: What is the difference between instantiation & initialization?

Instance ation will not allocate memory, just a instance will be created.

Initialization will actually allocate memory.
Post Your Answer

6 :: If the method does not return a value, its return type must be void

A) True
B) False

It's true. If a method is not returning any value then we must have to specify it's return type as void.void indicates that method is not returning any value.
Post Your Answer

9 :: Stacks are controlled through two operations traditionally called ___ and _____

A) Push and Pull
B) Push and Pop
C) Pop and Pull
D) Pop and Peep

Ans is :(B)push and pop

Push :Push is used to insert elements in the stack.

Pop : Pop is used to extract elements from the stack.
Post Your Answer

10 :: In Java it is possible to define two or more methods within the same class that share the same name, as long as their parameter declarations are different

A) True
B) False

Yes it is True ...

In Java we can have to or more classes with the same name but the parameter list should be Different ... This Concept is called

Method Overloading or Function Overloading

In C++ we have the same Concept too ..
Post Your Answer
Add New Question