wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Third Year Placement Training Revision Test

Total questions: 10

Worksheet time: 10mins

Name
Class
Date
1.

Number of primitive data types in Java are?

a)

6

b)

7

c)

8

d)

9

2.

Find the output of the following code.

int Integer = 24;

char String = 'I';

System.out.print(Integer);

System.out.print(String);

a)

Compile error

b)

Throws exception

c)

I

d)

24 I

3.

Find the output of the following program.

public class Solution {

public static void main(String[] args) {

short x = 10;

x = x * 5;

System.out.print(x); } }

a)

50

b)

10

c)

Compile error

d)

Syntax Error

4.

How many times will 'Interview' be printed?

int count = 101;

do {

System.out.println('Interview');

count++;

} while (count < 10);

a)

8

b)

9

c)

10

d)

1

5.

Find the output:

int n = 12345;

int r = 0;

while (n > 0) {

r = n % 10;

System.out.println(r); }

a)

54321

b)

12345

c)

Compile Error

d)

Infinite Loop

6.

Consider the following user inputs one by one as 10, java for the below program:

import java.util.Scanner;

public class extra1 {

public static void main(String[] args) {

Scanner s = new Scanner(System.in);

int a = s.nextInt();

System.out.println(a); } }

a)

10.0, Error

b)

10, Error

c)

Java, 10

d)

10, java

7.

What is the purpose of the PATH environment variable in Java?

a)

To locate Java libraries

b)

To store Java bytecode

c)

To locate the Java compiler

d)

To optimize Java code

8.

Which datatype would be best for storing a person's age in Java?

a)

int

b)

double

c)

long

d)

float

9.

What is the result of this operation in Java: (int)(7.9)?

a)

7

b)

7.9

c)

8

d)

Syntax Error

10.

Identify the error in this code:

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

System.out.println(i); }

System.out.println(i);

a)

Syntax error outside loop

b)

No error

c)

Variable i not accessible outside loop

d)

Infinite loop