wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

type conversion

Total questions: 22

Worksheet time: 20mins

Name
Class
Date
1.

Java character set consists of

a)

Letters

b)

Digits

c)

Operators

d)

Delimiters

e)

All of the above

2.

________________ is an American standard coding system that is represented in 7 binary bits.

a)

ISO

b)

IEC

c)

UNICODE

d)

ASCII

3.

Non Graphic characters which are used as commands to direct the cursor while printing is known as _________________

a)

Operators

b)

Escape Sequence

c)

Delimiters

d)

Digits

4.

float myFloatNum = 5.99f;

System.out.println(myFloatNum);


What will be the output?

a)

5.99

b)

5.99f

c)

"5.99"

d)

"5.99"f

5.

int x = 5;

int y = 6

int z = 50;

System.out.println(x + y + z);


What will be the output?

a)

61

b)

5650

c)

66

d)

x + y + z

6.

Which of the following is NOT a NON-primitive data type

a)

String

b)

Array

c)

double

d)

class

7.

which of the following is NOT a primitive data type?

a)

byte

b)

array

c)

char

d)

boolean

8.

Which of the following is the right way of defining char variable?

a)

char myGrade = 'B';

b)

char myGrade = "B";

c)

char myGrade 'B';

d)

char myGrade = "B"

9.

int sum1 = 100 + 50;

int sum2 = sum1 + 250;

int sum3 = sum2 + sum2;

System.out.println(sum3);


What will be the final output?

a)

950

b)

800

c)

sum2sum2

d)

sum1250

10.

Which of the following is assignment operator?

a)

==

b)

=

c)

=+

d)

++

11.

int x = 10;

x = x + 5;

System.out.println(x);


What will be the output?

a)

15

b)

5

c)

55

d)

x5

12.

x /= 3


Which of the below statements matches with above statement?

a)

x = 3 / x

b)

x = x / 3

c)

x / 3

d)

x /x = 3

13.

int x = 4;

System.out.println(x < 5 && x < 10);


What will be the output?

a)

false

b)

true

c)

4

d)

x < 5 && x < 10

14.

int x = 4.4;

int y = 5.5;

System.out.println(x == y);


What will be the output?

a)

4.4

b)

true

c)

false

d)

5.5

15.

What is the output of below code?


int x = 5;

System.out.println(x++);

System.out.println(x);

a)

5

5

b)

6

6

c)

5

6

d)

6

5

16.

What would the new value of A be?

A=1;

a++;

a)

1

b)

2

c)

3

d)

4

17.

What would the new value of A be?

A=1;

A--;

a)

0

b)

1

c)

2

d)

-1

18.

What's the value of below?


int i=5;

System.out.println(i++);

System.out.println(i);

System.out.println(++i);

a)

5

6

7

b)

6

6

7

c)

6

7

8

d)

5

5

6

19.

++i and i++ cannot be used anywhere for the same purpose

a)

true

b)

false

20.

What does the following code output?

int x = 1;

System.out.println(x++);

a)

1

b)

2

c)

compilation error

d)

runtime error

21.

Which statement(s) are equivalent to i = i + 1?

a)

i += 1

b)

i++

c)

i -= 1

d)

i--

22.
Which of the sets of statements below will add 1 to x if x is positive and subtract 1 from x if x is negative but leave x alone if x is 0?
a)
if (x > 0)  x++;
else x--;
b)
if (x > 0) x++;
else if (x < 0) x--;
c)
if (x > 0) x++;
if (x < 0) x--;
else x = 0;
d)
if (x == 0) x = 0;
else x++;
x--;