AP Comp Sci - Unit 2 Review (2.1 - 2.7)

AP Comp Sci - Unit 2 Review (2.1 - 2.7)

12th Grade - Professional Development

8 Qs

quiz-placeholder

Similar activities

Bài 3: Kiểu dữ liệu 1

Bài 3: Kiểu dữ liệu 1

12th Grade

10 Qs

Python Boolean and If

Python Boolean and If

9th - 12th Grade

10 Qs

Типы данных Python2

Типы данных Python2

6th Grade - University

12 Qs

Ordre supérieur 1

Ordre supérieur 1

University

11 Qs

Chapter 2 Python

Chapter 2 Python

8th Grade - University

13 Qs

Advance Python

Advance Python

KG - Professional Development

10 Qs

CODE-P4

CODE-P4

Professional Development

10 Qs

CR1-Introducción a la Programación con Python

CR1-Introducción a la Programación con Python

University

10 Qs

AP Comp Sci - Unit 2 Review (2.1 - 2.7)

AP Comp Sci - Unit 2 Review (2.1 - 2.7)

Assessment

Quiz

Computers

12th Grade - Professional Development

Hard

Created by

Steven Gall

Used 33+ times

FREE Resource

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 5 pts

String oldStr = "ABCDEF";

String newStr = oldStr.substring(1, 3) + oldStr.substring(4);

System.out.println(newStr);

What is printed as a result of executing the code segment?

ABCD

BCDE

BCEF

BCDEF

ABCDEF

2.

MULTIPLE CHOICE QUESTION

1 min • 5 pts

Consider the following method.

public double myMethod(int a, boolean b)

{  /* implementation not shown */  }

Which of the following lines of code, if located in a method in the same class as myMethod, will compile without error?

int result = myMethod(2, false);

int result = myMethod(2.5, true);

double result = myMethod(0, false);

double result = myMethod(true, 10);

double result = myMethod(2.5, true);

3.

MULTIPLE CHOICE QUESTION

2 mins • 5 pts

String temp = "comp";

System.out.print(temp.substring(0) + " " +

temp.substring(1) + " " +

temp.substring(2) + " " +

temp.substring(3));

What is printed when the code segment is executed?

comp

c o m p

comp com co c

comp omp mp p

comp comp comp comp

4.

MULTIPLE CHOICE QUESTION

2 mins • 5 pts

String str = "0";

str += str + 0 + 8;

System.out.println(str);

What is printed as a result of executing the code segment?

8

08

008

0008

Nothing is printed, because numerical values cannot be added to a String object.

5.

MULTIPLE CHOICE QUESTION

2 mins • 5 pts

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

* A String variable called color to represent the color of the car

* An int variable called year to represent the year the car was made

* A String variable called make to represent the manufacturer of the car

* A String variable called model to represent the model of the car

* The object vehicle will be declared as type Car.

Which of the following descriptions is accurate?

An instance of the vehicle class is Car.

An instance of the Car object is vehicle.

An attribute of the year object is int.

An attribute of the vehicle object is color.

An attribute of the Car instance is vehicle.

6.

MULTIPLE CHOICE QUESTION

3 mins • 5 pts

Consider the following class.

public class WindTurbine

{

private double efficiencyRating;

public WindTurbine()

{

efficiencyRating = 0.0;

}

public WindTurbine(double e)

{

efficiencyRating = e;

}

}

Which of the following code segments, when placed in a method in a class other than WindTurbine, will construct a WindTurbine object wt with an efficiencyRating of 0.25 ?

WindTurbine wt = new WindTurbine(0.25);

WindTurbine wt = 0.25;

WindTurbine wt = new WindTurbine();

wt = 0.25;

WindTurbine wt = new WindTurbine();

wt.efficiencyRating = 0.25;

new WindTurbine wt = 0.25;

7.

MULTIPLE CHOICE QUESTION

3 mins • 5 pts

ExamScore class. (see Google Slide)

4

5

80

84

85

8.

MULTIPLE CHOICE QUESTION

3 mins • 5 pts

GameClass error (see Google Slide)

IV only

I and III only

I and IV only

II and IV only

II, III, and IV only