This set of Object Oriented System Design Multiple Choice Questions & Answers (MCQs) focuses on “Lexical Issues”.
1. Which of these is a valid keyword in Java?
a) interface
b) string
c) float
d) unsigned
View Answer
Explanation: “String” and “Float” are class types in Java. “unsigned” is a keyword used in C/C++ but not in Java.
2. Which of these is a reserved word in Java Programming Language?
a) method
b) native
c) subclasses
d) reference
View Answer
Explanation: “native” is a valid keyword used to modify method declaration. The valid keyword used in Java language for subclassing is “extends” not subclasses.
3. How many reserved keywords are there in Java language?
a) 50
b) 52
c) 49
d) 45
View Answer
Explanation: As of Java 1.5 there are 50 keywords out of which 48 are used(const and goto keywords are unusable keywords).
4. Which of the following is a Literal Representation?
a) 100
b) ‘100’
c) Sample
d) None of the mentioned
View Answer
Explanation: A constant value in Java is created by using a ‘Literal Representation’ of it. Integer Literals are not enclosed in quotes where as String Literals are enclosed in quotes.
5. What are the types of comments defined by Java?
a) Single-line comment
b) Multi-line comment
c) Documentation comment
d) All of the mentioned
View Answer
Explanation: None.
6. Which of the following is readable by both Computer and Human?
a) Single-line comment
b) Multi-line comment
c) Documentation comment
d) All of the mentioned
View Answer
Explanation: Documentation comment is used to produce an HTML file that documents the given program.
7. Which of the following ‘Seperator’ is most commonly used in Java program?
a) Parenthesis
b) Braces
c) Comma
d) Semicolon
View Answer
Explanation: Semicolon is most commonly used in Java program, which terminates statements.
8. Which of the following is used to name class, method and variables?
a) Identifiers
b) Keywords
c) Both
d) None of the mentioned
View Answer
Explanation: Identifiers are used to name classes, methods and variables.
9. ‘Whitespace’ in Java language may be?
a) A space
b) A new line
c) A tab
d) All of the mentioned
View Answer
Explanation: None.
10. Which of the following is the output of the program?
class Test {
public static void main(String args[])
{
int num = 10;
System.out.println("The value of num is" +NUM);
}
}
a) Compilation error
b) Run time error
c) Exception
d) The value of num is 10
View Answer
Explanation: Java is case-sensitive. Identifier which is used to name variable and print are different.
Sanfoundry Global Education & Learning Series – Object Oriented System Design.
Here’s the list of Best Books in Object Oriented System Design.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]