WorksheetsJava upto packages
Total questions: 27
Worksheet time: 14mins
Choose the CORRECT mechanism of exception handling.
try block --> catch block --> finally block
try block --> catch block --> throws exception
try block --> catch block --> finally --> throws exception
try block --> throws exception--> catch block --> finally block
output of the program
Base::show() called
Derived::show() called
Compiler Error
Runtime Error
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
Predict the output of following Java program?
0
garbage value
compile time error
runtime error
Predict the output of following Java program
garbage value
0
compile time error
runtime error
output of the program
Compile error
values of obj1:
a = 11 b = 21
values of obj2:
a = 11 b = 21
values of obj1:
a = 11 b = 21
values of obj2:
a = 10 b = 20
values of obj1:
a = 11 b = 20
values of obj2:
a = 10 b = 21
runtime error
Predict the output of the following program.
Compilation error
Inside First
Inside First
Inside First
Inside Second
Runtime error
What is the output of the following JAVA program ?
dogood : dogoodgood
dogood : gooddogood
dogood : dodogood
dogood : dogood
Predict the output?
20
0
Compiler Error
none
Which of the following is/are true about constructors in Java?
1
1,2
1, 2, 4
1,2,3 & 4
output of the program
inside static block
a = 4
inside constructor
a = 11
Compiler Error
Run Time Error
inside static block
a = 4
inside constructor
a = 5
inside static block
a = 10
inside constructor
a = 11
What is the process of defining a method in a subclass having same name & type signature as a method in its superclass?
Method overloading
Method overriding
Method hiding
None of the mentioned
What is the output of this program?
2
3
7
compile time error
what is the output
9.0 9.0
9 9
compile time error
none
I am a Person
I am a Student
I am a Person I am a Student
I am a Student I am a Person
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?
Public
Protected
No Modifier
All of the mentioned
Which of these access specifiers can be used for a class so that its members can be accessed by a different class in the different package?
Public
Protected
Private
No Modifier
Which of the following is an incorrect statement about packages?
Package defines a namespace in which classes are stored
A package can contain other package within it
Java uses file system directories to store packages
A package can be renamed without renaming the directory in which the classes are stored
For which purpose packages are used in Java?
Categorizes data
Organizing java classes into namespaces
faster compilation
None of These
which package is imported implicitly?
java.applet
java.util
java.lang
java.io
Math class is in ………package.
java.io
java.lang
java.util
java.applet
………………….. package in java contents language utility classes such as vectors, hash tables, random numbers date etc.
java.util
java.awt
java.net
java.lang
…………………….. package in java contents set of classes for implementing graphical user interface, which includes classes for windows, buttons, lists, menus and so on.
java.util
java.awt
java.net
java.lang
Which of the following classes in Java.io package defines a method to delete a file.
Stack
File
String
Vector
The Date class includes within ………………….. package.
java.io
java.awt
java.net
java.util
By convention, java packages begin with ………………. letters while all the class names begin with an ………………… letter.
uppercase, uppercase
lowercase, lowercase
uppercase, lowercase
lowercase, uppercase
