NEW
Font size
WorksheetsThird Year Placement Training Revision Test
Total questions: 10
Worksheet time: 10mins
Number of primitive data types in Java are?
6
7
8
9
Find the output of the following code.
int Integer = 24;
char String = 'I';
System.out.print(Integer);
System.out.print(String);
Compile error
Throws exception
I
24 I
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); } }
50
10
Compile error
Syntax Error
How many times will 'Interview' be printed?
int count = 101;
do {
System.out.println('Interview');
count++;
} while (count < 10);
8
9
10
1
Find the output:
int n = 12345;
int r = 0;
while (n > 0) {
r = n % 10;
System.out.println(r); }
54321
12345
Compile Error
Infinite Loop
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); } }
10.0, Error
10, Error
Java, 10
10, java
What is the purpose of the PATH environment variable in Java?
To locate Java libraries
To store Java bytecode
To locate the Java compiler
To optimize Java code
Which datatype would be best for storing a person's age in Java?
int
double
long
float
What is the result of this operation in Java: (int)(7.9)?
7
7.9
8
Syntax Error
Identify the error in this code:
for(int i = 0; i <= 5; i++) {
System.out.println(i); }
System.out.println(i);
Syntax error outside loop
No error
Variable i not accessible outside loop
Infinite loop
