Which of the following best describes Java's "Write Once, Run Anywhere"
philosophy?
a.It must be recompiled for every platform.
b.It runs on any device with a JVM.
c.It only runs on Windows.
d.It cannot be used on mobile devices.
Which feature does NOT characterize Java?
a.Object-Oriented
b.Manual Memory Management
c.Secure
d.Platform Independent
What was Java originally designed for?
a.Mobile Apps
b.Desktop Games
c.Interactive Television
d.Web Applications
Java was created by James Gosling at Sun Microsystems in 1995.
True
False
Java's primary strength lies in its ability to execute across multiple platforms
without modification.
True
False
What is a common reason to use GitHub?
a.To automatically debug the application
b.To speed up code execution
c.To run code faster on cloud platforms
d.To manage and store code revisions
In debugging, breakpoints are used to:
a.Fix the bug automatically
b.Stop the code execution at a specific point
c.Run the code faster
d.Skip over code
Which of the following features is most important when debugging Java ap-
plications in IntelliJ IDEA?
a.Breakpoints
b.Code formatting
c.Repository management
d.Version control
Debugging is only necessary when there is an error message in the applica-
tion.
True
False
Every code change in GitHub is immediately reflected in the main branch
without merging.
True
False
What will be printed as a result of executing the following code?
Random random = new Random();
int score = random.nextInt(101);
if (score >= 60) {
System.out.println("You have passed the exam!");
} else {
System.out.println("You have failed the exam.");
}
a.You have failed the exam.
b.You have passed the exam!
c.No output
d.Either "You have passed the exam!" or "You have failed the exam." de-
pending on the value of `score`
What is the value of `middleChar` after the following code executes, if the
input for `fullName` is "Marcus"?
String fullName = "Marcus";
int length = fullName.length();
char middleChar;
if (length % 2 == 0) {
middleChar = fullName.charAt(length / 2 - 1);
} else {
middleChar = fullName.charAt(length / 2);
}
System.out.println(middleChar);
a.a
b.u
c.r
d.c
What message will be displayed if the input temperature is `10`?
int temperature = 10;
switch (temperature) {
case 30:
System.out.println("The temperature is 30 degrees, it's hot!");
break;
case 20:
System.out.println("The temperature is 20 degrees, it's warm!");
break;
case 10:
System.out.println("The temperature is 10 degrees, it's cool!");
break;
case 0:
System.out.println("The temperature is 0 degrees, it's cold!");
break;
default:
if (temperature < 0) {
System.out.println("It's freezing!");
} else {
System.out.println("The temperature is " + temperature + " de-
grees.");
}
break;
}
a.The temperature is 10 degrees, it's cool!
b.The temperature is 0 degrees, it's cold!
c.The temperature is 20 degrees, it's warm!
d.It's freezing!
If the `score` is 85, what grade will be assigned in the following code?
int score = 85;
String grade;
if (score >= 90) {
grade = "A";
} else if (score >= 80) {
grade = "B";
} else if (score >= 70) {
grade = "C";
} else if (score >= 60) {
grade = "D";
} else {
grade = "F";
}
System.out.println("Your grade is: " + grade);
a.A
b.C
c.D
d.B
Given the following code snippet, what will be the output?
int a = 15;
int b = 4;
int result = a / b;
System.out.println(result);
a.3.75
b.4.0
c.3.8
d.3.0
An array in Java can change its size after being declared.
True
False
What is a characteristic of arrays in Java?
a.Arrays in Java are primitive data types.
b.The size of an array can be changed after it is created.
c.An array can store multiple types of values.
d.An array contains a fixed number of values of a single type.
What is the purpose of the `continue` statement in a loop?
a.It terminates the entire program.
b.It exits the loop immediately.
c.It skips the current iteration and continues with the next iteration of the
loop.
d.It restarts the loop from the beginning.
A jagged array in Java allows each row to have a different number of ele-
ments.
True
False
In Java, an `if` statement can be nested inside another `if` statement.
True
False
Which is the only access modifier which can be used upon inheritance in
Java?
a.private
b.protected
c.public
d.None of the above
If the member of the subclass has an identical identifier as a member of the
superclass (e.g. int id), how can the identifier of the subclass be accessed
from within the superclass?
a.id
b.this.id
c.super.id
d.This cannot be accomplished
What is NOT true for abstract classes?
a.They can be instantiated
b.They can contain constructors
c.They can be inherited from
d.All of the above is true
What is the minimum number of abstract methods in a class, so that it MUST
be declared as abstract?
a.One
b.Two
c.None
d.More than two
Which of the following can be abstract?
a.A static member
b.A data member
c.A constructor
d.A method
What is the default value of the elements of an array in Java of type int?
a. Null
b. 1
c. Not initialized
d. 0
It is possible to overload operators in Java.
False
True
The break keyword is used to exit a loop in Java.
a. True
b. False
Java supports pointers.
a. True
b. False
What does method overloading in Java refer to ?
a. Methods that perform the same function in different classes
b. None of the above
c. Methods of the same name but different parameters
d. Different methods that share the same return type
Java is compiled language
True
False
Java platform is independent
True
False
We can create object of abstract class
True
False
Object class is root class of all java classes
True
False
The for loop can create infinite loop
True
False
Java supports multiple inheritence
True
False
Java is case sensitive language
True
False
Which of these is not a type of constructor in Java?
a. Local Constructor
b. Default Constructor
c. Copy Constructor
d. No-Argument Constructor
What does bytecode in Java refer to?
a. None of the above
b. Machine code
c. Source code
d. Intermediate code
Constructors can be overriden
True
False
Method overloading is supported
True
False
Can we simulate multiple inheritance in Java?
A. Yes, using interface
B. No
C. Yes
D. Yes, using abstract class
Inheritance is a violation of encapsulation inheritance is a violation of encap-
sulation
True
False
The continue keyword is used to skip the current itertion loop
True
False
We can overload method by different return types
True
False
Who created Java?
a.Guido van Rossum
b.Bjarne Stroustrup
c.Dennis Ritchie
d.James Gosling
Which security feature is unique to Java?
a.Built-in firewall
b.Supports HTTPS
c.SSL Encryption
d.Sandbox model for applets
Java includes direct support for pointers similar to the C programming lan-
guage.
True
False
Java applications can directly interact with hardware without any intermedi-
ary layers.
True
False
When debugging in IntelliJ IDEA, breakpoints stop the code execution to in-
spect the current state.
True
False
GitHub repositories are used to store and manage code changes over time.
True
False
Which of the following is NOT a fundamental part of GitHub?
a.Issues
b.Breakpoints
c.Repositories
d.Pull Requests
Which of the following best describes an `if-else` statement in Java?
a.It assigns a value to a variable based on a condition.
b.It tests multiple conditions, each with its own code block.
c.It allows the execution of different code blocks based on a condition.
d.It repeatedly executes a block of code while a condition is true.
Java is a strongly typed language, meaning every variable and expression
has its type known at compile time.
True
False
Given the following code snippet, what will be the output?
int a = 15;
int b = 4;
int result = a / b;
System.out.println(result);
a.3.8
b.3.0
c.3.75
d.4.0
What will be printed as a result of executing the following code?
Random random = new Random();
int score = random.nextInt(101);
if (score >= 60) {
System.out.println("You have passed the exam!");
} else {
System.out.println("You have failed the exam.");
}
a.No output
b.You have passed the exam!
c.Either "You have passed the exam!" or "You have failed the exam." de-
pending on the value of `score`
d.You have failed the exam
Which keyword is used to access the parent class constructor?
a.extends
b.this
c.super
d.None of the above
Java supports multiple inheritance.
a.True
b.False