Packages and Exception handling section
What is package?
Package is collection of classes and interfaces
How to define package?
By using package keyword before the definition of class
What is CLASSPATH?
It is an environment variable which is used for defining the location of class files
What is jar?
Jar stands for Java archive files, compressed set of class files and can be used in CLASSPATH
What is the meaning of import java.awt.*;?
Import all the classes and interfaces in the java.awt.package. This doesn't imports other packages
defined in java.awt. package.
Is it necessary to give import java.awt.event.*;, when already import java.awt.* given?
Yes, import java.awt.* doesn't imports event package defined in java.awt. package.
What is exception?
Abnormal termination of program is called exception
What is exception handler?
A method which controls abnormal termination of program
What are the keywords used for exception handling?
try, catch, throw, throws and finally
What is the difference between throw and throws keywords?
throw keyword is used for invoking an exception (For raising)
throws keyword lists exception names which can be ignored from the method execution
What is the difference between final and finally?
final is used for defining constants
finally is used for executing code after completion of exception handler
What is catch( ) block?
Exception handler that controls abnormal termination of program
Can we have multiple catch( ) blocks?
Yes, but first sub class exceptions should be handled
What happen is we not handle sub class exception first?
Generates compile time error saying that unreachable code is defined in the program
What is package?
Package is collection of classes and interfaces
How to define package?
By using package keyword before the definition of class
What is CLASSPATH?
It is an environment variable which is used for defining the location of class files
What is jar?
Jar stands for Java archive files, compressed set of class files and can be used in CLASSPATH
What is the meaning of import java.awt.*;?
Import all the classes and interfaces in the java.awt.package. This doesn't imports other packages
defined in java.awt. package.
Is it necessary to give import java.awt.event.*;, when already import java.awt.* given?
Yes, import java.awt.* doesn't imports event package defined in java.awt. package.
What is exception?
Abnormal termination of program is called exception
What is exception handler?
A method which controls abnormal termination of program
What are the keywords used for exception handling?
try, catch, throw, throws and finally
What is the difference between throw and throws keywords?
throw keyword is used for invoking an exception (For raising)
throws keyword lists exception names which can be ignored from the method execution
What is the difference between final and finally?
final is used for defining constants
finally is used for executing code after completion of exception handler
What is catch( ) block?
Exception handler that controls abnormal termination of program
Can we have multiple catch( ) blocks?
Yes, but first sub class exceptions should be handled
What happen is we not handle sub class exception first?
Generates compile time error saying that unreachable code is defined in the program






0 Response to "Viva Questions for Java Lab"