Given this set of questions and answers, 
What is the name of the method to print out text in Java?

A: System.out.println()
B: System.out.printline()
C: System.output()
D: System.out.PRINTLN()
A: System.out.println()

Start of 2.16.1 Basic Java



What is the output of the following lines?
int x = 24;
System.out.println("The total is " + x + x);

A: The total is 24
B: The total is 2424
C: The total is 48
D: The total is x + x
B: The total is 2424



Which of the following is not a primitive type?

A: int
B: double
C: String
D: boolean
E: char
C: String



What is the value of x after this code?

int x = 5; x = 10; x = 4;

A: 5
B: 10
C: 4
D: true
C: 4



What is the proper syntax to initialize a double called temperature to have the value 70.4?

A: int temperature = 70.4;
B: double temperature = 70.4;
C: temperature = 70.4;
D: float temperature = 70.4;
B: double temperature = 70.4;



What is the result of this expression?

5 + 2 / 3 + 1

A: 5
B: 6
C: 6.67
D: 0
B: 6



Which expression returns the 1's place of an integer x?

A: x % 10
B: x / 10
C: x % 100
D: x + 1
A: x % 10



What is the value of myInteger after this line of code?
int myInteger = (int) 5.6;

A: 6
B: 5.5
C: 5
D: 9
C: 5



Which expression is true?

A: true && !true
B: !false || !true
C: true && false
D: false || false || !true
B: !false || !true



Which of these is not a logical operator?

A: &&
B: !
C: ||
D: ++
D: ++



What is the output of this for loop?
for(int i = 0; i < 100; i += 2)
{
System.out.println(i);
}
A: The even numbers from 0 to 98, inclusive
B: The even numbers from 0 to 100, inclusive
C: All of the numbers from 0 to 100
D: The odd numbers from 0 to 98, inclusive
A: The even numbers from 0 to 98, inclusive



What is the output of this for loop?
for(int i = 10; i > 2; i -= 3)
{
System.out.println(i);
}
A:
10
7
4

B:
10
7
4
1

C:
1
2
3

D:
10
8
6
4
2
A:
10
7
4



How many times will the loop execute?
int i = 0;
while(i < 50)
{
System.out.println(i);
i += 10;
}
A: 0
B: 4
C: 5
D: 50
C: 5



What will this code output?
if(true && true && false)
{
System.out.println("Hello Karel");
}
if(true && 4 == 2 + 2)
{
System.out.println("Second if statement!");
}

A: Hello Karel

B: Hello Karel
Second if statement!

C: This program will print nothing

D: Second if statement!
D: Second if statement!



What will this program print if the value of grade is 80?
if(grade > 90)
{
System.out.println("A");
}
else if(grade > 80)
{
System.out.println("B");
}
else if(grade > 70)
{
System.out.println("C");
}

A: A
B: B
C: C
Nothing
C is what the program will print.



What output will be produced by
System.out.println("Hello");
System.out.println("Karel");

A: Hello Karel
B: HelloKarel
C: Hello
Karel
D: Error
C: Hello
Karel



What will the values of x and y be after this code segment runs?
int x = 100;
int y = 100;
if (x <= 100)
{
if (y > 100)
{
x = 200;
}
else
{
x = 99;
}
}
else
{
x++;
}
y = x + y;


x = 100
y = 200

x = 101
y = 100


x = 101
y = 201

x = 99
y = 199
D: x = 99
y = 199



What will the code segment output?
for (int m = 5; m > 0; m--)
{
for(int n = m; n > 0; n--)
{
System.out.print("*");
}
System.out.println();
}
A:
*
**
***
****
*****
B:
*****
****
***
**
*
C:
*****
*****
*****
*****
*****
D:
***************
B: *****
****
***
**
*



Refer to the following code segment:

double myDouble = 1/4;
System.out.println("1 / 4 = " + myDouble);
The output of the code is:
1 / 4 = 0.0
The student wanted the output to be:
1 / 4 = 0.25

Which change to the first line of their code segment would get the student the answer that they wanted?

A: int myDouble = 1/4;
B: double myDouble = (double) 1/4;
C: double myDouble = (int) 1/4;
D: double myDouble = (int) (1.0/4.0);
B: double myDouble = (double) 1/4;



What is the result of this expression?
4 + 8 * 3 / 4 + 5 % 2

A: 5
B: 6
C: 12
D: 11
D: 11



Question: 21
Which of these is not a valid Java method name?

A: runInCircles
B: jumpHurdle
C: find tower
D: finishMaze
C: find tower



Question: 22
Which of these is not a valid Java method name?

A: spin10Times
B: 10TimesMove
C: moveTenTimes
D: spinTenTmes
B: 10TimesMove



Question: 23

Which of these characters can a Java method name start with?
(I) Letters
(II) Numbers
(III) Underscore
(IV) $ Sign

I only
I and II
II only
I and III
I, III, and IV
I, III, and IV



Question: 24
What in this code segment could potentially cause a bug in our program?
String myString = readLine("What is your name?");
if (myString == "Karel")
{
System.out.println("Hi Karel!");
}
else
{
System.out.println("You're not Karel!");
}

A: Syntax error in the if statement
B: Nothing
C: Trying to store a Line in a String variable.
D: Comparing Strings with == instead of the .equals method.
D: Comparing Strings with == instead of the .equals method.



Question: 25
What is the output of this program?
int sum = 1;
System.out.println("Welcome to the adding machine!");
while(sum < 10)
{
sum += sum;
System.out.println(sum);
}
A:
Welcome to the adding machine!
1
2
4
8
16

B:
Welcome to the adding machine!
2
4
8
16

C:
Welcome to the adding machine!
2
4
8

D:
This code has an infinite loop.
B: Welcome to the adding machine!
2
4
8
16


End of 2.16.1 Basic Java quiz



What are parameters?

A: The value that a method returns.
B: The values that a method prints to the screen.
C: The formal names given to the data that gets passed into a method.
D: The type that is given to a variable.
C: The formal names given to the data that gets passed into a method.

Start of 3.9.1 AP Java Unit 3 quiz



What is a method?

A: A procedure that is defined by the user.
B: A keyword used to loop for a fixed amount of time.
C: A place where we can store data.
D: The type that is given to a variable.
A: A procedure that is defined by the user.



What is a Javadoc?

A: The reference guide to Java that is in the back of a textbook.
B: A program that cures the bugs in your Java program.
C: Data that gets passed into a method
D: A comment that clearly states the functionality and usage of a class or method.
D: A comment that clearly states the functionality and usage of a class or method.



What is a return value?

A: The value that a method prints to the screen.
B: The value that is inputted to a method.
C: The value that a user inputs to a program.
D: The value that a method outputs.
D: The value that a method outputs.



What does void mean?

A: Void means that a method returns any value.
B: Void means that a method takes no parameters.
C: Void means that a method returns no value.
D: Void means that a method can take any parameter.
C: Void means that a method returns no value.



What does this method call output?
public double doubleOrNothing(double myDouble)
{
return (double) (int) myDouble * 2;
}
doubleOrNothing(9.9);

A: 20
B: 18.8
C: 18.0
D: This method is improperly written.
C: 18.0



What does this method call return?
public int doubleInt(int x)
{
x * 2;
}
doubleInt(5);

A: 10
B: 5
C: This method returns nothing.
D: This method is improperly written.
D: This method is improperly written.



What will the value of yourBankAccount be after the method call?
int yourBankAccount = 0;
public void depositMoney(int bankAccount, int deposit)
{
bankAccount += deposit;
}
depositMoney(yourBankAccount, 1000000);

A: 1000000
B: 0
C: 100000
D: The code will error.
B: 0



Write a method that will ask for user input until user inputs the String "no". Allow the user to input any capitalization of the String "no" ("no", "No", "NO", "nO") Also, have the method return the number of loops.
Use readLine to get the user input.



A:
public int loopTillNo()
{
int count = 0;
while(!readLine("Again?").equals("no"))
{
count++;
}
return count;
}



B:
public int loopTillNo()
{
int count = 0;
while(readLine("Again?").toLowerCase().equals("no"))
{
count++;
}
return count;
}



C:
public int loopTillNo()
{
int count = 0;
while(readLine("Again?").equals("no"))
{
count++;
}
return count;
}


D:
public int loopTillNo()
{
int count = 0;
while(!readLine("Again?").toLowerCase().equals("no"))
{
count++;
}
return count;
}
D:
public int loopTillNo()
{
int count = 0;
while(!readLine("Again?").toLowerCase().equals("no"))
{
count++;
}
return count;
}



What will this method call print?
public void patternGrid(int rows, int columns, char symbol)
{
for(int m = 0; m < rows; m++)
{
for(int n = 0; n < columns; n++)
{
System.out.print(symbol);
}
System.out.println();
}
}
patternGrid(3,4,'#');

A:
####
####
####


B;
###
###
###


C:
####
####
####
####


D;
This code will error.
A:
####
####
####



What would this method call output?
public int myMethod(int num)
{
while(num / 10 >= 10)
{
num /= 10;
}
return num;
}
myMethod(830)

A: 830
B: 30
C: 0
D: 8
E: 83
E: 83



What is the return value of this method call?
public static String someWhereInTheMiddle(int number)
{
String stringNum = "" + number;
int middle = stringNum.length()/2;
if(stringNum.length() % 2 == 1)
{
return stringNum.substring(middle,middle+1);
}
else
{
return stringNum.substring(middle-1,middle+1);
}
}

someWhereInTheMiddle(188603)

A: 8
B: 6
C: 7
D: 86
D: 86



What is returned by this method call: translator("pokemon")?
public String translator(String word)
{
return word.substring(1) + word.charAt(0) + "ay";
}

A: "pokemonpay"
B: "okemonpay"
C: "okemonay"
D: This method call will error.
B: "okemonpay"



What will this method call output?
public int myMethod(boolean x, boolean y)
{
if(!x)
{
if(y)
{
return 1;
}
else
{
return 0;
}
}
else
{
return -1;
}
}
myMethod(false,false)

A: 1
B: 0
C: -1
D: This method call will error.
B: 0



Question: 15
What could the method signature for a Karel command look like?

A:
public void move()
{
//some code
}




B:
public String move()
{
//some code
}




C:
public int move()
{
//some code
}




D:
public boolean move()
{
//some code
}
A:
public void move()
{
//some code
}



What will this method call print to the screen?
public static void someMethod(int a, String b, int c)
{
System.out.println(b + " " + a + ", " + c);
}
someMethod(9,"Mar", 1250)

A: 9 Mar 1250
B: Mar 9 1250
C: 9, Mar 1250
D: Mar 9, 1250
D: Mar 9, 1250



Write a method that loops forever until the user inputs the correct secret password or until the user fails to enter the correct password 10 times. The secret password the program should look for is the String "secret"
Use readLine(String prompt) for user input

A:
public void secretPassword()
{
int count = 1;
while(true)
{
if(count == 10)
{
System.out.println("You are locked out!");
return;
}
if(readLine("Password?").equals("secret"))
{
System.out.println("Welcome!");
return;
}
count++;
}
}





B:
public void secretPassword()
{
int count = 0;
while(true)
{
if(count == 10)
{
System.out.println("You are locked out!");
}
if(readLine("Password?").equals("secret"))
{
System.out.println("Welcome!");
}
count++;
}
}







C:
public void secretPassword()
{
int count = 0;
while(true)
{
if(count == 10)
{
System.out.println("You are locked out!");
return;
}
if(readLine("Password?").equals("secret"))
{
System.out.println("Welcome!");
return;
}
count++;
}
}






D:
public void secretPassword()
{
int count = 0;
while(true)
{
if(count != 10)
{
System.out.println("You are locked out!");
return;
}
if(!readLine("Password?").equals("secret"))
{
System.out.println("Welcome!");
return;
}
count++;
}
}
C:
public void secretPassword()
{
int count = 0;
while(true)
{
if(count == 10)
{
System.out.println("You are locked out!");
return;
}
if(readLine("Password?").equals("secret"))
{
System.out.println("Welcome!");
return;
}
count++;
}
}



What will this method call output?
public String yesOrNo(boolean myBoolean)
{
if(myBoolean == true)
{
return "Yes";
}
else
{
return "No";
}
}
yesOrNo(true)

A:"No"
B: "Yes"
C: 0
D: This program will error
B: "Yes"



What will this method call output?
public boolean someMethod(int number)
{
if(number % 2 == 0)
{
return true;
}
else
{
return false;
}
}
someMethod(9990)

A: false
B: 0
C: "true"
D: true
D: true



What will this method call output?
public int mysterymethod(String x, char y)
{
int z = 1;
for(int i = 0; i < x.length(); i++)
{
if(x.charAt(i) == y)
{
z++;
}
}
return z;
}
mysteryMethod("Karel The Dog", 'e');

A: 1
B: 2
C: 3
D: 4
C: 3



Question: 21
What is wrong with this method definition?
public String outputString(String input)
{
System.out.println(input);
}

A: The method should not be public
B: Improper return value
C: Improper variable names
D: All of the above
B: Improper return value



What kind of error does this method cause?
public void buggyMethod(String x)
{
for(int i = 0; i <= x.length(); i++)
{
System.out.println(x.substring(i, i+1));
}
}
buggyMethod("BUG");

A: Compile Time Error: Unexpected return value
B: Runtime Error: String index out of range
C: Compile Time Error: Missing return value
D: Compile Time Error: Syntax Error in method definition
B: Runtime Error: String index out of range



What will this method call print to the screen?
public void numberMadness(double myDouble)
{
int myInt = (int) myDouble;
String myString = "";
while(myInt != 0)
{
myString = myInt % 10 + myString;
myInt /= 10;
}
System.out.println(myString);
}
numberMadness(12345)

A: 12345
B: 54321
C: 123
D: 543

Answer :  A: 12345



Why do we use methods in Java?

A: To make code easier to understand
B: To avoid repeated code
C: To simplify code
D: All of the above

Answer :  D: All of the above



What does this method call output?
public int trickyMethod(int x, int y)
{
int sum = 0;
while (x <= 10)
{
sum += x % y;
x++;
y++;
}
return sum;
}
trickyMethod(3,1)

A: 9
B: 10
C: 11
D: 12

Answer : D: 12

End of 3.9.1 AP Java Unit 3




I need you to generate a quiz involving all 50 terms. Please rearaange the question orders, as well as the answer order. For example,   the choices will be arragned like: d c b a rather than a b c d.