Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java upto packages

Total questions: 27

Worksheet time: 14mins

Name
Class
Date
1.

Choose the CORRECT mechanism of exception handling.

a)

try block --> catch block --> finally block

b)

try block --> catch block --> throws exception

c)

try block --> catch block --> finally --> throws exception

d)

try block --> throws exception--> catch block --> finally block

2.

output of the program

a)

Base::show() called

b)

Derived::show() called

c)

Compiler Error

d)

Runtime Error

3.

output of the program

a)

Base::show() called

b)

Derived::show() called

c)

Compiler Error

d)

Runtime Error

4.

Output of following Java Program?

a)

Derived::show() called

b)

compile time error

c)

Base::show() called

d)

runtime error

5.

Predict the output of following Java program?

a)

0

b)

garbage value

c)

compile time error

d)

runtime error

6.

Predict the output of following Java program

a)

garbage value

b)

0

c)

compile time error

d)

runtime error

7.

output of the program

a)

Compile error

b)

values of obj1:

a = 11 b = 21

values of obj2:

a = 11 b = 21

c)

values of obj1:

a = 11 b = 21

values of obj2:

a = 10 b = 20

d)

values of obj1:

a = 11 b = 20

values of obj2:

a = 10 b = 21

e)

runtime error

8.

Predict the output of the following program.

a)

Compilation error

b)

Inside First

Inside First

c)

Inside First

Inside Second

d)

Runtime error

9.

What is the output of the following JAVA program ?

a)

dogood : dogoodgood

b)

dogood : gooddogood

c)

dogood : dodogood

d)

dogood : dogood

10.

Predict the output?

a)

20

b)

0

c)

Compiler Error

d)

none

11.

Which of the following is/are true about constructors in Java?

a)

1

b)

1,2

c)

1, 2, 4

d)

1,2,3 & 4

12.

output of the program

a)

inside static block

a = 4

inside constructor

a = 11

b)

Compiler Error

c)

Run Time Error

d)

inside static block

a = 4

inside constructor

a = 5

e)

inside static block

a = 10

inside constructor

a = 11

13.

What is the process of defining a method in a subclass having same name & type signature as a method in its superclass?

a)

Method overloading

b)

Method overriding

c)

Method hiding

d)

None of the mentioned

14.

What is the output of this program?

a)

2

b)

3

c)

7

d)

compile time error

15.

what is the output

a)

9.0 9.0

b)

9 9

c)

compile time error

d)

none

16.
a)

I am a Person

b)

I am a Student

c)

I am a Person I am a Student

d)

I am a Student I am a Person

17.

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?

a)

Public

b)

Protected

c)

No Modifier

d)

All of the mentioned

18.

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?

a)

Public

b)

Protected

c)

Private

d)

No Modifier

19.

Which of the following is an incorrect statement about packages?

a)

Package defines a namespace in which classes are stored

b)

A package can contain other package within it

c)

Java uses file system directories to store packages

d)

A package can be renamed without renaming the directory in which the classes are stored

20.

For which purpose packages are used in Java?

a)

Categorizes data

b)

Organizing java classes into namespaces

c)

faster compilation

d)

None of These

21.

which package is imported implicitly?

a)

java.applet

b)

java.util

c)

java.lang

d)

java.io

22.

Math class is in ………package.

a)

java.io

b)

java.lang

c)

java.util

d)

java.applet

23.

………………….. package in java contents language utility classes such as vectors, hash tables, random numbers date etc.

a)

java.util

b)

java.awt

c)

java.net

d)

java.lang

24.

…………………….. package in java contents set of classes for implementing graphical user interface, which includes classes for windows, buttons, lists, menus and so on.

a)

java.util

b)

java.awt

c)

java.net

d)

java.lang

25.

Which of the following classes in Java.io package defines a method to delete a file.

a)

Stack

b)

File

c)

String

d)

Vector

26.

The Date class includes within ………………….. package.

a)

java.io

b)

java.awt

c)

java.net

d)

java.util

27.

By convention, java packages begin with ………………. letters while all the class names begin with an ………………… letter.

a)

uppercase, uppercase

b)

lowercase, lowercase

c)

uppercase, lowercase

d)

lowercase, uppercase