wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

java

Total questions: 87

Worksheet time: 22hrs 45mins

Name
Class
Date
1.

Attributes of an object are also known as

a)

methods

b)

properties

c)

classes

d)

functions

2.

Polymorphism related to :

a)

PPO

b)

Class

c)

OPP

d)

OOP

3.

Which from the following is a feature that allows us to perform a single action in different ways.

a)

Abstraction

b)

Polymorphism

c)

Encapsulation

d)

Inheritance

4.

The process by which objects of one class acquire the properties of objects of another class is known as

a)

Polymorphism

b)

Inheritance

c)

Data Hiding

d)

Association

5.
How many objects can be made from a class? 
a)
None, you make classes from objects
b)
one
c)
As many as you want
d)
All of the above
6.
What is the difference between a class and an object?
a)
A class is a blueprint to make an object
b)
An object is a blueprint to make a class
c)
A blueprint is an object to make a class
d)
Blueprint class is an object make a
7.
An object is an instance of a:
a)
parameter
b)
method
c)
class
d)
application
8.

Which of the these is the functionality of ‘Encapsulation’?

a)

Binds together code and data

b)

Using single interface for general class of actions

c)

Reduce Complexity

d)

All of the mentioned

9.

What is the main difference between float and double data types?

a)

4.1 is an example of float.

b)

4.11 is an example of double.

c)

Float consists of 8 bytes, and double consists of 4 bytes.

d)

Float consists of 4 bytes, and double consists of 8 bytes.

10.

How do you create a variable with the numeric value 5?

a)

float x = 5;

b)

x = 5;

c)

int x = 5;

d)

num x = 5

11.

Which data type is used to create a variable that should store text?

a)

myString

b)

String

c)

Txt

d)

string

12.

How do you insert COMMENTS in Java code?

a)

# This is a comment

b)

/* This is a comment

c)

// This is a comment

13.

Java is short for "JavaScript".

a)

true

b)

false

14.

How do you create a variable with the floating number 2.8?

a)

byte x = 2.8f

b)

x = 2.8f;

c)

float x = 2.8f;

d)

int x = 2.8f;

15.

The value of a string variable can be surrounded by single quotes.

a)

true

b)

false

16.

The default value of a static integer variable of a class in Java is,

a)

(a) 0

b)

(b) 1

c)

(c) Garbage value

d)

d) Null

e)

(e) -1.

17.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

18.

The name of the following should be the file name in Java

a)

Object Name

b)

Variable Nam

c)

Class Name

d)

Array Name

19.

Java program is

a)

Interpreted

b)

Compiled

20.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

21.

A ___________ file is created after successful compilation of a Java program.

a)

Object file

b)

Array file

c)

Class file

d)

String file

22.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

23.

Command to run a Java program

a)

javaa

b)

java

c)

jaava

d)

jaavaa

24.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

25.

JRE stands for

a)

Java Run Environment

b)

Java Run Execution

c)

Java Runtime Environment

d)

Java Ready Execution

26.

Java is

a)

Machine dependent language

b)

Machine independent language

27.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

28.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

29.

The name of the following should be the file name in Java

a)

Object Name

b)

Variable Nam

c)

Class Name

d)

Array Name

30.

Java program is

a)

Interpreted

b)

Compiled

31.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

32.

A ___________ file is created after successful compilation of a Java program.

a)

Object file

b)

Array file

c)

Class file

d)

String file

33.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

34.

Command to run a Java program

a)

javaa

b)

java

c)

jaava

d)

jaavaa

35.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

36.

JRE stands for

a)

Java Run Environment

b)

Java Run Execution

c)

Java Runtime Environment

d)

Java Ready Execution

37.

Java is

a)

Machine dependent language

b)

Machine independent language

38.

which of the following is wrapper class in java

a)

Float

b)

Integer

c)

Double

d)

all of above

39.

which one of the following is true?

a)

runnable interface declares the start method

b)

Thread.start() method is used to move a thread from a new state to the runnable state

c)

Thread.runnable() method is used to move a thread from new state to the runnable state

d)

Thread.run() method is used to move a thread from new state to the runnable state

40.

Which one of the following statement is not true about the collection interface?

a)

all methods defined in set interface are also defined in collection interface

b)

list interface extends collection interface

c)

set interface extends collection interface

d)

all methods defined in list interface are also defined in collection interface

41.

which one of the following is a legal decelration of a two- dimensional array of integers

a)

int[] a[] = new int[5][];

b)

int[5][5] a = new int[][];

c)

int a = new int[5,5];

d)

int[][] a = new int[][5];

42.

which interface needs to be implemented in order to make an object seralized

a)

clonnable

b)

remote

c)

seralizable

d)

none of the above

43.

superclass of all classes representing the output stream of characters is -------------

a)

OutputStream

b)

Reader

c)

InputStream

d)

Writer

44.

which of this class is used by character streams for reading data from buffer

a)

BufferReader

b)

InputStreamReader

c)

FileReader

d)

FileInputStream

45.

which one this keywords are used to create a class in java

a)

class

b)

struct

c)

int

d)

none of the avove

46.

which one of these events will cause the thread to die?

a)

on calling the sleep() method.

b)

when the execution of the run() method ends

c)

when the execution of the start() method ends

d)

on calling the wait() method

47.

which one of the following have elements in insertion order

a)

sorted map

b)

hashmap

c)

linkedhashmap

d)

treemap

48.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

49.

The name of the following should be the file name in Java

a)

Object Name

b)

Variable Nam

c)

Class Name

d)

Array Name

50.

Java program is

a)

Interpreted

b)

Compiled

51.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

52.

A ___________ file is created after successful compilation of a Java program.

a)

Object file

b)

Array file

c)

Class file

d)

String file

53.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

54.

Command to run a Java program

a)

javaa

b)

java

c)

jaava

d)

jaavaa

55.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

56.

JRE stands for

a)

Java Run Environment

b)

Java Run Execution

c)

Java Runtime Environment

d)

Java Ready Execution

57.

Java is

a)

Machine dependent language

b)

Machine independent language

58.

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

59.

Which of the following is not a Java features?

a)

Dynamic

b)

Architecture Neutral

c)

Use of pointers

d)

Object-oriented

60.

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

a)

JVM

b)

JRE

c)

JDK

d)

JDB

61.

Which of the following is a valid declaration of a char?

a)

char ch = '\utea';

b)

char ca = 'tea';

c)

char cr = \u0223;

d)

char cc = '\itea';

62.

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

a)

0

b)

Not a number

c)

Infinity

d)

Run time exception

63.

Evaluate the following Java expression, if x=3, y=5, and z=10:

++z + y - y + z + x++

a)

24

b)

23

c)

20

d)

25

64.

Which of the following for loop declaration is not valid?

a)

for ( int i = 99; i >= 0; i / 9 )

b)

for ( int i = 7; i <= 77; i += 7 )

c)

for ( int i = 20; i >= 2; - -i )

d)

for ( int i = 2; i <= 20; i = 2* i )

65.

Which of the following is not OOPS concept in Java?

a)

Inheritance

b)

Encapsulation

c)

Polymorphism

d)

Compilation

66.

Which of the following is a type of polymorphism in Java?

a)

Compile time polymorphism

b)

Execution time polymorphism

c)

Multiple polymorphism

d)

Multilevel polymorphism

67.

When does method overloading is determined?

a)

At run time

b)

At compile time

c)

At coding time

d)

At execution time

68.

Which concept of Java is a way of converting real world objects in terms of class?

a)

Polymorphism

b)

Encapsulation

c)

Abstraction

d)

Inheritance

69.

Which concept of Java is achieved by combining methods and attribute into a class?

a)

Encapsulation

b)

Inheritance

c)

Polymorphism

d)

Abstraction

70.

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

a)

JVM

b)

JDK

c)

JIT

d)

JRE

71.

Which of the below is invalid identifier with the main method?

a)

public

b)

static

c)

final

d)

private

72.

What is use of interpreter?

a)

They convert bytecode to machine language code

b)

They read high level code and execute them

c)

They are intermediated between JIT and JVM

d)

It is a synonym for JIT

73.

What is the extension of compiled java classes?

a)

.java

b)

.class

c)

.txt

d)

.js

74.

Which of these keywords is used to make a class?

a)

class

b)

struct

c)

int

d)

none of the mentioned

75.

Which of these statement is incorrect?

a)

Every class must contain a main() method

b)

Applets do not require a main() method at all

c)

There can be only one main() method in a program

d)

main() method must be made public

76.

Which of the following statements is correct?

a)

Public method is accessible to all other classes in the hierarchy

b)

Public method is accessible only to subclasses of its parent class

c)

Public method can only be called by object of its class

d)

Public method can be accessed by calling object of the public class

77.

Which of this keyword must be used to inherit a class?

a)

super

b)

this

c)

extend

d)

extends

78.

Output of following Java Program?

a)

Derived::show() called

b)

Base::show() called

c)

Run time Error

d)

Compilation Error

79.

Output of following Java Program?

a)

10

b)

20

c)

Compilation Error

d)

Run Time Error

80.

Output of following Java Program?

a)

12

b)

321

c)

123

d)

23

81.

What will be the output of following program?

a)

Base::show() called

b)

Derived::show() called

c)

Compiler Error

d)

Runtime Error

82.

What will be the output of the following program?

a)

Base::show() called

b)

Derived::show() called

c)

Compiler Error

d)

Run Time Error

83.

Which inheritance in java programming is not supported

a)

Multiple inheritance using classes

b)

Multiple inheritance using interfaces

c)

Multilevel inheritance

d)

Single inheritance

84.

What is subclass in java?

a)

A subclass is a class that extends another class

b)

A subclass is a class declared inside a class

c)

Both above.

d)

None of the above.

85.

Output of following Java program?

a)

Base

Derived

Derived

b)

Base

Base

Derived

c)

Base

Derived

Base

d)

Compiler Error

86.

Predict the output of following program

a)

Base

b)

Derived

c)

Compiler Error

d)

Runtime Error

87.

Predict the output of following Java Program

a)

Compiler Error

b)

Grandparent's Print()

Parent's Print()

Child's Print()

c)

Child's Print()

Parent's Print()

Grandparent's Print()

d)

Runtime Error