wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

22BCA6A-Java-Quiz1

Total questions: 100

Worksheet time: 1hrs 18mins

Name
Class
Date
1.

It is used to store two types of values, i.e., true or false. This data type is commonly used as a flag in code logic.

a)

boolean

b)

byte

c)

char

d)

String

2.

It can store 8-bit signed two’s complement integer. The range lies between -128 to 127

a)

byte

b)

boolean

c)

char

d)

string

3.

This data type is used to store a single 16-bit Unicode character. It stores just one character in simple words, and the word Unicode is used because java uses the Unicode system, not the ASCII system. The size of this data type is 16bits (2 bytes).

a)

byte

b)

boolean

c)

char

d)

int

4.

It is a data type that stores 32 bit(4 bytes) two’s complement integer, i.e., its range lies within (-2^31 to 2^32 – 1).

a)

int

b)

float

c)

double

d)

String

5.

Similar to ‘int,’ it is also used to store integer values but within 16-bit (2 bytes) signed two’s complement. Its range lies within (-2^15 to 2^16-1).

a)

int

b)

long

c)

short

d)

byte

6.

It is 64 bit two’s complement integer and its range lies within (-2^63 to2^64 – 1) i.e. ( -9,223,372,036,854,775,808 to 9,223,372,036,854,775,808).

a)

int

b)

short

c)

long

d)

byte

7.

It is a data type that holds data with more precision, i.e., floating-point numbers. It is a single-precision 32-bit (4 bytes) IEEE754 floating-point.

a)

int

b)

float

c)

double

d)

char

8.

It is a double-precision 64-bit (8 bytes) IEEE754 floating point.

a)

float

b)

double

c)

long

d)

int

9.

It is a sequence of characters.

a)

char

b)

string

c)

boolean

d)

int

10.

An element of a program that defines the type of data that a variable will hold

a)

variable

b)

expression

c)

operator

d)

data type

11.

Which of these is long data type literal?

a)

0x99fffL

b)

ABCDEFG

c)

0x99fffa

d)

99671246

12.

System.out.println("one\rtwo");

a)

two

b)

onetwo

c)

one\rtwo

d)

twoone

13.

System.out.println("one\btwo");

a)

one two

b)

onetwo

c)

one

two

d)

ontwo

14.

System.out.println("\"Java Program\"");

(a)  

15.

System.out.println("b="+0b101);

(a)  

16.

How many primitive data types are there in java?

(a)  

17.

Which is the smallest integer datatype in java?

a)

byte

b)

int

c)

small

d)

smallint

18.

Choose valid identifier

a)

a_101$100

b)

100$a

c)

/a_123

d)

(a100)

19.

How will you declare a boolean data type

a)

boolean b;

b)

bool b;

20.

Long is 4 byte size in storage?

a)

True

b)

False

21.

char is 2 byte in storage?

a)

True

b)

False

22.

(=) sign means

a)

equals and it is used for math problems in Java

b)

assignment operator. It used to assign a value

23.

Which one is used for remainder in Java?

a)

/

b)

%

c)

+

d)

*

24.

int x = 3; in this case, which of the following statement is true?

a)

x = x+1;

b)

x++;

c)

x += 1;

d)

All of above

25.

A developer wants to convert a smaller data type to larger data type. What is this in Java?

a)

Widening primitive

b)

Narrowing primitive

26.

Which of the following is NOT safe and can result in a loss of data?

a)

Narrowing primitive

b)

Widening primitive

27.

This data type returns true or false

a)

String

b)

boolean

c)

char

d)

int

28.

Name the data type: 1.0

a)

double

b)

int

c)

char

d)

boolean

29.

Name the data type: "true"

a)

boolean

b)

char

c)

String

d)

double

30.

Name the data type: '3'

a)

int

b)

char

c)

String

d)

None of the above

31.

Which expression evaluates to true?

a)

false == false

b)

true != true

c)

4 < 4

d)

true == true != true

32.

Which expression evaluates to false?

a)

15 % 3 < 2

b)

3 * 3 % 2 <= 0

c)

false == false

d)

false == false == false == false

33.

Which declaration will throw an error?

a)

String name = "1 1233 141";

b)

double num = 1;

c)

int bigNumber = 1234567890;

d)

char random = '7';

34.

Which declaration will throw an error?

a)

double num = 8;

b)

int averageGrade = 89.7;

c)

boolean done = false;

d)

String done = "true";

35.

Which of the following is a primitive data type?

a)

double

b)

Integer

c)

String

d)

List

e)

Number

36.

int x;


/* What is the correct description of the code segment? */

a)

The variable x has been declared as an int.

b)

The variable x has been initialized as an int.

c)

The variable x has been instantiated as an int.

d)

The variable x has been referenced as an int.

37.

Which best describes primitive data types in Java?

a)

Primitive data types point to an object.

b)

Primitive data types are rarely used in Java.

c)

String is a primitive data type.

d)

Primitive data types are the most basic building blocks of all code generated in Java.

e)

Primitive data types are data types used by cave people to write code.

38.

Java Tokens help the compiler. Which of the following is a type of Java Token?

a)

Identifiers

b)

Keywords

c)

Operators

d)

All of the answers.

39.
if - else statement
a)
a loop that iterates, or repeats, until a condition is met
b)
a loop that iterates, or repeats, for a set number of times
c)
makes a decision based on input
d)
creates spaces in memory that holds elements all of the same types
40.
single line comments, which the computer doesn't read, start with
a)
//
b)
..
c)
**
d)
uppercase letters
41.
a)

15

b)

5

c)

Compiler error

d)

Runtime error

42.
a)

15

b)

5

c)

Compiler error

d)

Runtime error

43.
a)

15

b)

5

c)

Compiler error

d)

Runtime error

44.
a)

15

b)

5

c)

Compiler error

d)

Runtime error

45.
a)

15

b)

5

c)

Compiler error

d)

Runtime error

46.
a)

15

b)

5

c)

Compiler error

d)

Runtime error

47.
a)

15

b)

5

c)

15.0

d)

5.0

48.
a)

true

b)

false

c)

Compiler error

d)

Runtime error

49.
a)

11

b)

12

c)

Compiler error

d)

Runtime error

50.
a)

11.0

b)

12.0

c)

11

d)

12

51.
a)

false

b)

true

c)

Compiler error

d)

Runtime error

52.
a)

11

9

b)

11

10

c)

10

9

d)

9

8

53.
a)

12

11

b)

11

11

c)

10

11

d)

11

12

54.
a)

11

b)

12

c)

10

d)

13

55.
a)

11

b)

12

c)

10

d)

13

56.
a)

11

b)

12

c)

10

d)

Compiler error

57.
a)

11

b)

12

c)

10

d)

Compiler error

58.
a)

-11

9

b)

10

-10

c)

10.0

-10.0

d)

Compiler error

59.
a)

200

b)

190

c)

101

d)

0.5

60.
a)

220

b)

210

c)

1000

d)

0

61.
a)

220

b)

210

c)

1000

d)

0

62.
a)

2

b)

80

c)

Compiler error

d)

20

63.
a)

5

5

b)

5

10

c)

10

10

d)

10

5

64.
a)

true

b)

false

c)

Runtime error

d)

Compiler error

65.
a)

10

b)

No output

c)

Compiler error

d)

Runtime error

66.
a)

a

b)

b

c)

Compiler error

d)

-1

67.
a)

a

b)

b

c)

Compiler error

d)

-1

68.
a)

true

b)

false

c)

Compiler error

d)

Runtime error

69.
a)

true

b)

false

c)

Compiler error

d)

Runtime error

70.
a)

true

b)

false

c)

Compiler error

d)

Runtime error

71.
a)

true

b)

false

c)

Compiler error

d)

Runtime error

72.
a)

0

b)

10

c)

Compiler error

d)

5

73.
a)

0

b)

10

c)

Compiler error

d)

5

74.
a)

true

b)

false

c)

Compiler error

d)

No output025

75.
a)

true

b)

false

c)

Compiler error

d)

10

76.
a)

false

11

b)

true

12

c)

false

12

d)

Compiler error

77.
a)

20

b)

25

c)

Compiler error

d)

Runtime error

78.
a)

12

b)

11

c)

Compiler error

d)

Runtime error

79.
a)

-128

b)

128

c)

Compiler error

d)

Runtime error

80.
a)

-128

b)

128

c)

Compiler error

d)

Runtime error

81.
a)

true

b)

false

c)

Compiler error

d)

Runtime error

82.
a)

true

b)

false

c)

Compiler error

d)

Runtime error

83.
a)

6

10

b)

5

10

c)

6

11

d)

No output

84.
a)

6

10

b)

5

10

c)

6

11

d)

No output

85.
a)

6

10

b)

5

10

c)

6

11

d)

No output

86.
a)

6

10

b)

5

10

c)

6

11

d)

No output

87.
a)

6

10

12

b)

5

10

11

c)

6

11

12

d)

No output

88.
a)

6

10

11

b)

5

10

11

c)

6

11

12

d)

No output

89.
a)

6

11

11

b)

5

10

11

c)

6

10

12

d)

No output

90.
a)

6

11

11

b)

5

10

11

c)

6

10

12

d)

No output

91.
a)

6

11

12

b)

5

10

11

c)

6

10

12

d)

No output

92.
a)

6

11

12

b)

5

10

11

c)

6

10

11

d)

No output

93.
a)

6

11

11

b)

5

10

11

c)

6

10

11

d)

No output

94.
a)

6

11

11

b)

5

10

11

c)

6

10

11

d)

No output

 

95.
a)

6

11

11

12

b)

5

10

11

12

c)

6

10

11

12

d)

No output

96.
a)

6

11

12

13

b)

5

10

11

12

c)

6

11

12

12

d)

No output

97.
a)

6

11

12

13

b)

5

10

11

12

c)

6

11

12

12

d)

No output

98.
a)

6

11

12

13

b)

5

10

11

12

c)

6

11

11

12

d)

No output

99.
a)

6

11

12

13

b)

5

10

11

12

c)

6

11

11

12

d)

No output

100.
a)

6

11

12

13

b)

5

10

11

12

c)

6

11

11

12

d)

No output