• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Interview Questions Answers

Question - 141 : - What is a protected method?

Answer - 141 : - A protected method is a method that can be accessed by any method in its package and inherited by any subclass of its class.

Question - 142 : - Is Iterator a Class or Interface? What is its use?

Answer - 142 : - Iterator is an interface which is used to step through the elements of a Collection.

Question - 143 : - What is the difference between yielding and sleeping?

Answer - 143 : - When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

Question - 144 : - What invokes a thread's run() method?

Answer - 144 : - After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

Question - 145 : - What is the difference between a static and a non-static inner class?

Answer - 145 : - A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.

Question - 146 : - Which c ontainers use a border Layout as their default layout?

Answer - 146 : - The window, Frame and Dialog classes use a border layout as their default layout.

Question - 147 : - What is a transient variable?

Answer - 147 : - A transient variable is a variable that may not be serialized.

Question - 148 : - Can a for statement loop indefinitely?

Answer - 148 : - Yes, a for statement can loop indefinitely. For example, consider the following: for(;;) ;

Question - 149 : - What's new with the stop(), suspend() and resume() methods in JDK 1.2?

Answer - 149 : - The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.

Question - 150 : - What is an object's lock and which object's have locks?

Answer - 150 : - An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock. All objects and classes have locks. A class's lock is acquired on the class's Class object.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners