AP CSA Unit 2: Lesson 5 Questions

studied byStudied by 6 people
0.0(0)
Get a hint
Hint

Consider the following code segment: String word = new String("question"); What does this code segment do?

1 / 9

flashcard set

Earn XP

Description and Tags

10 Terms

1

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.

New cards
2

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.

New cards
3

Which of the following is a class in Java?

String

New cards
4

What keyword do we use to tell Java to set aside memory to create an object?

new

New cards
5

Which of these code segments shows a constructor being used to create a new object?

RegularPolygon p = new RegularPolygon(2, 2.5);

New cards
6

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);

New cards
7

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

New cards
8

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.

New cards
9

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

New cards
10

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

New cards

Explore top notes

note Note
studied byStudied by 23 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 41 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 11 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 46 people
Updated ... ago
4.0 Stars(1)
note Note
studied byStudied by 91 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 26 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 30060 people
Updated ... ago
4.4 Stars(24)

Explore top flashcards

flashcards Flashcard36 terms
studied byStudied by 9 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard117 terms
studied byStudied by 66 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard27 terms
studied byStudied by 16 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard103 terms
studied byStudied by 16 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard47 terms
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard29 terms
studied byStudied by 15 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard46 terms
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard40 terms
studied byStudied by 65 people
Updated ... ago
5.0 Stars(1)