Back to Dashboard

Java Programming

Complete Subject Question Bank

Subject Overview
Deep dive into core Java concepts, including Object-Oriented Programming (OOP), variables, conditional statements, arrays, constructors, and packages.
01 Introduction To Java#1

Using Java we can develop ___________________.

A
Desktop Application
B
Web Application
C
Both the options
D
None of these options

Correct answer: Both the options.

01 Introduction To Java#2

The main method in java should ___________.

A
take boolean[] as argument
B
be public static
C
return int
D
be private static

Correct answer: be public static.

01 Introduction To Java#3

The break statement cannot be present for _____________ construct.

A
do while
B
while
C
for
D
if

Correct answer: if.

01 Introduction To Java#4

A continue statement makes the execution jump to ______________.

A
the end of the loop
B
the first statement of the loop
C
the next iteration of the loop
D
the statement just after continue

Correct answer: the next iteration of the loop.

01 Introduction To Java#5

Identify the features of java.

A
Exception Handling
B
Multi threading
C
Direct Access to memory using pointers
D
Less security

Correct answer: Exception Handling.

01 Introduction To Java#6

a for loop, if the number of statements are greater than one, which of the following needs to be inserted at the beginning and the end of the loop?

A
Arrows<>
B
Square bracket [ ]
C
French curly braces{ }
D
Parenthesis

Correct answer: French curly braces{ }.

01 Introduction To Java#7

JRE comprises of ___________ and ___________.

A
JVM
B
tools
C
API
D
JDK

Correct answer: JVM; API.

01 Introduction To Java#8
Logic Block
1
What will be the output of the program? public class Sample { final static short a = 2; public static int b = 0; public static void main(String [] args) { for (int c=0; c < 4; c++) { switch (c) { case a: System.out.print("a "); default: System.out.print("default "); case a-1: System.out.print("a-1 "); break; case a-2: System.out.print("a-2 "); } } } }
A
a-2 a-1 a default a-1 default a-1
B
a-2 a-1 a default a-1
C
a-2 a-1 a default default
D
a default a-1

Correct answer: a-2 a-1 a default a-1 default a-1.

01 Introduction To Java#9

The ________________ statement causes the program execution to stop and JVM to shut down.

A
System.exit
B
break
C
return
D
exit

Correct answer: System.exit.

01 Introduction To Java#10

JVM is independent of OS

A
True
B
False

JVM abstracts the OS; Java bytecode runs on any JVM regardless of OS.

01 Introduction To Java#11

To compile, debug and execute a program written in java, _______________ is required.

A
JRE
B
JIT
C
JDK
D
JVM

Correct answer: JDK.

01 Introduction To Java#12

State true or false. Java is a structured programming language.

A
Java is a structured programming languag
B
TRUE
C
FALSE

Correct answer: Java is a structured programming languag.

01 Introduction To Java#13

Who is the father of Java?

A
James Gosling
B
Dennis Ritchie
C
Jim Gray
D
Donald Knuth

Correct answer: James Gosling.

01 Introduction To Java#14

What is Polymorphism?

A
ability to acquire the properties
B
blueprint for an object
C
ability to have many forms
D
hiding the properties

Correct answer: ability to have many forms.

01 Introduction To Java#15

How was Java initially named?

A
GreenTalk
B
Algol
C
The Oak
D
COBOL

Correct answer: The Oak.

01 Introduction To Java#16

Java is _____________________________.

A
Platform dependent
B
Platform independent

Correct answer: Platform independent.

01 Introduction To Java#17
Logic Block
1
What is the output of this program? 1. class Crivitch { 2. public static void main(String [] args) { 3. int x = 10; 4. 5. do { } while (x++ < y); 6. System.out.println(x); 7. } 8. } Which statement, inserted at line 4, produces the output 12?
A
int y=11;
B
int y=12;
C
int y=13;
D
int y=10;

Correct answer: int y=11;.

01 Introduction To Java#18
Logic Block
1
What will be the output of the program? Given: 10. int x = 0; 11. int y = 10; 12. do { 13. y--; 14. ++x; 15. } while (x < 5); 16. System.out.print(x + "," + y); What is the result?
A
6,5
B
5,5
C
5,6
D
6,6 x is assigned 0 and y, 10 initially. During each iteration x is incremented by 1 and y is decremented by 1. The iteration stops when x equals 5. At this stage y also would have reached the value 5. Hence the output 5 5.

Correct answer: 5,5.

01 Introduction To Java#19
Logic Block
1
What is the output of this program? class selection_statements { public static void main(String args[]) { int var1 = 5; int var2 = 6; if ((var2 = 1) == var1) System.out.print(var2); else System.out.print(++var2); } }
A
3
B
4
C
2
D
1 Observe the if construct. var 2 is assigned 1. 1 does not equal 5, hence else block will get execute

Correct answer: 2.

01 Introduction To Java#20
Logic Block
1
Fill in the appropriate data type for the Java switch statement: switch (____) { case value1: ... case value2: ... default: System.out.println("Hello"); }
A
byte
B
float
C
boolean
D
double

Java switch supports byte, short, char, int, their wrapper classes, enums, and String. Among the options, byte is valid.

Key Topics to Study

Based on our question bank analysis, master these concepts to score high in Java Programming.

JavaConstructorStringArraySwitchPackageEclipseCompilation
Recommended

Success Primer Exam

Test your knowledge under real exam conditions with our curated mock assessment.

Start Preparing for Primers
Watch Walkthroughs!