Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

string and Inputstream

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Choose the correct input stream class

a)

System.io

b)

System.in

c)

System.out

d)

System.InOut

2.

Find the output

String str1="java";

String str2="Java";

System.out.println(str1==str2));

a)

false

b)

true

c)

boolean

d)

equals

3.

Find the output

String str1="JAva";

System.out.println(str1.indexOf('a'));

a)

1

b)

2

c)

3

d)

4

4.

The input read by the using System.in.read() returns what value?

a)

char

b)

ascii

c)

int

d)

float

5.

Which one is correct string declaration?

a)

Char greeting = "Hello";

b)

greeting = "Hello";

c)

String greeting = 'Hello';

d)

String greeting = "Hello";

6.

str1="sona";

System.out.println(str1.charAt(3));

a)

s

b)

o

c)

n

d)

a

7.

WHICH OF THE FOLLOWING CLASS IS USED TO READ INPUT FROM THE USER AT RUNNING TIME?

a)

output

b)

Scanner

c)

scan

d)

input

8.

which method is used to read integer from user?

a)

next()

b)

nextint()

c)

nextInt()

d)

Intnext()

9.

Which method is used for reading string value?

a)

nextchar()

b)

next()

c)

Next()

d)

nextString()

10.

Scanner class is available in which package?

a)

jaa.io

b)

java.lang

c)

java.util

d)

java.java