Interview Questions

Q:

What is the difference between an Interface and an Abstract class?

Answer

An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1480
Q:

What is the purpose of garbage collection in Java, and when is it used ?

Answer

The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1702
Q:

What are pass by reference and passby value ?

Answer

Pass By Reference means the passing the address itself rather than passing the value. Passby Value means passing a copy of the value to be passed.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1505
Q:

Difference between Swing and Awt ?

Answer

AWT are heavy-weight componenets. Swings are light-weight components. Hence swing works faster than AWT.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1751
Q:

What is synchronization and why is it important ?

Answer

With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often leads to significant errors.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2968
Q:

What are wrapped classes ?

Answer

Wrapped classes are classes that allow primitive types to be accessed as objects.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1622
Q:

What is the purpose of the wait(), notify(), and notifyAll() methods ?

Answer

The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods..

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1573
Q:

What is top level class?

Answer

Top level class is also called outer class. It is not defined inside any class.


Ex:


class A {  //top level class


 


}

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1517