Java Basic Program Structure MCQ Questions and Answers 1

Study and learn Java MCQ questions and answers on basic program structure and syntax. Attend job interviews easily with these MCQs.

Go through Java Basic Theory Notes on Program Structure before studying these questions.



1) Every statement in Java language should end with a?
A) Dot or Period
B) Comma
C) Semicolon
D) Colon
Answer [=]
Answer[=]
2) A function in C language is similar to what in Java language?
A) Method
B) Member
C) Variable
D) None of the above
Answer [=]
Answer[=]
3) All methods and variables in Java language are kept inside a?
A) File
B) Class or Interface
C) static method
D) main
Answer [=]
Answer[=]
4) What is the need to mention "static" before main method?
A) To call main method without creating an object of class
B) To make main method as class method common to all instances
C) Both A and B
D) None of the above
Answer [=]
Answer[=]
5) In standalone Java applications, which method is mandatory?
A) main method
B) show method
C) display method
D) print method
Answer [=]
Answer[=]
6) What is the use of Access modifier "pubic" in Java language?
A) To hide the main method from misuse
B) To call the main method outside of Class or Package by JVM
C) To protect main method
D) None of the above
Answer [=]
Answer[=]
7) Choose a Single Line Comment in Java Language below?
A)
//Some comments
B)
Some comments//
C)
/*Some comments*/
D)
*/Some comments/*
Answer [=]
Answer[=]


 

8) Choose a multiline comment in Java language below?
A)
/*comments are going
cars are moving*/
B)
*/comments are going
cars are moving/*
C)
//comments are going
cars are moving//
D) None of the above
Answer [=]
Answer[=]
9)
String args[] in main method are used for?
public static void main(String args[])
{
  //
}
A) Passing arguments at compile time
B) Passing arguments at run time
C) Counting number of words
D) Nothing
Answer [=]
Answer[=]
10) What is the default return type of a method in Java language?
A) void
B) int
C) short
D) None of the above
Answer [=]
Answer[=]
11) Name of a Class, Variable, Method or an Interface in Java language is called?
A) Argument
B) Value
C) Identifier
D) None of the above
Answer [=]
Answer[=]
12) A valid identifier in Java language may contain which characters?
A) 0-9
B) A-Z, a-z
C) $, _ (Underscore)
D) All the above
Answer [=]
Answer[=]
13) A valid Identifier or name in Java language can start with which character?
A) a-z, A-Z
B) $, _
C) 0-9
D) A and B
Answer [=]
Answer[=]
14) What are the valid White Spaces available in Java language?
A) Space
B) Enter
C) Tab
D) All the above
Answer [=]
Answer[=]


 

15) Choose a correct version of Java Documentation Comment?
A)
/*
comments
*/
B)
/**
comments
*/
C)
/*
comments
**/
D)
/**
comments
**/
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Try Some Java Books

Book Price
1. Java - The Complete Reference  Check Price
2. Core Java: An Integrated Approach, Black Book Check Price
3. Java All-in-One for Dummies Check Price
4. OCP Java SE 8: Programmer II Check Price
5. Programming with Java Check Price
6. Head First Java Check Price

We may get some affiliate commission for the above purchases.