Font size
Worksheetspolymorphism, exception and packages
Total questions: 40
Worksheet time: 24mins
the class at the top of exception class hierarchy is ...
ArithmeticException
Throwable
Object
Exception
in which of the following package exception class exists
java.lang
java.io
java.util
java.net
0.0
Compilation fails.
A Parse Exception is thrown by the parse method at runtime.
A Number Format Exception is thrown by the parse method at runtime.
Under which three circumstances will the code on line 37 be executed?
The instance gets garbage collected.
The code on line 33 throws an exception.
The code on line 35 throws an exception.
The code on line 31 throws an exception.
The code on line 33 executes successfully.
Which exception or error will be thrown when a programmer attempts to run this code?
java.lang.StackOverflowError
java.lang.IllegalStateException
java.lang.ExceptionInInitializerError
java.lang.ArrayIndexOutOfBoundsException
null
life
universe
everything
Compilation fails.
Compilation Error
A
B
Runtime error
Which of these keywords must be used to monitor for exceptions?
finally
catch
try
throw
throws
hello throwit caught
Compilation fails
hello throwit caught finally after
hello throwit RuntimeException caught after
12345
123450
1234500
Compilation Error
which of the following are valid
1,3
2,3,4
1,4
1,2,3,4,5
The ability to define more than one function with the same name is called?
Inheritance
Encapsulation
Abstraction
Polymorphism
Which of the following is the correct way of importing an entire package "pkg"?
import pkg.
Import pkg.
import pkg.*
Import pkg.*
Choose the correct syntax of a Java Package below.
package PACKAGE_NAME;
package PACKAGE_NAME.*;
pkg PACKAGE_NAME;
pkg PACKAGE_NAME.*;
Package in Java is a mechanism to encapsulate a ______________.
Classes
Sub Packages
Interfaces
All of the above
Is it necessary that each try block must be followed by a catch block?
True
False
which of the following is an example of polymorphism design related to switch board plugs.
this is an example for
method overloading
method overriding
Choose the correct syntax below for defining an Interface in Java.
All the above
no output
C
compile time error
none of the above
which of the package contains Scanner class
import java.io.*;
import java.net.*;
import java.util.*;
import java.awt.*;
Which of the following key word is optional in Exception handling program
try
catch
finally
throw
What is the purpose of 'throw' keyword
To Raise an exception explicityly
To Raise an exception implicityly
To create user defined exceptions
To create custom exceptions
Choose the CORRECT exception
String clg="LBRCE";
Integer no=Integer.parseInt(clg);
ArithmeticException
NullPointerException
NumberFormatException
ArrayIndexOutOfBoundsException
A class member declared protected becomes a member of subclass of which type?
public member
private member
protected member
static member
Which of these is correct way of inheriting class A by class B?
class B + class A {}
class B inherits class A {}
class B extends A {}
class B extends class A {}
What is the output of this program?
0
1
2
Compilation Error
What is the output of this program?
2 2
3 3
2 3
3 2
What is the output of this program?
1 2
2 1
Runtime Error
Compilation Error
What is not type of inheritance?
Single inheritance
Double inheritance
Hierarchical inheritance
Multiple inheritance
what is the output?
Base
Derived
compile time error
run-time error
Output of following Java program?
Base
Derived
Derived
Base
Base
Derived
Base
Derived
Base
Compiler Error
Which of the following is true about inheritance in Java?
1, 2 and 4
Only 1 and 2
1, 2 and 3
2, 3 and 4
output of the program
Base::show() called
Compiler Error
Derived::show() called
None
output of the program
Base::show() called
Derived::show() called
Compiler Error
Runtime Error
Output of following Java Program?
Derived::show() called
compile time error
Base::show() called
runtime error
Math class is in ………package.
java.io
java.lang
java.util
java.applet
which package is imported implicitly?
java.applet
java.util
java.lang
java.io
If a variable is declared as private , then it can be used in _______.
Any class of any package.
Any class of same package.
Only in the same class.
Only subclass in that package.
A package is a collection of
classes
interfaces
editing tools
classes and interfaces
