Object Oriented System Design Questions and Answers – Lexical Issues

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

Answer: a
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

Answer: b
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

Answer: a
Explanation: As of Java 1.5 there are 50 keywords out of which 48 are used(const and goto keywords are unusable keywords).
advertisement
advertisement

4. Which of the following is a Literal Representation?
a) 100
b) ‘100’
c) Sample
d) None of the mentioned
View Answer

Answer: a
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

Answer: d
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

Answer: c
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

Answer: d
Explanation: Semicolon is most commonly used in Java program, which terminates statements.
advertisement

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

Answer: a
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

Answer: d
Explanation: None.
advertisement

10. Which of the following is the output of the program?

  1. class Test {
  2.     public static void main(String args[]) 
  3.     {
  4.         int num = 10;
  5.         System.out.println("The value of num is" +NUM);
  6.     }
  7. }

a) Compilation error
b) Run time error
c) Exception
d) The value of num is 10
View Answer

Answer: a
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.

To practice all areas of Objection Oriented System Design, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.