WorksheetsNetligent Test
Total questions: 80
Worksheet time: 1hrs 22mins
Select the correct answer
All integral integers in Java are signed
All integral integers in Java are unsigned
In Java, a datatype is ________ the operatoring system
not depending
depending
Choose the correct answer(s)
Primitve and non-primitive variables can be null
Only primitive variables can be null
Only non-primitve variables can be null
A NullPointerException is raised when a null variable is accessed
No Exception happens when a null variable is accessed
Is this a valid statement and why?
long i = 1;
double d = i + 1;
Yes, the compiler casts automatically
No, the cast needs to happen manually
Yes, because range of int is smaller then the range of double
No, double has a smaller range than int
_________ data type is used to store 'true' or 'false' value
boolean
int
float
char
__________ data type is used to store decimal value
int
float
double
both float and double
Converting several data types into one single one is called ___________
concatenation
assignment
variable declaration
type conversion
size of double data type is ______________
8 bits
32 bits
16 bits
64 bits
Which of the following is NOT a primitive datatype?
byte
boolean
String
int
Which of these is necessary condition for automatic type conversion in Java?
The destination type is smaller than source type
The destination type is larger than source type
The destination type can be larger or smaller than source type
None of the mentioned
What will be the error in the following Java code?
byte b = 50;
b = b * 50;
b cannot contain value 100, limited by its range
* operator has converted b * 50 into int, which can not be converted to byte without casting
b cannot contain value 50
No error in this code
If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?
long
int
double
float
E U
U E
V E
U F
With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?
1, 2 & 3
1 & 4
1, 2, 3 & 4
3 & 2
Decrement operator, −−, decreases the value of variable by what number?
1
2
3
4
What will be the output of the following Java program?
1 1
0 1
1.5 1
1.5 1.0
What will be the output of the following Java program?
3 2 4
3 2 3
2 3 4
3 4 4
What is the output of relational operators?
Integer
Boolean
Characters
Double
Which of these is returned by “greater than”, “less than” and “equal to” operators?
Integers
Floating – point numbers
Boolean
None
Which of the following operators can operate on a boolean variable?
3 & 2
1 & 4
1, 2 & 4
1, 2 & 3
Which of these statements is correct?
true and false are numeric values 1 and 0
true and false are numeric values 0 and 1
true is any non zero value and false is 0
true and false are non numeric values
0
1
3
-4
0
1
false
true
25
24
32
33
Can 8 byte long data type be automatically type cast to 4 byte float data type?
True
False
66
67
65
64
95 67
65 97
67 95
97 65
0
1
3
-4
What is the output of relational operators?
Integer
Boolean
Characters
Double
Which of these is returned by “greater than”, “less than” and “equal to” operators?
Integers
Floating – point numbers
Boolean
None
Which of the following operators can operate on a boolean variable?
3 & 2
1 & 4
1, 2 & 4
1, 2 & 3
Which of these statements is correct?
true and false are numeric values 1 and 0
true and false are numeric values 0 and 1
true is any non zero value and false is 0
true and false are non numeric values
0
1
3
-4
0
1
false
true
25
24
32
33
Can 8 byte long data type be automatically type cast to 4 byte float data type?
True
False
66
67
65
64
95 67
65 97
67 95
97 65
0
1
3
-4
What will be the output for the following program?
Hello Hello Hello
Compile time error
Hello (Infinitely)
No output
What will be the output of the following program?
i = 15 j = 13 k = 759
i = 16 j = 16 k = 297
i = 11 j = 10 k = 801
i = 15 j = 13 k = 808
Program goes into infinite loop
What will be the output of the following program?
n = 5
n = 4
n = 3
n = 2
n = 1
n = 4
n = 3
n = 2
n = 1
Compilation Error
n = 5
n = 4
n = 3
n = 2
n = 1
n = 0
A CONTINUE statement inside a Loop like WHILE, FOR, DO-WHILE and Enhanced-FOR causes the program execution ___ the loop.
A) Skip
Skip present iteration and continue with next iteration of the loop
Exit
None
An Increment operator "++" and/or a Decrement operator "--" are used along with a Loop-Counter variable in Java.
TRUE
FALSE
What is the output of the below Java program?
1 2 3 4
1 2 3
6
Compiler error
What is the output of the below Java program?
0
1
2
3
1 2
An IF or ELSE IF statement accepts ___ as input before branching.
boolean
int
float
chae
What is the output of the Java program?
OK MASTER
BYE
Compiler error
None
What will be the output for the following program segment?
int num = 20;
if (num > 0)
if (num % 5 == 0)
System.out.println(num);
else System.out.println(num + " is negative ");
20
4
4 is negative
20 is negative
A ___________ file is created after successful compilation of a Java program.
Object file
Array file
Class file
String file
Command to compile Java program
javax
javay
javac
Java
Which of the following personality is called as father of Java Programming language –
Bill Gates
Larry Page
Brendan Greene
James Gosling
What is the range of short data type in Java
-128 to 127
-32768 to 32767
-2147483648 to 2147483647
None of the mentioned
What is a correct syntax to output "Hello World" in Java?
System.out.println("Hello World");
Console.WriteLine("Hello World");
echo("Hello World");
print ("Hello World");
Which statement is used to stop a loop?
return
break
stop
exit
Which of the following is incorrect?
int count = 50.0;
int salary = 50_000;
int salary = 50_00;
all of these are incorrect
Where does a java program start executing instructions from:
class
source file
main method
object
Click ALL answers which result in an "X" printed.
a = 5, c = 5
a = 0, c = 0
a = 5, c = 4
a = 6, c = 9
a = 1, c = 0
Given : a = 1, b = 2
if ( missing ) print "X"
Select ALL expressions which can be used for missing to result in an "X" being printed.
a < 2
a != b
a > b
b >= a
b == a
14 >= 14
15 > 15
16 != 16
18 >= 19
2 + 2 == 4
Math.pow(2, 3) >= 9;
if ( age _________ 18 ) System.out.println("too young!"); else System.out.println("GO VOTE!");What is my result?
john = 10
if (john > 6)
print("John is getting ice cream")
else
print("John is getting apple juice")
print("John is getting grapes")
John is getting ice cream
John is getting grapes
John is getting apple juice
John is getting grapes
John is getting apple juice
John is getting ice cream
What is my result?
john = 6
if (john != 60)
print("John is getting ice cream")
else
print("John is getting apple juice")
print("John is getting grapes")
John is getting ice cream
John is getting grapes
John is getting apple juice
John is getting grapes
John is getting apple juice
John is getting ice cream
Is "X" printed?
YES
NO
Is "X" printed?
YES
NO
What is output?
-1
0
1
2
Print "1" if x is equal to y, print "2" if x is greater than y, otherwise print "3".
if else
<=
else
If = else
else if
else
if else <
if else
if
if ==
else if
else
Insert the missing parts to complete the following "short hand if...else statement" (ternary operator):
" " ? ;
( ) ? :
( ) ; =
< = ; ?
