Você está na página 1de 5

Sample Question Paper

QUESTION BANK
MODULE NAME: Learn Java by Example
Category - Simple
1)

Fill in the Blank with single option:


__________ is the ability of a program to run on any machine regardless of the
underlying platform.
a)

b)

2)

Polymorphism
Platform-Independence

c)

Data Encapsulation

d)

Garbage Collection

Fill in the Blank with single option:


__________ specifies the location for import classes (that is, it overrides the CLASSPATH
environment variable), when used in combination with javac compiler.

a)

3)

-classpath

b)

-version

c)

-help

d)

-verbose

Fill in the Blank with single option:


________ releases the memory occupied by an object once it determines that the object
is no longer accessible.
a)

b)

4)

Java Compiler
Garbage Collector

c)

Java Virtual Machine

d)

Java Interpreter

Fill in the Blank with single option:


A ________ signifies a fixed value and is represented directly in the code without
requiring computation.

Aptech Limited

Page 1

Sample Question Paper

a)

Constant

b)

Variable

c)
d)

5)

Literal
Class

Fill in the Blank with single option:


The Scanner class belongs to the _______ package.

a)

java.util

b)

java.awt

c)

java.lang

d)

java.net

Category - Average
1)

Select the correct answer with two options:


Identify the valid Reference data types from the following options:

a)

2)

Array

b)

Delegate

c)

Structure

d)

Interface

Select the correct answer with single option:


Identify the correct option that enables version controlling of files in Java.
a)

b)
c)

Refactor
The Concurrent Version System (CVS)
Build

Aptech Limited

Page 2

Sample Question Paper

d)

3)

Debug

Select the correct answer with single option:


Identify the type of multiline comment used in Java.
a)

// This is a comment

b)

/ This is a comment

c)
d)
4)

/* This is a comment */
/** This is a comment **/

Select the correct answer with single option:


What is the output of the following code?

double dbl = 10;


long lng = 100;
int in = 10;
dbl = in;
a)

b)

5)

It will have same integer value


assigns the integer value to double variable

c)

assigns the integer value to float variable

d)

assigns the integer value to long variable

Select the correct answer with two options:


Identify the functions of the for loop operation in Java:

a)

Used to execute a statement or a block of statements while a particular condition is true.

b)

Checks the condition at the end of the loop rather than at the beginning to ensure that the
loop is executed at least once.

c)

Used when the user knows how many times the statements need to be executed in the
code block of the loop.

d)

Used to execute a statement or a block of statements while a particular condition is


false.

Aptech Limited

Page 3

Sample Question Paper


Category Difficult
1)

Select the correct answer with single option:


Identify the correct output for the following code:
int i = 55/22;
// decimal integer
System.out.printf (55/22 = %d %n, i);

a)

2)

55/22=2

b)

55/22=2.0

c)

55/22=2.5

d)

55/22=2.05

Select the correct answer with single option:


Identify the correct output for hexadecimal escape sequence characters.

System.out.println(\u0048\u0065\u006C\u006C\u006F + !\n);

3)

a)

Helo!

b)

Hello!

c)

Helo

d)

Helloo!

Select the correct answer with two options:


Identify the correct syntax to create an object in Java.

a)

<class_name> <object_name> = new <constructor_name()>;

b)

<class_name> <object_name> = new <class_name()>;

c)

<class_name>

d)

<class_name> <object_name> =

Aptech Limited

= new <constructor_name()>;
<constructor_name()>;

Page 4

Sample Question Paper

4)

Select the correct answer with single option:


Identify the output of the following code:

int sum = 0;
int number = 0;
do {
number++;
sum += number;
if (sum > 6) break;
}while (number < 5);
System.out.println(sum);

5)

a)

It will continue the loop till Sum>6 and then break out of the loop

b)

It will continue the loop till Sum<6 and then break out of the loop

c)

It will continue the loop till Sum=6 and then break out of the loop

d)

It will continue the loop till Sum>=6 and then break out of the loop

Select the correct answer with single option:


Identify the correct output for the following code:

String empName = new String();


empName = \n\t\tDavid Blake.\t\n;
System.out.println(empName);
String newEmpName = empName.trim();
System.out.println(newEmpName);

a)

David Blake.

b)

\t David Blake.\t

c)

\t\tDavid Blake.\t

d)

\n\t\tDavid Blake.\t\n

Aptech Limited

Page 5

Você também pode gostar