Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Netligent Test

Total questions: 80

Worksheet time: 1hrs 22mins

Name
Class
Date
1.

Select the correct answer

a)

All integral integers in Java are signed

b)

All integral integers in Java are unsigned

2.

In Java, a datatype is ________ the operatoring system

a)

not depending

b)

depending

3.

Choose the correct answer(s)

a)

Primitve and non-primitive variables can be null

b)

Only primitive variables can be null

c)

Only non-primitve variables can be null

d)

A NullPointerException is raised when a null variable is accessed

e)

No Exception happens when a null variable is accessed

4.

Is this a valid statement and why?


long i = 1;

double d = i + 1;

a)

Yes, the compiler casts automatically

b)

No, the cast needs to happen manually

c)

Yes, because range of int is smaller then the range of double

d)

No, double has a smaller range than int

5.

_________ data type is used to store 'true' or 'false' value

a)

boolean

b)

int

c)

float

d)

char

6.

__________ data type is used to store decimal value

a)

int

b)

float

c)

double

d)

both float and double

7.

Converting several data types into one single one is called ___________

a)

concatenation

b)

assignment

c)

variable declaration

d)

type conversion

8.

size of double data type is ______________

a)

8 bits

b)

32 bits

c)

16 bits

d)

64 bits

9.

Which of the following is NOT a primitive datatype?

a)

byte

b)

boolean

c)

String

d)

int

10.

Which of these is necessary condition for automatic type conversion in Java?

a)

The destination type is smaller than source type

b)

The destination type is larger than source type

c)

The destination type can be larger or smaller than source type

d)

None of the mentioned

11.

What will be the error in the following Java code?

byte b = 50;

b = b * 50;

a)

b cannot contain value 100, limited by its range

b)

* operator has converted b * 50 into int, which can not be converted to byte without casting

c)

b cannot contain value 50

d)

No error in this code

12.

If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?

a)

long

b)

int

c)

double

d)

float

13.
a)

E U

b)

U E

c)

V E

d)

U F

14.

With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?

a)

1, 2 & 3

b)

1 & 4

c)

1, 2, 3 & 4

d)

3 & 2

15.

Decrement operator, −−, decreases the value of variable by what number?

a)

1

b)

2

c)

3

d)

4

16.

What will be the output of the following Java program?

a)

1 1

b)

0 1

c)

1.5 1

d)

1.5 1.0

17.

What will be the output of the following Java program?

a)

3 2 4

b)

3 2 3

c)

2 3 4

d)

3 4 4

18.

What is the output of relational operators?

a)

Integer

b)

Boolean

c)

Characters

d)

Double

19.

Which of these is returned by “greater than”, “less than” and “equal to” operators?

a)

Integers

b)

Floating – point numbers

c)

Boolean

d)

None

20.

Which of the following operators can operate on a boolean variable?

a)

3 & 2

b)

1 & 4

c)

1, 2 & 4

d)

1, 2 & 3

21.

Which of these statements is correct?

a)

true and false are numeric values 1 and 0

b)

true and false are numeric values 0 and 1

c)

true is any non zero value and false is 0

d)

true and false are non numeric values

22.
a)

0

b)

1

c)

3

d)

-4

23.

a)

0

b)

1

c)

false

d)

true

24.

a)

25

b)

24

c)

32

d)

33

25.

Can 8 byte long data type be automatically type cast to 4 byte float data type?

a)

True

b)

False

26.
a)

66

b)

67

c)

65

d)

64

27.

a)

95 67

b)

65 97

c)

67 95

d)

97 65

28.

a)

0

b)

1

c)

3

d)

-4

29.

What is the output of relational operators?

a)

Integer

b)

Boolean

c)

Characters

d)

Double

30.

Which of these is returned by “greater than”, “less than” and “equal to” operators?

a)

Integers

b)

Floating – point numbers

c)

Boolean

d)

None

31.

Which of the following operators can operate on a boolean variable?

a)

3 & 2

b)

1 & 4

c)

1, 2 & 4

d)

1, 2 & 3

32.

Which of these statements is correct?

a)

true and false are numeric values 1 and 0

b)

true and false are numeric values 0 and 1

c)

true is any non zero value and false is 0

d)

true and false are non numeric values

33.
a)

0

b)

1

c)

3

d)

-4

34.

a)

0

b)

1

c)

false

d)

true

35.

a)

25

b)

24

c)

32

d)

33

36.

Can 8 byte long data type be automatically type cast to 4 byte float data type?

a)

True

b)

False

37.
a)

66

b)

67

c)

65

d)

64

38.

a)

95 67

b)

65 97

c)

67 95

d)

97 65

39.

a)

0

b)

1

c)

3

d)

-4

40.

What will be the output for the following program?

a)

Hello Hello Hello

b)

Compile time error

c)

Hello (Infinitely)

d)

No output

41.

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

42.

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

43.

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

44.

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

a)

TRUE

b)

FALSE

45.

What is the output of the below Java program?

a)

1 2 3 4

b)

1 2 3

c)

6

d)

Compiler error

46.

What is the output of the below Java program?

a)

0

b)

1

c)

2

d)

3

e)

1 2

47.

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

a)

boolean

b)

int

c)

float

d)

chae

48.

What is the output of the Java program?

a)

OK MASTER

b)

BYE

c)

Compiler error

d)

None

49.

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 ");

a)

20

b)

4

c)

4 is negative

d)

20 is negative

50.

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

a)

Object file

b)

Array file

c)

Class file

d)

String file

51.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

52.

Which of the following personality is called as father of Java Programming language –

a)

Bill Gates

b)

Larry Page

c)

Brendan Greene

d)

James Gosling

53.

What is the range of short data type in Java

a)

-128 to 127

b)

-32768 to 32767

c)

-2147483648 to 2147483647

d)

None of the mentioned

54.

What is a correct syntax to output "Hello World" in Java?

a)

System.out.println("Hello World");

b)

Console.WriteLine("Hello World");

c)

echo("Hello World");

d)

print ("Hello World");

55.

Which statement is used to stop a loop?

a)

return

b)

break

c)

stop

d)

exit

56.

Which of the following is incorrect?

a)

int count = 50.0;

b)

int salary = 50_000;

c)

int salary = 50_00;

d)

all of these are incorrect

57.

Where does a java program start executing instructions from:

a)

class

b)

source file

c)

main method

d)

object

58.
What is at the end of a line of code?
a)
#
b)
;
c)
)
d)
>
59.

Click ALL answers which result in an "X" printed.

a)

a = 5, c = 5

b)

a = 0, c = 0

c)

a = 5, c = 4

d)

a = 6, c = 9

e)

a = 1, c = 0

60.

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)

a < 2

b)

a != b

c)

a > b

d)

b >= a

e)

b == a

61.
WHICH OF THE FOLLOWING IS THE RELATIONAL OPERATOR FOR NOT EQUAL TO?
a)
>=
b)
<>
c)
\=
d)
!=
62.
How many choices are possible when using a single if-else statement?
a)
1
b)
2
c)
3
d)
4
63.
a)
Under
b)
Over
c)
Under the limit
d)
Over the limit
64.
a)
You lose the prize
b)
You lose
c)
You win
d)
You win the prize
65.
a)
You win the prize
b)
You lose
c)
You win
d)
You lose the prize
66.
 Evaluate (to true or false) each of the following expressions:
14 >= 14
15 > 15
16 != 16
18 >= 19
a)
T, F, F, F
b)
T, T, T, T
c)
F, T, F, F
d)
F, T, T, F
67.
Evaluate the following expression:
2 + 2 == 4
a)
true
b)
false
c)
sometimes true
d)
only true on sundays
68.
Evaluate the following expression
Math.pow(2, 3) >= 9;
a)
true
b)
false
c)
compile error
d)
only true when the Patriots win
69.
Which expression below would determine if a number was odd?
a)
number % 2 ==0
b)
number / 2 == 0
c)
number % 2 == 1
d)
number % 10 == number
70.
a)
Low bridge: 
b)
Low bridge: proceed with caution.
c)
Proceed with caution.
d)
<nothing prints to the screen>
71.
a)
Danger: 
b)
Danger: deep water.
c)
Danger: deep water.  No swimming allowed.
d)
deep water.  No swimming allowed. 
72.
Fill in the blank so people 18 years and older are told to vote.
if ( age _________ 18 ) System.out.println("too young!"); else System.out.println("GO VOTE!");
a)
>
b)
>=
c)
<=
d)
<
73.
a)
true 
b)
false
c)
depends on compiler
d)
sometimes
74.

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")

a)

John is getting ice cream

John is getting grapes

b)

John is getting apple juice

John is getting grapes

c)

John is getting apple juice

d)

John is getting ice cream

75.

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")

a)

John is getting ice cream

John is getting grapes

b)

John is getting apple juice

John is getting grapes

c)

John is getting apple juice

d)

John is getting ice cream

76.

Is "X" printed?

a)

YES

b)

NO

77.

Is "X" printed?

a)

YES

b)

NO

78.

What is output?

a)

-1

b)

0

c)

1

d)

2

79.

Print "1" if x is equal to y, print "2" if x is greater than y, otherwise print "3".

a)

if else

<=

else

b)

If = else

else if

else

c)

if else <

if else

if

d)

if ==

else if

else

80.

Insert the missing parts to complete the following "short hand if...else statement" (ternary operator):

a)

" " ? ;

b)

( ) ? :

c)

( ) ; =

d)

< = ; ?