Q: How many primitive data types are there in Java?
A.6
B.7
C.8
D.9
Correct Option: CExplanation: 8
Q: What is the output for the below code?
public class Test{
int _$;
int $7;
int do;
public static void main(String argv[]){
Test test = new Test();
test.$7=7;
test.do=9;
System.out.println(test.$7);
System.out.println(test.do);
System.out.println(test._$);
}
}
A.7 9 0
B.Compile error - $7 is not valid identifier.
C.7 0 0
D.Compile error - do is not valid identifier.
Correct Option: DExplanation: Compile error - do is not valid identifier.
Q: Which of the following is not a primitive data type?
A.int
B.short
C.byte
D.enum
Correct Option: DExplanation: enum
Q: Compiler never assigns a default value to an uninitialized local variable in Java Programming !!
A.True Statement
B.False Statement
Correct Option: AExplanation: True Statement
Q: What will the output of the following program?
public class Test{
public static void main(String args[]){
float f = (1 / 4) * 10;
int i = Math.round(f);
System.out.println(i);
}
}
A.2
B.0
C.3
D. 2.5
Correct Option: BExplanation: 0
Q: Which of the following is data type stores longest ______________ floating point number.
A.double
B.long
C.boolean
D.float
Correct Option: AExplanation: double
Q: is used to construct the __________ .
public Boolean (boolean value)
A.None of these
B.Boolean Object
C.Floating Object
D.Integer Object
Correct Option: BExplanation: Boolean Object
Q: What will be the output for the below code ?
1. public class Test{
2. public static void main(String[] args){
3. byte i = 128;
4. System.out.println(i);
5. }
6. }
A.128
B.0
C. Compilation fails with an error at line 3
D.None of these
Correct Option: CExplanation: Compilation fails with an error at line 3
Q: Integer Data type does not include following primitive data type ____________.
A.double
B.long
C.short
D.byte
Correct Option: AExplanation: Integers includes byte, short, int, and long
Q: What would be the output of the following fraction of code?