Solving a problem by breaking it down into multiple steps involving calculation
What is computational thinking?
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?
operators that make comparisons between variables, constants, and even more complex expressions; they test for equality (==), inequality (!=), or relative value (<, >, <=, >=)
What are comparison operators?
Write a for loop that prints the numbers 2-10.
for(int i = 2; i <= 10; i++) { System.out.println(i); }
What does a method declaration require?
Return type, a name, and a list of parameters or empty set of parameters
What is computer science?
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. +
operators that take one or two boolean variable(s) to make a new variable (&&, ||, !)
What are logical operators?
A keyword with a smaller interruption than break; it says "finish this iteration and move to the next one
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?
What is a programming language?
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
avoiding unnecessary operations while evaluating a condition by ceasing evaluation once there is enough information to make a decision
What is short circuiting?
The continuation condition is checked at the end of the loop, rather than prior to its execution
What is a do-while loop?
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
What is a program?
Operators that combine an arithmetic operator and an assignment operator into one (+=, -=, *=, /=, %=); aka compound assignment
What are augmented assignment operators?
Which of these statements are logically equivalent according to DeMorgan's Law?
!(p && (q || r))
!p || (!q && !r)
a variable only exists within the code block (e.g., a for loop)
What is block scope?
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).
Identifying abstract similarities across solutions to apply existing solutions to new problems
What is pattern recognition?
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 +
Write a Java program that asks the user for an integer and checks the following conditions using if statements and the modulus operator %:
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();
}
}
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?
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);
}