AP CSA Unit 2: Lesson 5 Questions

0.0(0)
studied byStudied by 6 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

flashcard set

Earn XP

Last updated 7:59 PM on 9/25/22
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards
Consider the following code segment:
String word = new String("question");
What does this code segment do?
Declares and initializes an object of the String class.
2
New cards
Consider the following code example:
Scanner scan = new Scanner(System.in);
Which of the following sentences best describes the features in this code segment?
Variable scan points to an object, Scanner is the class of this object.
3
New cards
Which of the following is a class in Java?
String
4
New cards
What keyword do we use to tell Java to set aside memory to create an object?
new
5
New cards
Which of these code segments shows a constructor being used to create a new object?
RegularPolygon p = new RegularPolygon(2, 2.5);
6
New cards
Which of the following creates a rectangle with length and width equal to 2.0?
Rectangle r = new Rectangle(2.0);
Rectangle r = new Rectangle(2.0, 2.0);
7
New cards
Which of the following will be printed by the following code?
RegularPolygon shape = new RegularPolygon(5.0);System.out.println(shape);
equilateral triangle with side length 5.0
8
New cards
Which of the following statements about overloaded constructors is true?
Constructors for a class can be overloaded but they must all have a different number of parameters, different order of parameters or different types of parameters.
9
New cards
Which of the following best describes what happens when the code segment below is run?
RegularPolygon p = new RegularPolygon();
System.out.println(p);
"equilateral triangle with side length 1.0" is printed
10
New cards
Which of the following best describes what happens when the code segment below is run?
RegularPolygon p = new RegularPolygon(5.5);
System.out.println(p);
"equilateral triangle with side length 5.5" is printed