wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

EPA-11-DEC-2021 On Java

Total questions: 50

Worksheet time: 56mins

Name
Class
Date
1.

Which of these can not be used for a variable name in Java?

a)

identifier

b)

identifier & keyword

c)

keyword

d)

none of the mentioned

2.

Which of the following is not an operator in Java?

a)

instanceof

b)

sizeof

c)

>>>=

d)

new

3.

Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

a)

while

b)

do-while

c)

for

d)

none of the mentioned

4.

What is the output of relational operators?

a)

Integer

b)

Boolean

c)

Characters

d)

Double

5.

Which component is used to compile, debug and execute java program?

a)

jre

b)

jvm

c)

jdk

d)

jit

6.

What is the stored in the object obj in following lines of Java code?

Box b;

here Box is a class

a)

Memory address of allocated memory of object

b)

NULL

c)

Any arbitrary pointer

d)

Garbage

7.

Which of the following is not a Java features?

a)

Dynamic

b)

Architectural Neutral

c)

Pointer

d)

static

8.

_____ is used to find and fix bugs in the Java programs.

a)

JVM

b)

JRE

c)

JDB

d)

JDK

9.

What does the expression float a = 35 / 0 return?

a)

0

b)

NOT A NUMBER

c)

INFINITY

d)

RUN TIME EXCEPTION

10.

Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?

a)

delete

b)

free

c)

new

d)

none of the mentioned

11.

Which of the following option leads to the portability and security of Java?

a)

Bytecode is executed by JVM

b)

The applet makes the Java code secure and portable

c)

Use of exception handling

d)

Dynamic binding between objects

12.

What is the advantage of Exception Handling

a)

To avoid abnormal termination of a program

b)

To find out errors

c)

To Debug program

d)

None of these

13.

What is the purpose of 'throw' keyword

a)

To Raise an exception explicityly

b)

To Raise an exception implicityly

c)

To create user defined exceptions

d)

To create custom exceptions

14.

What is an exception

a)

Error occurred during the execution of a program

b)

Bug occurred during the compile time of a program

c)

Simply an Error

d)

It is related to input values

15.

Exception classes belongs to following package

a)

import java.io.*

b)

import java.lang.*

c)

import java.util.*

d)

import java.lang.Exception.*

16.

Choose the CORRECT exception


String department="JTMK";

Integer no=Integer.parseInt(department);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundsException

17.

Choose an exception if attempt to divide number by zero


int number = 89 / 0;

System.out.println("The answer is " + number);

a)

ArithmeticException

b)

NullPointerException

c)

NumberFormatException

d)

ArrayIndexOutOfBoundException

18.

1. Which of these keywords must be used to monitor for exceptions?

a)

a) try

b)

b) finally

c)

c) throw

d)

d) catch

19.

2. Class at the top of exception class hierarchy?

a)

ArithmeticException

b)

Throwable

c)

Object

d)

Exception

20.
Which of these method of FileReader class is used to read characters from a file?
a)
read()
b)
scanf()
c)
get()
d)
getInteger()
21.
Which stream used to read data from a source, it may be a file, an array, peripheral device or socket?
a)
InputStream
b)
OutputStream
c)
Input/OutputStream
d)
None of the above
22.
Which is used for writing data to a file in file handling?
a)
FileInputStream
b)
FileOutputStream
c)
Both A & B
d)
None of the above
23.
 Which exception is thrown by read() method?
a)
SystemInputException
b)
IOException
c)
SystemException
d)
InterruptedException
24.

Which of the below is/are valid identifier with the main method?

a)

public

b)

private

c)

static

d)

this

25.

For the array:

int stats[3];

What is the range of the index?

a)

0 to 3

b)

0 to 2

c)

1 to 3

d)

0 to 4

26.
Which of the following statements outputs the fifth value in the quizzes array?
a)
System.out.println(quizzes[5]);
b)
quizzes[4];
c)
quizzes[5];
d)
System.out.println(quizzes[4]);
27.
Index values of an array range from ______________.
a)
0 to length – 1
b)
1 to length
c)
0 to length
d)
0 to length + 1
28.
True or False:  An array can be store different types of data (like store both doubles and ints).
a)
True
b)
False
29.

Is String a primitive data type?

a)

Yes

b)

No

c)

Both

30.

Which of the following variable is declared as static?

a)

Home address of a particular Student

b)

Account number of a Customer

c)

Company name of all Employees in an Organization

d)

Name of a Employee

31.

Which of the following is not a correct statement?

a)

A class can have any number of static blocks

b)

Static method is accessed directly using class name

c)

Separate memory is allocated for each object for all static variables

d)

Static method is executed before main() method once a class is loaded

32.

Which of the following is Mutable object

a)

String

b)

StringBuffer

33.

After a StringBuffer has been constructed, how many characters may be added to it?

a)

No more after it has been constructed.

b)

Only as many as the original capacity.

c)

As many as needed; it will grow in size if necessary.

d)

A new StringBuffer must be constructed each time characters are added.

34.

What is the potential number of characters in a StringBuffer called?

a)

length

b)

size

c)

width

d)

capacity

35.

what will be output of below program

a)

Compile Time error

b)

0 0

c)

Run time Exception

d)

No Output

36.

What will be output of follwoing program

a)

Base

Derived

Derived

b)

Derived

Derived

Base

c)

Derived

Base

Derived

d)

compile time error

37.

what will be output of follwing program

a)

Compile time error

b)

Run time Exception

c)

x= 0 y=0

d)

x= 1 y= 1

38.

what will be output of following program?

a)

400

200

10

b)

10

400

200

c)

200

400

10

d)

10

200

400

39.

what will be output of following program?

a)

20

b)

10

c)

2

d)

20

40.

what will be output of following program?

a)

The output is true and LNCT fulfills the Object.equals() contract.

b)

The output is false and LNCT fulfills the Object.equals() contract.

c)

The output is true and LNCT does NOT fulfill the Object.equals() contract.

d)

The output is false and LNCT does NOT fulfill the Object.equals() contract.

41.

You wish to compare the contents of two StringBuffer objects. How should this be done?

a)

Use the == operator.

b)

Use the equals() method of StringBuffer.

c)

Construct a String object from each StringBuffer and use their equals() method.

d)

Do a character-by-character comparison using charAt() and ==.

42.

Choose the correct statement about the given code:

a)

The code will not compile because of line 2.

b)

The code will not compile because of line 4.

c)

The code will not compile because of line 7.

d)

It compiles but throws an exception at runtime.

43.

Choose the correct statement about the given code:

a)

The code will not compile because of line 3.

b)

The code will not compile because of line 4.

c)

The code will not compile because of lines 3 and 4.

d)

It compiles and runs without issue.

44.

Choose the correct statement about the given code:

a)

It compiles without issue.

b)

The code will not compile because of line 2.

c)

The code will not compile because of line 4.

d)

The code will not compile because of lines 2 and 5.

45.

Which statements are true about the given code? (Choose all that apply)

a)

The CanBark interface doesn’t compile.

b)

A class that implements CanBark inherits both the makeSound() and bark() methods.

c)

A class that implements CanBark only inherits the bark() method.

d)

An interface cannot extend another interface.

46.

What is the output of the given code?

a)

Lizard laying eggs

b)

The code will not compile because of line 4.

c)

The code will not compile because of line 2.

d)

The code will not compile because of line 9.

47.

What is the result of the given code?

a)

Bird is flying

b)

Pelican is flying

c)

The code will not compile because of line 4.

d)

The code will not compile because of line 9.

48.

What is the result of compiling and executing the following class?

a)

It does not compile.

b)

It compiles but throws an exception at runtime.

c)

It compiles and outputs 5.

d)

It compiles and outputs 15.

49.

Which statement about the given code is correct?

a)

The code does not compile due to line g1.

b)

The code does not compile due to line g2.

c)

The code does not compile due to line g3.

d)

The code compiles and runs without issue.

50.

What will it print?

a)

1

2

3

30

b)

1

2

30

c)

1

2

3

11

d)

1

2

11