wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Batch-2_Test-2

Total questions: 87

Worksheet time: 50mins

Name
Class
Date
1.

Which statement is true about java ?

a)

Java is a sequence-depended programming language

b)

Java is a code dependent programming language

c)

Java is a platform-dependent programming language

d)

Java is a platform-independent programming language

2.

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

a)

JRE

b)

JIT

c)

JDK

d)

JVM

3.

Which one of the following is not a java feature

a)

Object-oriented

b)

Use of pointers

c)

Portable

d)

Dynamic and Extensible

4.

Which of these cannot be used for a variable name in java ?

a)

Identifier & keyword

b)

Identifier

c)

Keyword

d)

None of the mentioned

5.

Which of the following is not an OOPS concept in java ?

a)

Polymorphism

b)

Inheritance

c)

Compilation

d)

Encapsulation

6.

Which of these are selection statements in java

a)

Break

b)

Continue

c)

For ( )

d)

If ( )

7.

Which of these keywords is used to define interfaces in java

a)

intf

b)

Intf

c)

interface

d)

Interface

8.

Which of the following is a superclass of every class in java ?

a)

ArrayList

b)

Abstract class

c)

Object class

d)

String

9.

Which of these packages contains the exception stack Overflow in java ?

b)

Java.system

c)

Java.lang

d)

Java.util

10.

Which of these statements is incorrect about tread ?

a)

Start() method is used to begin execution of the thread

b)

Run () method is used to begin execution of a thread before start() method in special cases

c)

A thread can be formed by implementing runnable interface only

d)

A thread can be formed by a class that extends thread class

11.

Which of these keywords are used for the block to be examined for exceptions ?

a)

Check

b)

Throw

c)

Catch

d)

Try

12.

Which one of the following is not an access modifier ?

a)

Protected

b)

Void

c)

Public

d)

Private

13.

What is the numerical range of a char data tupe in java ?

a)

0 to 256

b)

-128 to 127

c)

0 to 65535

d)

0 to 32767

14.

When does method overloading is determined?

a)

At run time

b)

At compile time

c)

At coding time

d)

At execution time

15.

When overloading does not occur ?

a)

More than one method with same name but different method signature and different number or type of parameters

b)

More than one method with same name,same signature but different number of signature

c)

More than one method with same name,same signature,same number of parameters but different type

d)

More than one method with same , same number of parameters and type but different signature

16.

What is it called if an object has its own life cycle and there is no owner

a)

Aggregation

b)

Composition

c)

Encapsulation

d)

Association

17.

Method overriding is combination of inheritance and polymorphism ?

a)

True

b)

False

18.

Which of the below is invalid identifier with the main method

a)

Public

b)

Static

c)

Private

d)

Final

19.

How can we identify whether a compilation unit is class or interface from a .class file ?

a)

Java source file header

b)

Extension of compilation unit

c)

We cannot different between class and interface

d)

The class or interface name should be postfixed with unit type

20.

What is use of interpreter ?

a)

They covert 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

21.

1. Which of this method is given parameter via command line arguments?

a)

a) main()

b)

b) recursive() method

c)

c) Any method

d)

d) System defined methods

22.

What are the Type Conversions available in Java language?

a)

A) Narrowing Type Conversion

b)

B) Widening Type Conversion

c)

A and B

d)

D) None of the above

23.

What is the output of the below Java code snippet?

char ch = 'A';//ASCII 65

int a = ch + 1;

ch = (char)a;

System.out.println(ch);

a)

A) 66

b)

B) A

c)

C) B

d)

D) 65

24.

Which type of loop is best known for its boolean condition that controls entry to the loop?

a)

A. do-while loop

b)

B. for (traditional)

c)

C. for-each

d)

D. while

25.

What will be the Output of the below code:

public class Demo{

public static void main(String[] arr){

}

public static void main(String arr){

}

}

a)

a) Nothing

b)

b) Error

c)

C) Finite

d)

d) Hii

26.

char is 2 byte in storage?

a)

True

b)

False

27.

Name the data type: '3'

a)

int

b)

char

c)

String

d)

None of the above

28.

What data type would you use for storing the number of students in a class?

a)

boolean

b)

String

c)

double

d)

int

29.
What data type would be best used to record an email address?
a)
String
b)
Integer
c)
Real
d)
Character
30.

What is the output of the below Java code snippet?

char ch = 'A';//ASCII 65

int a = ch + 1;

ch = (char)a;

System.out.println(ch);

a)

A) 66

b)

B) A

c)

C) B

d)

D) 65

31.

What is the output of the following code snippet?

int i = 0; for(i = 0 ; i < 5; i++)

{ }

System.out.println(i);

a)

A. 5

b)

B. 0

c)

C. 4

d)

D. Compilation Error

32.

Function of the Scanner class to accept a float literal from the user is

a)

nextInt( )

b)

hasNext( )

c)

next( )

d)

nextFloat( )

33.

Predict the value of k,

int k =10;

k=k+k++;

a)

11

b)

20

c)

21

d)

22

34.
Which of these is not a Thread state?
a)
New
b)
Runnable
c)
sleep
d)
terminated
35.

Which of the following key word is optional in Exception handling program

a)

try

b)

catch

c)

finally

d)

throw

36.

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

37.

Exception classes belongs to following package

a)

import java.io.*

b)

import java.lang.*

c)

import java.util.*

d)

import java.lang.Exception.*

38.

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

39.

class exception_handling

{ public static void main(String args[])

{ try

{ int a, b;

b = 0;

a = 5 / b;

System.out.print("A");

} catch(ArithmeticException e)

{ System.out.print("B");

}

finally

{ System.out.print("C");

}

}

}

a)

A

b)

B

c)

AC

d)

BC

40.

Find the output for the following.

public class IncDec

{

public static void main(String s[])

{

int a = 1;

int b = 2;

int c;

int d;


c = ++b;

d = a++;


c++;


System.out.println("a = " + a);

System.out.print("b = " + b);

System.out.println("c = " + c);

System.out.print("d = " + d);

}

}

a)

a = 2 b = 3 c = 4 d = 1

b)

a = 2 b = 3 c = 4 d = 1

c)

Program does not compile.

d)

a = 1 b = 2 c = 4 d = 2

41.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

42.

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

a)

Object Name

b)

Variable Nam

c)

Class Name

d)

Array Name

43.

Java program is

a)

Interpreted

b)

Compiled

44.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

45.

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

a)

Object file

b)

Array file

c)

Class file

d)

String file

46.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

47.

Command to run a Java program

a)

javaa

b)

java

c)

jaava

d)

jaavaa

48.

JDK stands for

a)

Java Developer Kit

b)

Java Development Kit

c)

Java Design Kit

d)

Java Debugging Kit

49.

JRE stands for

a)

Java Run Environment

b)

Java Run Execution

c)

Java Runtime Environment

d)

Java Ready Execution

50.

Java is

a)

Machine dependent language

b)

Machine independent language

51.
In the statement  int x; What is x ?
a)
a variable
b)
a data type
c)
a class
d)
an object
52.
In the statement 
 Bank tom = new Bank(5000.0);
Which is the class?
a)
Bank
b)
tom
c)
new
d)
5000.0
53.
In the statement 
Bank tom = new Bank(5000.0);

Which is the object?
a)
Bank
b)
tom
c)
new
d)
5000.0
54.
In the statement  int x; What is int ?
a)
a variable
b)
a data type
c)
a class
d)
an object
55.
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
56.
The ____ method executes first in an application, regardless of where you physically place it within its class.
a)
execute()
b)
main()
c)
start()
d)
run()
57.

which package is imported implicitly?

a)

java.applet

b)

java.util

c)

java.lang

d)

java.io

58.

Classes in Java are:

a)

Abstract data types, used as a template of objects

b)

Where students learn

c)

Dungeons and Dragons Character types

d)

None of these

59.

To create an object in java we use the keyword new.

a)

True

b)

False

60.

Which is the fundamental unit of OOP?

a)

Object

b)

Class

61.

Class is a_________.

a)

object / Template

b)

blue print / Template

c)

Instance / blue print

62.

TextBook English=new Textbook();

In the above snippet, TextBook is a _______.

a)

Object

b)

Data member

c)

Member function

d)

Class

63.

TextBook English=new Textbook();

In the above snippet, English is an _______.

a)

Object

b)

Class

c)

Member function

d)

Class name

64.

The process of binding data and functions is called as

a)

Inheritance

b)

Polymorphism

c)

Abstraction

d)

Encapsulation

65.

The process of hiding the implementation details from the user is called

a)

Abstraction

b)

Polymorphism

c)

Inheritance

d)

Encapsulation

66.

A class can have any number of objects

a)

false

b)

true

c)

neither true nor false

d)

cannot say

67.

The OOPs concept, exposing only necessary information to users or clients is known as

a)

Inheritance

b)

Insulation

c)

Abstraction

d)

Polymorphism

68.

Predict the output of following Java program?

class Test {

int i;

}

class Main {

public static void main(String args[]) {

Test t;

System.out.println(t.i);

}

a)

0

b)

garbage value

c)

Compiler Error

d)

Run Time Error

69.

Predict the output of following Java program

class Test

{ int i;

}

class Main

{ public static void main(String args[])

{ Test t = new Test();

System.out.println(t.i);

} }

a)

Garbage Value

b)

0

c)

Compiler Error

d)

Runtime error

70.

Tools that provide support for software development process including editors and debuggers are called

a)

integrated development environments

b)

bytecode converters

c)

virtual machine converters

d)

memory verifier

71.

Which of the following is not a feature of Java

a)

Robust

b)

Platform Specific

c)

Multithreaded

d)

Object-Oriented

72.

Among the following list, which is/are the optional items that can be present in a Java Program

a)

Documentation Section

b)

Import Statements

c)

Main Method Class

d)

Package declaration

73.

The presence of JVM makes java program platform independent.

a)

True

b)

False

74.

Advantages of OOPs

a)

Code Reusability

b)

Easy Maintenance

c)

Security

d)

Use of Procedures

75.

Pure OOP can be implemented without using class in a program. (True or False)

a)

True

b)

False

76.

What is the output of the following code snippet?

public class MyClass {

public static void main(String[] args) {

int x = 5;

System.out.println(x++ + ++x);

}

}

a)

10

b)

11

c)

12

d)

13

77.

What will be the output for the following program?

a)

Hello Hello Hello

b)

Compile time error

c)

Hello (Infinitely)

d)

No output

78.

What will be the output of the following program?

a)

i = 15 j = 13 k = 759

b)

i = 16 j = 16 k = 297

c)

i = 11 j = 10 k = 801

d)

i = 15 j = 13 k = 808

e)

Program goes into infinite loop

79.

What will be the output of the following program?

a)

n = 5

n = 4

n = 3

n = 2

n = 1

b)

n = 4

n = 3

n = 2

n = 1

c)

Compilation Error

d)

n = 5

n = 4

n = 3

n = 2

n = 1

n = 0

80.

A CONTINUE statement inside a Loop like WHILE, FOR, DO-WHILE and Enhanced-FOR causes the program execution ___ the loop.

a)

A) Skip

b)

Skip present iteration and continue with next iteration of the loop

c)

Exit

d)

None

81.

Choose the Java-Code below with a never-ending loop.

a)

while(true);

b)

for(;true;);

c)

do

{

;

}while(true);

d)

All

82.

An Increment operator "++" and/or a Decrement operator "--" are used along with a Loop-Counter variable in Java.

a)

TRUE

b)

FALSE

83.

What is the output of the below Java program?

a)

1 2 3 4

b)

1 2 3

c)

6

d)

Compiler error

84.

What is the output of the below Java program?

a)

0

b)

1

c)

2

d)

3

e)

1 2

85.

An IF or ELSE IF statement accepts ___ as input before branching.

a)

boolean

b)

int

c)

float

d)

chae

86.

What is the output of the Java program?

a)

OK MASTER

b)

BYE

c)

Compiler error

d)

None

87.

public class MyClass {

public static void main(String[] args) {

(a)   ("Hello World");

}

}