Back to marketplace

Module 02: Using Objects

No description yet. This curated deck is ready for daily study.

Total cards: 24•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (24)

#1
Front (Question)

What are parameters? • The value that a method returns. • The formal values that a method prints to the screen. • The formal names given to the data that gets passed into a method. • The type that is given to a variable.

Back (Answer)

• The formal names given to the data that gets passed into a method

#2
Front (Question)

A procedure that is defined by the user is called a • method. • keyword. • variable. • variable type.

Back (Answer)

• method

#3
Front (Question)

The value that a non-void method outputs is called • a print statement. • an argument. • a parameter. • a return value.

Back (Answer)

• a return value

#4
Front (Question)

What is true of a void method? • It returns any value. • It takes no parameters. • It returns no value. • It can take any parameter.

Back (Answer)

• It returns no value

#5
Front (Question)

What does this method call doubleNumber(7.8); return, given the following method? • public double doubleNumber(double myNumber)* • {* • return (double) (int) myNumber * 2;* • }*

Back (Answer)

14.0

#6
Front (Question)

What does the method call tripleString(“APCSA”); return for the following method? • public String tripleString(String x)* • {* • return x * 3;* • }* • APCSAAPCSAAPCSA • APCSA APCSA APCSA • APCSA3 • This method is improperly written. • APCSA 3

Back (Answer)

• This method is improperly written

#7
Front (Question)

What will the value of myBankAccount be after the method call depositMoney(myBankAccount, 572);? • int myBankAccount = 122;* • public void depositMoney(int bankAccount, int deposit)* • {* • bankAccount += deposit;* • }*

Back (Answer)

122

#8
Front (Question)

What is returned by this method call: translator(“pokemon”)? • public String translator(String word)* • {* • return word.substring(1) + word.substring(0,1) + “ay”;* • }* • “pokemonpay” • “okemonpay” • “okemonay” • This method call will error.

Back (Answer)

• “okemonpay”

#9
Front (Question)

What will this method call print to the screen? • public static void formatText(int a, int b, String c)* • {* • System.out.println(b + “ “ + c + “, “ + a);* • }* formatText(2018, 17, “Dec”) • Dec 17, 2018 • Dec 17 2018 • 17 Dec 2018 • 17 Dec, 2018

Back (Answer)

• 17 Dec, 2018

#10
Front (Question)

What is wrong with this method definition? • public int printPayAmount(int amount)* • {* • System.out.println(amount);* • }* • This method should be private • Nothing is returned from this method • This is a String type method • The method is never called

Back (Answer)

• Nothing is returned from this method

#11
Front (Question)

Why do we use methods in Java? I. To make code easier to understand II. To define global variables III. To avoid repeated code IV. To simplify code V. To avoid needing to define them as public or private • I - V all • III, IV, and V • I, II, III, and IV • I, III, and IV

Back (Answer)

• I, III, and IV

#12
Front (Question)

A coffee shop has created a DrinkOrder class. The class contains variables to represent the following: • A String variable called name to represent the name of the drink. • An int variable called ounces to indicate how many ounces the drink should be. • A boolean variable called isIced to indicate whether the drink is iced. An object latte has been declared as type DrinkOrder after someone has ordered a Latte. Which of the following descriptions is accurate? • An instance of latte is DrinkOrder. • An attribute of latte is DrinkOrder. • An attribute of name is latte. • An instance of the DrinkOrder class is latte. • An attribute of DrinkOrder is latte.

Back (Answer)

• An instance of the DrinkOrder class is latte

#13
Front (Question)

After the execution of the following lines of code, what will be output onto the console? String letters = “ABCde”; String name = “Karel the Dog”; String letter = “D”; System.out.println(name.indexOf(letter)); System.out.println(letters.indexOf(name.substring(3,4))); System.out.println(letters.indexOf(letter));

Back (Answer)

10 4 -1

#14
Front (Question)

Consider the following class: • public class Coin* • {* • private String name;* • private double value;* • public Coin(String theName, double theValue)* • {* • name = theName; value = theValue;* • }* • public double getValue()* • {* • return value;* • }* • }* Assume that a Coin object quarter has been properly declared and initialized. Which of the following code snippets will successfully assign the value of quarter to a new variable coinWorth? • quarter.getValue(); • double coinWorth = quarter.getValue(); • int coinWorth = quarter.getValue(); • double coinWorth = quarter;

Back (Answer)

• double coinWorth = quarter.getValue();

#15
Front (Question)

Consider the following class: Which of the following is NOT a possible header for a new constructor for the Insect class? • Insect(String theName, int legNumber) • Insect(String theName, int legNumber, boolean isExoskeleton) • Insect(String theName) • Insect()

Card front image
Back (Answer)

• Insect(String theName, int legNumber, boolean isExoskeleton)

#16
Front (Question)

Which of the following code segments would successfully square the minimum value between two int variables x, y? • Math.pow(Math.min(x, y), 2); • Math.min(Math.pow(x, y)); • Math.pow(Math.min(x, y)); • Math.pow(2, Math.min(x, y));

Back (Answer)

• Math.pow(Math.min(x, y), 2);

#17
Front (Question)

Consider the following class: public class Dog { private String name; private String breed; public String getName() { return name; } } An object Karel is created using the Dog class. What would the result of the command System.out.println(Karel.getName()); be? • This code would result in an error, as name has yet to be initialized. • This code would result in an error, as there is no constructor present in the Dog class. • ” “ • null • false

Back (Answer)

• null

#18
Front (Question)

Consider the following method: • public double doubleVal(double x)* • {* • return x *2;* • }* The following code segment calls the method doubleVal: • Double val = 6.5;* • System.out.println(doubleVal(val));* What is printed when the code segment is executed?

Back (Answer)

13.0

#19
Front (Question)

Which of the following can be used to replace /*Code to be implemented */ so that the code segment produces a random number between 1-100? • return Math.random() * 100; • return Math.random() * 100 + 1; • return (int) (Math.random() * 100); • return (int) (Math.random() * 100 +1); • return (int) (Math.random() * 101);

Card front image
Back (Answer)

• return (int) (Math.random() * 100 +1);

#20
Front (Question)

Consider the following class: What would the output be of the following code segment: RandomCalculator calc = new RandomCalculator(4, 5); System.out.println(calc.add(5.0)); System.out.println(calc.add(5.0, 5)); System.out.println(calc.add(5, 5.0));

Card front image
Back (Answer)

5 9 11.0

#21
Front (Question)

Consider the following code segment: • String str = “I am”;* • str += 10 + 3; String age = “years old”;* • System.out.println(str + age);* What is printed as a result of executing the code segment? • I am103years old • I am 13 years old • I am13years old • I am 103 years old • years oldI am 13

Back (Answer)

• I am13years old

#22
Front (Question)

Which of the following code segments would correctly assign word from the String sentence = “Grab the last word” to the variable lastWord? • I. String lastWord = sentence.substring(sentence.length()-4, sentence.length());* • II. String lastWord = sentence.substring(sentence.indexOf(“w”), sentence.indexOf(“d”));* • III. String lastWord = sentence.substring(14, 16) + sentence.substring(1, 2) + sentence.substring(sentence.length()-1, sentence.length());* I only III only I and II only I and III only I, II, & III

Back (Answer)

I and III only

#23
Front (Question)

Consider the following class:

Back (Answer)

#24
Front (Question)

What is the difference between a primitive type and a reference type?

Back (Answer)

Card back image