Short answerModerate2 marks
Identify and name the following tokens: (i) public (ii) 'a' (iii) == (iv) { }
Topic: Java tokens
Previous-year question practice database
Answer
Exam answer
(i) Keyword (ii) Literal (a character literal) (iii) Operator (a relational operator) (iv) Separator (punctuator)
Explanation
A token is the smallest meaningful unit of a program. Java has five kinds, and this question walks through four of them: Keywords - reserved words with a fixed meaning (public, class, void, static) Identifiers - names given by the programmer (variable and class names) Literals - fixed values written in the code (25, 'a', "text", true) Operators - symbols that perform operations (+, ==, &&) Separators - punctuation that groups or ends code ({ } ( ) ; ,) Naming the sub-type, as in "relational operator", earns no extra mark but does no harm.
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