Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DATA TYPES ,INPUT AND OUTPUT

Total questions: 25

Worksheet time: 16mins

Name
Class
Date
1.

What is the error in this code?

byte b=30;

b=b*30;

a)

b can not contain value 30, limited by its range

b)

b can not contain value 30.

c)

* has converted b *30 into int which can not be converted by using byte without casting.

d)

no error in this code

2.

What is a Widening Type Conversion in Java?

a)

Conversion of data from higher data type to lower data type

b)

Conversion of data from any data type to any data type

c)

Conversion of data from lower data type to higher data type

d)

all the above

3.

What is the result of a Narrowing type conversion?

a)

Addition of data

b)

Loss of data

c)

Corruption of data

d)

None of the above

4.

What is the output of the below Java code snippet?

float a = 8.2/2;

System.out.println(a);

a)

4.1

b)

8.1

c)

4

d)

compile time error

5.

A boolean literal in Java can be type casted to which data type?

a)

byte

b)

short

c)

int

d)

none of the above

6.

Which among the following is not a primitive data type in Java?

a)

char

b)

byte

c)

String

d)

short

7.

What is the default boolean literal assigned to a boolean variable in Java?

a)

true

b)

false

c)

undefined

8.

a)

hello

b)

hello world

c)

hello arg[0]

d)

runtime error

9.

ASCII values of upper case alphabets ..i.e A-Z are

a)

65-90

b)

66-91

c)

97-122

d)

98-123

10.

is it possible to type cast to boolean to int

a)

possible

b)

Not possible

11.

In the main method syntax, args in an array of String type.

a)

True

b)

False

c)

Can't Say

d)

Can be true or false

12.

A command-line argument in Java is a value passed at the time of ___ a program.

a)

Compiling

b)

Running

c)

after the program terminates

13.

Choose the correct way of receiving command-line arguments with in the main method in Java?

a)
b)
c)
d)
14.
a)

0

b)

10

c)

Compilation Error

d)

5-5

15.

a)

150

b)

100

c)

50

d)

10050

16.

What package is a part of the wrapper class which is imported by default into all Java programs?

a)

java.io

b)

java.util

c)

java.lang

d)

all the above

17.
a)

93

b)

93.52

c)

93.00

d)

number format error

18.

Which Scanner class method is used to read integer value from the user?

a)

next()

b)

nextInteger()

c)

nextInt()

d)

readInt()

19.

Which method does not store string value after space?

a)

next()

b)

nextLine()

c)

nextString()

20.

Which is the correct syntax to declare Scanner class object?

a)

Scanner objectName= new Scanner(System.in);

b)

Scanner objectName= new Scanner();

c)

Scanner objectName= Scanner(System.in);

d)

Scanner objectName= Scanner();

21.

Consider the following object declaration statement Scanner objectName= new Scanner(System.in); What is System.in in this declaration?

a)

passing variables from method

b)

passing variables to the method

c)

read input from keyboard

d)

forward data from display (monitor) to keyboard

22.

Which package should be imported to use Scanner class?

a)

import java.util.*;

b)

import java.util.System;

c)

import java.util.Scanner;

d)

import java.util.System.in;

23.

the operation performed on three variables belongs to which classification

a)

unary

b)

binary

c)

ternary

d)

all the above

24.

boolean b;

what are the supportable values for b in java

a)

true

b)

false

c)

0

d)

1

25.

which of the following are valid primitive data types.

a)

int

b)

String

c)

byte

d)

boolean

e)

Array