Hello World
Decisions Decisions
Feelin' Loopy
OOPs I did it again
Code for your life
100

Because Java uses both compilation and interpretation it is considered a _____ language

Hybrid

100

To continue an existing branching statement, I can use this to add an additional logical expression.

else if

100

This type of loop is often considered a "post-check" loop.

do-while

100

When dealing with multiple classes, the java main method must exist in the ____ class

Main, Primary, Top-most.

100

output the constant PI, formatted to 3 decimal places.

System.out.printf("%.3f", Math.PI);

200

This type of error occurs most frequently when the syntax is correct, but you create an illegal operation. Such as attempting to enter a string for Scanner's nextInt() method.

Runtime error

200
A switch uses the "fall down" decision structure, which requires a ____ in order to prevent multiple case output.

break

200
What type of looping structure is often considered controversial?

Infinite loop

while(true)

200

List the 4 fundamentals of Object Oriented Programming

Encapsulation, Inheritance, Abstraction, Polymorphism

200

Create a method that returns the sum of 2 given parameters.

public int Add(int a, int b){

return a+b;

}

300

To call any method in java, you are required to use

Parenthesis

300

A decision structure "flag" is often a single variable of what datatype?

Boolean

300

This keyword skips sections of loop code to move on to a new iteration of the same loop.

continue

300

These methods have the same name as another existing method, but different parameters.

Overloaded methods.

300

Debug the following loop-

do[

System.out.println("Main Menu: ");

System.out.println("1. Buy Something")

System.in.println("2. Sell Something "):

System.out.printline("3. Trade Something ");

System.out.println("4. Exit "):

]while(not count == 5);

do - needs curly brackets

missing semicolons on some lines.

System.out.println (not .in, or printline)

the "not" keyword does not exist in java. count != 5

400

What class/package do I need to import in order to create Times and Dates in code?

java.time.LocalDate

java.time.LocalDateTime

400

what is the output of the following switch pseudocode?

letterGrade = C

switch(letterGrade){

     case A

                output "excellent work"

      case B

                 output "decent job"

                 break

      case C

               output "passable"

      case D

                output "needs improvement"

                break

       default

               output failed    

}


passable

needs improvement

400

To validate user input with a while loop, the Scanner class has these type of methods to assist.

hasNext-X()

400

What kind of methods belong to a class itself, rather than an instance of the class?

Static methods.

400

Write a java code snippet that validates user input to be a positive integer.

Scanner scan = new Scanner(System.in);

int num;

while (!scan.hasNextInt() || (num = scan.nextInt()) <= 0){

//output invalid

if(!scan.hasNextInt()){

    scan.next();

}

}


500

Explain the purpose of the Java Virtual Machine (JVM)

It is the environment that surrounds all java programs. A java program cannot be executed without the JVM.

500

This method of branching uses the '?' operator and as times is a replacement for an if/else.

Ternary

500

What is the output of the following loop?

String text = "burger king";

for(int x = 0; x < text.length(); x++){

     if(x % 2 == 0){

         System.out.print(text.charAt(x));

     }

}

bre  ig

500

A(n) ____ is an instance of a class that bundles together data. A good example would be a String, whereas primitive datatypes are not an example.

An object.

500

Create an encapsulated class of your choice. With at least 1 method.

Create the object for the class and call its method in your main java program.

class calculator{

     private int a;

     private int b;

      public calculator(int a, int b){

            this.a = a;

            this.b = b;

       }


       public int add(){

            return a+b;

       }

}


//main method call

calculator c = new calculator(2,3);

System.out.println(c.add());