WorksheetsDATA TYPES ,INPUT AND OUTPUT
Total questions: 25
Worksheet time: 16mins
What is the error in this code?
byte b=30;
b=b*30;
b can not contain value 30, limited by its range
b can not contain value 30.
* has converted b *30 into int which can not be converted by using byte without casting.
no error in this code
What is a Widening Type Conversion in Java?
Conversion of data from higher data type to lower data type
Conversion of data from any data type to any data type
Conversion of data from lower data type to higher data type
all the above
What is the result of a Narrowing type conversion?
Addition of data
Loss of data
Corruption of data
None of the above
What is the output of the below Java code snippet?
float a = 8.2/2;
System.out.println(a);
4.1
8.1
4
compile time error
A boolean literal in Java can be type casted to which data type?
byte
short
int
none of the above
Which among the following is not a primitive data type in Java?
char
byte
String
short
What is the default boolean literal assigned to a boolean variable in Java?
true
false
undefined
hello
hello world
hello arg[0]
runtime error
ASCII values of upper case alphabets ..i.e A-Z are
65-90
66-91
97-122
98-123
is it possible to type cast to boolean to int
possible
Not possible
In the main method syntax, args in an array of String type.
True
False
Can't Say
Can be true or false
A command-line argument in Java is a value passed at the time of ___ a program.
Compiling
Running
after the program terminates
Choose the correct way of receiving command-line arguments with in the main method in Java?
0
10
Compilation Error
5-5
150
100
50
10050
What package is a part of the wrapper class which is imported by default into all Java programs?
java.io
java.util
java.lang
all the above
93
93.52
93.00
number format error
Which Scanner class method is used to read integer value from the user?
next()
nextInteger()
nextInt()
readInt()
Which method does not store string value after space?
next()
nextLine()
nextString()
Which is the correct syntax to declare Scanner class object?
Scanner objectName= new Scanner(System.in);
Scanner objectName= new Scanner();
Scanner objectName= Scanner(System.in);
Scanner objectName= Scanner();
Consider the following object declaration statement Scanner objectName= new Scanner(System.in); What is System.in in this declaration?
passing variables from method
passing variables to the method
read input from keyboard
forward data from display (monitor) to keyboard
Which package should be imported to use Scanner class?
import java.util.*;
import java.util.System;
import java.util.Scanner;
import java.util.System.in;
the operation performed on three variables belongs to which classification
unary
binary
ternary
all the above
boolean b;
what are the supportable values for b in java
true
false
0
1
which of the following are valid primitive data types.
int
String
byte
boolean
Array
