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 the difference between method overriding and overloading?

Answer

Overriding is a method with the same name and arguments as in a parent, whereas overloading is the same method name but different arguments

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1462
Q:

If a method is declared as protected, where may the method be accessed?

Answer

A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2083
Q:

What do you understand by private, protected and public?

Answer

These are accessibility modifiers. Private is the most restrictive, while public is the least restrictive. There is no real difference between protected and the default type (also known as package protected) within the context of the same package, however the protected keyword allows visibility to a derived class in a different package.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1470
Q:

I don't want my class to be inherited by any other class. What should i do?

Answer

You should declared your class as final. But you can't define your class as final, if it is an abstract class. A class declared as final can't be extended by any other class.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

2 5683
Q:

What is the impact of declaring a method as final?

Answer

A method declared as final can't be overridden. A sub-class can't have the same method signature with a different implementation.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1379
Q:

What is a package?

Answer

Package is a collection of related classes and interfaces. package declaration should be first statement in a java class.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 1466
Q:

What is difference between Path and Classpath?

Answer

Path and Classpath are operating system level environment variales. Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .class files.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1583
Q:

What is Thread ?

Answer

A thread is a lightweight subprocess, a smallest unit of processing. It is a separate path of execution. It shares the memory area of process.



As shown in the above figure, thread is executed inside the process. There is context-switching between the threads. There can be multiple processes inside the OS and one process can have multiple threads.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1509