Data Types & Variables

1.Which of the following is not a primitive data type in Java?
  • A. int
  • B. float
  • C. String
  • D. boolean

String

String

2. What is the default value of an int variable in Java?
  • A. 0
  • B. null
  • C. 1
  • D. Undefined

0

0

3.What is the size of a char in Java?
  • A. 1 byte
  • B. 2 bytes
  • C. 4 bytes
  • D. 8 bytes

2 bytes

2 bytes

4.Which of the following data types has the largest memory size?
  • A. int
  • B. long
  • C. float
  • D. double

double

double

5.What will be the output of the following code?
public class Main { public static void main(String[] args) { byte b = 127; b++; System.out.println(b); } }
  • A. 127
  • B. 128
  • C. -128
  • D. Compilation error

-128

-128