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:

Why is the main() method declared static?

Answer

main() method is called by the JVM even before the instantiation of the class, hence it is declared as static.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2002
Q:

What are instance variables?

Answer Instance variables are those which are defined at the class level. Instance variables need not be initialized before using them as they are automatically initialized to their default values.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1975
Q:

Is Java a pure object oriented language?

Answer

Java uses primitive data types and hence is not a pure object oriented language.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 2058
Q:

Are arrays primitive data types?

Answer In Java, Arrays are objects.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 1832
Q:

Does Java support multiple inheritance?

Answer Java doesn't support multiple inheritance.
Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2874
Q:

What is difference between Path and Classpath?

Answer

PATH and CLASSPATH are operating system level environment variables. PATH is used to define where the system can find the executables (.exe) files whereas CLASSPATH is used to specify the location of .class files.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

1 3044
Q:

What do you mean by platform independence?

Answer

Platform independence means that we can write and compile the java code in one platform (Eg Windows) and can execute the class in any other supported platform (Eg Linux,Solaris,etc).

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 3180
Q:

What is the difference between a JDK and a JVM?

Answer

JDK is Java Development Kit which is for development purpose and it includes execution environment also.


JVM is Java Virtual Machine which is a run time environment for the compiled java class files .Hence you will not be able to compile your source files using a JVM.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

0 2695