What is concatenation? How is it different from the + operator? When does it know to do + and when does it concatenation?
To merge together two Strings or variables for an output. The + operator does actual arthritic addition. It knows once it encounters a String, it considers the rest of the expression as a String
What are the three looping statements?
Do,Do-while,for loops
What are the four branching statements?
if, else, else-if, switch
What is the method to take an integer from the user?
.nextInt();
What is a boolean?
True/False
Give an example of a declared constant that is an integer
public static final int DAYS_IN_WEEK = 7;
When would you use a for loop?
When you know how many times you would want to run the loop for
What happens if you forget the break in a switch statement?
It will continue doing every case until the code finds a break in the switch statement.
What does the .length() method return?
the number of characters in a String
int num = 0;
boolean condition = false;
if(num == 0){
condition = true;
}
System.out.print(condition);
true
What type of coding language is Java?
High-level object oriented programming
What will happen if the Boolean condition is never true in a loop?
Infinite loop
What does System.exit(0); do?
exits current program/stops running the code
What does .substring(start index, end index) do? What happens if you just have a start index in the parameters?Which index is inclusive and which index is exclusive?
returns a new string that is a sub string of given string. If you just have the start index in the parameters, then it will create a new string from the start index to the end of the string. The start index is inclusive and the end index is exclusive.
What is the output of the following code?
int num = 0;
boolean condition = false;
if(num != 0){
condition = true;
}
System.out.print(condition);
false
What is the file extension for Java source code? What is the file extension for Java byte code?
.java / .class
What does it mean if a loop is post-test? What loop is a post-test loop?
It means it runs the code once, then checks if the if the Boolean statement is true. A do-while is a post test loop
What type of condition do you need when you're trying to use a branching?
a Boolean condition
What is the method we need to invoke to read a string from the user?
.nextLine();
What packages do you have to import to use the Scanner and RandomGenerator? What package do you need to import to use Decimal Format?
java.util.Scanner;
java.text.DecimalFormat;
What is the header for your main method?
public static void main(String[] args) {
What type of variable is i in this for loop, (int i = 0; i>10;i++)
Local variable
What is the output of the following code?
for (int n= 1; n<= 3; n++) {
switch(n){
case 1:
System.out.println("First");
case 2:
System.out.println("Second");
break;
case 3:
System.out.println("Third");
break;
default:
System.out.println("Default Case");
}
}
}
}
First
Second
Second
Third
What is the method that will check for equality of two Strings, while ignoreing if there is differences in the casing?
.equalsIgnoreCase()
What are the symbols that match with these boolean operators?:
AND, OR , EQUALS, NOT , NOT EQUALS
&&, || , == , ! , !=