Inside the parentheses of the method
Parameter
Used to store whole numbers
int variables
The correct way to write a print statement that jumps to the next line after execution
System.out.println();
The main purpose of loops (think one general word)
Repetition
Using the same constructor to make different objects
Overloading
How to call a method outside the class (class = ClassName & method = methodName)
ClassName.methodName(arguments);
A true/false statement
boolean variables
The correct way to declare/initialize an int variable "numStudents" with a value of 15
int numStudents = 15;
The loop used when we know the number of times we want the statement to be executed
For loop
True/False: It is efficient to create an object of a class and use it outside the class
True
Class method that returns the square root of an int
Math.sqrt();
Keyword for a variable that cannot be accessed outside the class
private
Keyword to escape an infinite loop
break
Hiding implementation details of data structures and exposing only essential operations
Abstraction
public class Main {
static void myMethod() {
System.out.println("Hello World!");
}
public static void main(String[] args) {
myMethod();
}
}
What is the output of the shown code?
Hello World!
The default value for this variable is 0
Byte
The general notation for creating a new object (class = ClassName & object = objectName)
ClassName objectName = new ClassName(arguments);
What does the following code print?
for (int i = 2; i < 9; i++)
{
System.out.print(i + ", ");
}
2, 3, 4, 5, 6, 7, 8
Keyword that describes an object of the class
static
class Calculator {
public int add(int a, int b) {
return a + b;
}
public double add(double a, double b) {
return a + b;
}
}
What concept is being conveyed?
Polymorphism
Consider the following code segment:
int x = 2; int y = 7;
double result = y / (double) x; System.out.println(result);
What will be printed when this code is run?
3.5
The correct notation of the signature for the main method
public static void main (String[] args)
Consider the following loop, where n is some positive integer.
for (int i = 0; i < n; i += 2)
{
/* perform some action */
}
In terms of n, which Java expression represents the maximum number of times that /* perform some action */ could be executed?
(n + 1) / 2;
public class Main {
public ____ (){
System.out.println("Constructor called");
}
}
Complete the constructor (fill in the blank)
Main