Test Series - java

Test Number 8/64

Q: What are the types of Literals available in Java language?
A. Integer and Float
B. Character and String
C. Boolean
D. All the above
Solution: Literals are Data assigned to Primitive data type variables.
Q: What are the types of Integer Literals in Java?
A. Decimal Literals
B. Octal and Hexadecimal Literals
C. Binary Literals
D. All the above
Solution: JDK 7 introduced binary literals to easily set individual bits of a number.
Q: An Octal number is Java is represented with a leading ____?
A. O (Alphabet)
B. 0 (ZERO)
C. 0x
D. 0X
Solution: Eg. int a=0765;
Q: Choose correct ranges for Decimal, Octal and Hexadecimal numbers in Java?
A. Decimal: 0 to 9
B. Octal: 0 to 7
C. Hexadecimal: 0 to 9 and A to F / a to f
D. All the above
Solution: no solution
Q: Choose the correct example of Octal Literal in Java?
A. short = 0564;
B. int = 076__45_2;
C. int = 0______11;
D. All the above
Solution: int = 0______11; // 8^1 * 1 + 8^0 * 1 = 9
Q: What is the prefix used to represent Hexadecimal numbers in Java?
A.  0x
B. 0X
C. A and B
D. None of the above
Solution: int a=0xFEB5;
int b=0X9876__45;
Q: Choose correct examples of Hexadecimal literals in Java?
A. long a = 0X987654321L;
B. int a = 0x76FE____23;
C. byte b = 0X0__________F;
D. All the above
Solution: no solution
Q: Binary literals in Java are introduced with which version of Java?
A. JDK 5
B. JDK 7
C. JDK 6
D. JDK 8
Solution: no solution

You Have Score    /8