Java Questions

Q:

What is polymorphism?

Answer

It is the ability of an object to behave differently on different situations for the same message.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1556
Q:

What is the difference between throw and throws clause?

Answer

A throw is used to throw an exception manually, where as throws is used in the case of checked exceptions, to tell the compiler that we haven't  handled the exception, so that the exception will be handled by the calling function.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1553
Q:

What is different among String, StringBuffer, StringBuilder?

Answer

String class objects are immutable objects and they represents strings( sequence of characters)


StringBuffer class objects are mutable objects representing strings and they are Thread safe


StringBuild class objects are also mutable objects representing strings and they are not Thread safe

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1550
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 1541
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 1537
Q:

What are the 3main tasks of JVM?

Answer

The JVM performs three main tasks:


• Loads code


• Verifies code


• Executes code

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1529
Q:

What is the use of tostring() method?

Answer

If we print any object by using println() or print() methods.


The println() or print() methods internally calls tostring() method and prints the return value of toString() method.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1526
Q:

What is anonymous class?

Answer

Anonymous class is class without name.


EX:


class A {


}


class Demo {


    A r = new A() {


        }; //anonymous class


}


 

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1523