3
Q:

try { int x = Integer.parseInt("two"); }

Which could be used to create an appropriate catch block?

A) ClassCastException B) IllegalStateException
C) NumberFormatException D) None

Answer:   C) NumberFormatException



Explanation:

C is correct. 'Integer.parseInt' can throw a NumberFormatException, and IllegalArgumentException is its superclass 

Subject: Java
Q:

What is JAR file?

Answer

A JAR file (short for Java Archive) is a ZIP file used to distribute a set of Java classes. It is used to store compiled Java classes and associated metadata that can constitute a program

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1814
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 1557
Q:

What is Marker Interface?

Answer

An interface without having any methods and by implementing that interface if our objects will get same ability such type interfaces are called marker interface (or) ability interface (or) tag interface

Report Error

View answer Workspace Report Error Discuss

Subject: Java
Job Role: IT Trainer

1 3011
Q:

Inside an interface when should the variables be initialized?

A) Globally B) Whenever required
C) Inside a function D) During the time of declaration
 
Answer & Explanation Answer: D) During the time of declaration

Explanation:

They should be initialized during the time of declaration itself otherwise it is a compilation eror

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

0 4017
Q:

Which of the following statements are equal for a variable declared in the interface ?

1. int X=10
2. public int X=10
3. public static final int X=10

A) Only 1 and 2 are equal B) Only 2 and 3 are equal
C) All are unequal D) All are equal
 
Answer & Explanation Answer: D) All are equal

Explanation:

All the statements are equal because inside an interface a variable declared will be public static final by default 

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

0 13368
Q:

Why interface method is always public?

Answer

To make this method available to every implementation class

Report Error

View answer Workspace Report Error Discuss

Subject: Java
Job Role: IT Trainer

0 2124
Q:

Which of the following method declarations are allowed inside interface?

A) public void m1() B) private void m1()
C) protected void m1() D) abstract public void m1()
 
Answer & Explanation Answer: D) abstract public void m1()

Explanation:

Inside an interface every method will be by default abstract and public

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

0 3938
Q:

X implements Y extends Z

A) X can be class Y,Z are interfaces B) X is an interface Y,Z are classes
C) X,Y are classes Z is an interface D) Complilation error
 
Answer & Explanation Answer: D) Complilation error

Explanation:

It is a compilation error it should be X extends Y implements Z

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: IT Trainer

3 4821