Types & Variables
Math & Operators
String Methods
Methods & Signatures
Objects & Constructors
100

What are the 3 primitive data types required for this unit?

Ints, doubles, booleans

100

What is the result of 17 % 5?

2

100

Given String s = "Computer";, what value is returned by s.length()?

8

100

What two components make up a method signature in Java?

Method name and parameter list. Ex: calculateSum(int a, double b);

100

What keyword is used to instantiate a new object using a constructor?

new

200

What is the result of: 

System.out.println("Result: " + 5 + 3);

Result: 53

200

What is printed by System.out.println(7 / 2);?

3

200

Given String s = "JAVA";, what happens when you attempt to execute s.substring(4) vs s.substring(5)?

Empty string. IndexOutOfBounds

| J | A | V | A | 

0   1   2    3    4

200

What keyword in a method header indicates that the method does not return any value?

Void

200

How do you recognize a constructor header inside a class definition?

It's the same name as the class.

300

What does a variable declared as a String store?

Reference or pointer

300

What is the value of x after int x = 10; x %= 4; x *= 3 ?

6

300

What does s.indexOf("cat") return if the substring "cat" is not found inside s?

-1

300

What term describes having multiple methods in the same class with the same name but different parameter lists?

Overload

300

Given String str = "AP CSA";, what does str.substring(1, 4) return?

P C

400

What error occurs at runtime if you attempt to call a method on an object set to null?

NullPointerExceptionError

400

Write a single expression using Math.random() that generates a random integer between 5 and 15 inclusive.

(int) (Math.random() * (15 - 5 + 1)) + 5

400

String word = "APCSA";

word.concat(" Rocks");

System.out.println(word);

What is printed?

APCSA

Need to reassign! word = word.concat(" Rocks");

400

Java passes arguments to methods using "Call by Value". What does this mean when passing a primitive variable into a method?


The method receives a copy of that variable's value, not the actual variable itself.

400

What is the comparison method for Strings?

str.equals();

500

How many bits is an integer and double?

32 and 64

500

What does Math.pow(2, 3) return? State the exact value and its data type.

8.0, double

500

Given String word1 = "apple"; and String word2 = "banana";, what does word1.compareTo(word2)return (positive, negative, or zero)?


Negative.

500

What is the key structural difference between calling a static class method versus an instance method?

Wether or not the method requires an object instance to execute. 

Static: Class.method();

Instance: object.method();

500

What does it mean for String objects to be immutable? Explain how Strings work in memory.

Once it is created in memory, its value can never be changed or modified. When a new value is assigned, it creates a new variable in memory.

M
e
n
u