Unit 2 AP CSA Practice Quiz Part 1

Unit 2 AP CSA Practice Quiz Part 1

9th - 12th Grade

29 Qs

Similar activities

Introduction to Arduino

Introduction to Arduino

10th - 12th Grade

26 Qs

PARCC Review

PARCC Review

KG - University

25 Qs

Health & Safety CSCS

Health & Safety CSCS

1st Grade - Professional Development

25 Qs

ulangan pertama

ulangan pertama

10th Grade

30 Qs

Integrals

Integrals

12th Grade - University

34 Qs

WR Route Combos

WR Route Combos

12th Grade

24 Qs

Python conditionals Elidon Mema

Python conditionals Elidon Mema

10th - 12th Grade

30 Qs

C# Skill Review

C# Skill Review

12th Grade - Professional Development

32 Qs

Unit 2 AP CSA Practice Quiz Part 1

Unit 2 AP CSA Practice Quiz Part 1

Assessment

Quiz

Created by

Madelynn Andino

Other

9th - 12th Grade

2 plays

Medium

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.

8.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

Answer the following

Purchase.totalAmount();

p.totalAmount();

totalAmount(p);

System.out.print(p);

Answer explanation

Correct. The dot operator is needed to invoke a non-static method of a class on an object of that class. This code segment will correctly print the purchase amount associated with p.

9.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

Answer the following

printDog(AnimalPrinter);printCat(AnimalPrinter);

AnimalPrinter.printDog();

AnimalPrinter.printCat();


printDog(myPrinter);

printCat(myPrinter);

myPrinter.printDog();

myPrinter.printCat();

Answer explanation

Correct. To work correctly, the dot operator must be used to invoke a non-static method of a class on an object of that class. This code segment correctly invokes the myPrinter object's methods printDog() and printCat() and will produce the desired output.

10.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Media Image

Answer the following


14


50

Nothing is printed

40

Answer explanation

Correct. The value 4 is passed to methodA and stored in methodA’s parameter arg. This value is multiplied by 10. The result 40 is then passed to methodB and stored in methodB’s parameter arg. The value 10 is added to arg, and the result 50 is printed.

Explore all questions with a free account

or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?