Search Header Logo

Unit 2 AP CSA Practice Quiz Part 1

Authored by Madelynn Andino

Other

9th - 12th Grade

Used 2+ times

Unit 2 AP CSA Practice Quiz Part 1
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

29 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

A teacher has created a Student class. The class contains the following.

  • An int variable called grade to represent the student’s grade level

    • A String variable called name to represent the student’s name

      • A double variable called average to represent the student’s grade point average

  • A method called updateAverage that updates the student’s average.

The object greg will be declared as type Student.

Which of the following descriptions is accurate?

greg is an instance of the Student class.


greg is an instance of three attributes.


greg is an instance of the updateAverage method.

Student is an instance of the greg object.

updateAverage is an instance of the Student class.

2.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Consider the following description of the Thing class which includes two constructors.

public Thing() – Constructs a Thing object that uses a default value to represent a color

public Thing(String setColor) – Constructs a Thing object that uses setColor to represent a color

Which of the following code segments, when appearing in a class other than Thing, will create an instance variable of a Thing object with a value of null ?


private Thing someThing = new Thing()

private Thing someThing;

private Thing someThing = new Thing("Green");

private Thing("Green");

3.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

A student has created a Book class. The class contains variables to represent the following.

An int variable called pages to represent the number of pages

  • A boolean variable called isHardcover to indicate whether or not the book is hardcove

  • The object story will be declared as type Book.

Which of the following descriptions is accurate?

An instance of the story class is Book.

An instance of the Book object is story.

An attribute of the story object is isHardcover.

An attribute of the Book instance is story.

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

Answer the following

An attribute of the penelope object is email.

An attribute of the mrsPatel object is studentName.

An attribute of the mrsPatel object is email.


An attribute of the penelope object is Parent.

5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

Answer the following

VetRecord(String name, int weight, int age)

VetRecord(String name, int age)

VetRecord(int age, boolean needsVac)

VetRecord(int age, int weight)

6.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Media Image

Answer the following


I only


II only


I and II only


II and III only

7.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

Answer the following


I only



II and III only

None of the code segments will compile.

II only

Answer explanation

Correct. Code segment I will not compile. To call a nonstatic method outside the MagicNumber class, a MagicNumber object must be created and the nonstatic method must be called using the dot operator on the object name. Code segment II will compile successfully, as it first creates an object of the class MagicNumber and then uses the dot operator to call nonstatic methods that manipulate an instance variable of that object. Code segment III will not compile because the variable n2 has not been properly declared and initialized.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?