Intro to Computer Science
Basics
Conditionals
Loops
Methods
100

Solving a problem by breaking it down into multiple steps involving calculation

What is computational thinking?

100

Symbols that allow you to create complex expressions involving either numerical literals and/or numerical variables; negation (-), addition (+), subtraction (-), multiplication (*), division (/), remainder/modulus (%)

What are arithmetic operators?

100

operators that make comparisons between variables, constants, and even more complex expressions; they test for equality (==), inequality (!=), or relative value (<, >, <=, >=)

What are comparison operators?

100

Write a for loop that prints the numbers 2-10.

for(int i = 2; i <= 10; i++) { System.out.println(i); }

100

What does a method declaration require?

Return type, a name, and a list of parameters or empty set of parameters

200
The theory and application of computation to systematically and rigorously solve problems

What is computer science?

200

What is the Order of Precedence for the following operation: a. A + B / C + B * C

From left to right, Multiplication, Division, and Modulos go first, then Addition and Subtraction. Therefore the order is as follows:

1. / 

2. * 

3. - 

4. +  

200

operators that take one or two boolean variable(s) to make a new variable (&&, ||, !)

What are logical operators?

200

A keyword with a smaller interruption than break; it says "finish this iteration and move to the next one

What is continue?
200

passing values, not expressions; evaluating what's in the parentheses first, and passing that value to the method; a copy of the value is passed to the method being called

What is a pass-by-value?

300
A language that humans can write and computers can understand

What is a programming language?

300

An operation that explicitly indicates how we want a variable to be interpreted by converting the variable's type into another type using the syntax (type) variable

What is type casting?
300

avoiding unnecessary operations while evaluating a condition by ceasing evaluation once there is enough information to make a decision

What is short circuiting?

300

The continuation condition is checked at the end of the loop, rather than prior to its execution

What is a do-while loop?

300

What will happen when this method is called?

public void calculateSum(int a, int b) {

    return a + b;

}

Compilation error because the method signature specifies a void return type, yet it attempts to return a value

400
Solutions to problems written in languages that computers can understand

What is a program?

400

Operators that combine an arithmetic operator and an assignment operator into one (+=, -=, *=, /=, %=); aka compound assignment

What are augmented assignment operators?

400

Which of these statements are logically equivalent according to DeMorgan's Law?

  • !(p && (q || r))
  • !p || (!q && !r)
  • !(p || q) && !r
  • !p && (!q || !r)


!(p && (q || r))
!p || (!q && !r)

400

a variable only exists within the code block (e.g., a for loop)

What is block scope?

400

What is the difference between passing by value and passing by reference in Java? How does Java handle this for primitive data types and objects?

When you pass a primitive to a method, Java passes a copy of the value. Changes made to the parameter inside the method do not affect the original value. 

When you pass an object, Java still passes by value, but the value being passed is a reference (a copy of the reference to the object’s memory location).

500

Identifying abstract similarities across solutions to apply existing solutions to new problems

What is pattern recognition?

500

What would be printed from the following code snippet?

public static void main(String[] args) {

        String name = "Khalif";

        String word = "Hi!" + "My name is" + name + " and I have $" (50 + 3 * 2 - 8 / 4 + (10 % 3) * 4 - 2) + " in my bank account";

        System.out.println(word);

    }






Compilation error! There's no + in between $" and (50 +

500

Write a Java program that asks the user for an integer and checks the following conditions using if statements and the modulus operator %:

  1. If the number is divisible by both 3 and 5, print "FizzBuzz".
  2. If the number is only divisible by 3, print "Fizz".
  3. If the number is only divisible by 5, print "Buzz".
  4. If the number is not divisible by 3 or 5, print "Not divisible by 3 or 5".

import java.util.Scanner;

public class FizzBuzzChecker {

    public static void main(String[] args) {

        Scanner scanner = new  Scanner(System.in);

        System.out.print("Enter a number: ");

        int num = scanner.nextInt();


        if (num % 3 == 0 && num % 5 == 0) {

            System.out.println("FizzBuzz");

        } else if (num % 3 == 0) {

            System.out.println("Fizz");

        } else if (num % 5 == 0) {

            System.out.println("Buzz");

        } else {

            System.out.println("Not divisible by 3 or 5");

        }


        scanner.close();

    }

}


500

The value of count at the end of the code segment. 

int count = 0;

for(int x=0; x<20; x++){ 

      for(int y=1; y<=5; y++){ 

             count++; 

       }

}

System.out.println(count);

What is 100?

500

Write a program to find the factorial value of any number.

Ex: num = 5 

Factorial of 5 is 5*4*3*2*1 = 120

public static void main(String[] args)

    {

        Scanner input = new Scanner(System.in);

        System.out.print("Enter Factorial Number : ");

        int num = input.nextInt();

        int fact = 1;

        for(int i=1; i<=num; i++)

        {

            fact *= i;

        }        

        System.out.println("Factorial: "+ fact);        

    }

M
e
n
u