Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Core Java Interview Questions and Answers

Test your skills through the online practice test: Core Java Quiz Online Practice Test

Ques 131. Why isn't there operator overloading?

Because C++ has proven by example that operator overloading makes code almost impossible to maintain. In fact there very nearly wasn't even method overloading in Java, but it was thought that this was too useful for some very basic methods like print(). Note that some of the classes like DataOutputStream have unoverloaded methods like writeInt() and writeByte().

Is it helpful? Add Comment View Comments

Ques 132. Can a method be overloaded based on different return type but same argument type ?

No, because the methods can be called without using their return type in which case there is ambiquity for the compiler

Is it helpful? Add Comment View Comments

Ques 133. What restrictions are placed on method overloading?

Two methods may not have the same name and argument list but different return types.

Is it helpful? Add Comment View Comments

Ques 134. How could Java classes direct program messages to the system console, but error messages, say to a file?

By default, both System console and err point at the system console.

The class System has a variable out that represents the standard output.
The variable err that represents the standard error device. 
Stream st = new Stream (new  FileOutputStream ("withoutbook_com.txt"));

Is it helpful? Add Comment View Comments

Ques 135. What does the keyword "synchronize" mean in java. When do you use it? What are the disadvantages of synchronization?

Synchronize is used when you want to make your methods thread safe. The disadvantage of synchronize is it will end up in slowing down the program. Also if not handled properly it will end up in dead lock.

Is it helpful? Add Comment View Comments

Most helpful rated by users:

©2024 WithoutBook