Short answerEasy2 marks
Classify the following as primitive or non-primitive data types: (i) char (ii) arrays (iii) int (iv) classes
Topic: Primitive and non-primitive data types
Previous-year question practice database
Answer
Exam answer
(i) char — primitive (ii) arrays — non-primitive (iii) int — primitive (iv) classes — non-primitive
Explanation
Java has exactly eight primitive types: byte, short, int, long, float, double, char and boolean. Everything else — arrays, classes, interfaces and String — is non-primitive, also called reference or composite. The distinguishing feature: a primitive holds a single value directly, while a non-primitive holds a reference to something that may contain many values. Remember that String is non-primitive despite how often it is used.
More from Revision Tour I
The full form of JVM is:2026Which of the following occupies 2 bytes of storage?2026In a statement c = c + (x * d + e); which variable is an accumulator?2026Assertion (A): The result of the Java expression 3 + 7/2 is 6.
Reason (R): According to the hierarchy of operators in Java, addition is done first followed by division.2026Evaluate the Java expression:
x = a * b % (++c) + (++a) + (--b);
if a = 7, b = 8, c = 22026System.out.println('Z' + 32); will display:2025