Exam 2 MC

Exam 2 MC

10th - 12th Grade

10 Qs

quiz-placeholder

Similar activities

Cuestionario Steve Jobs

Cuestionario Steve Jobs

12th Grade - University

10 Qs

Sistema Operativo Android

Sistema Operativo Android

9th - 12th Grade

10 Qs

BAI 9 LOP 5

BAI 9 LOP 5

12th Grade

8 Qs

Types of Mass Media

Types of Mass Media

10th Grade - Professional Development

11 Qs

Common Protocols

Common Protocols

10th - 12th Grade

15 Qs

UH Bab 3 XII 3

UH Bab 3 XII 3

12th Grade

10 Qs

10 câu kiểu xâu tiết 1

10 câu kiểu xâu tiết 1

11th Grade

10 Qs

LENGUAJE C

LENGUAJE C

11th Grade

13 Qs

Exam 2 MC

Exam 2 MC

Assessment

Quiz

Computers

10th - 12th Grade

Practice Problem

Medium

Created by

Adam Lueken

Used 11+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Consider the Animal, Fish, and Goldfish classes shown below. Which of the following object declarations will compile without error?

public class Animal

{

/* no constructors or other methods have been declared */

}


public class Fish extends Animal

{

/* no constructors or other methods have been declared */

}


public class Goldfish extends Fish

{

/* no constructors or other methods have been declared */

}


I. Goldfish glub = new Fish();


II. Animal glub = new Fish();


III. Fish glub = new Goldfish();

(A) I only

(B) II only

(C) III only

(D) I and II only

(E) II and III only

2.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Assume that list has been instantiated as an ArrayList of integers containing [6, 2, 9] . What are the contents of list after the code is executed?

list.remove(2);

list.add(1, 4);

list.add(5);

list.set(2, 7);

(A) [6, 2, 7, 5]

(B) [6, 4, 2, 7, 5]

(C) [4, 7, 9, 5]

(D) [6, 4, 7, 5]

(E) [4, 7, 6, 9, 5]

3.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

A sorted array of integers containing 2000 elements is to be searched for key using a binary search method. Assuming key is in the array, what is the maximum number of iterations needed to find key?

(A) 8

(B) 10

(C) 100

(D) 2000

(E) 11

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Which of the following code segments creates a 7 x 9 array of integers and fills every space in the array with multiples of two (not including the value 0)?

I. int[][] arr = new int [7][9];


II. int[][] arr = new int [7][9];

int count = 1;


for(int i = 0; i < arr.length; i++)

{

for(int j = 0; j < arr[0].length; j++)

{

arr[i][j] = count * 2;

count++;

}

}


III. int[][] arr = new int [7][9];

int count = 1;

int row = 0;

int col = 0;


while (row < arr.length && col < arr[0].length)

{

arr[row][col] = count * 2;

row++;

col++;

count++;

}

(A) I only

(B) II only

(C) II and III only

(D) I and II only

(E) III only

5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Consider the method printString shown below. What is printed as a result of printString(“sandwich”)?

public void printString(String s)

{

if (s.length() > 0)

{

printString(s.substring(1));

System.out.print(s.substring(0, 1));

}

}

(A) hciwdnas

(B) sandwich

(C) andwichandwichndwichdwichwichichchh

(D) hchichwichdwichndwichandwich

(E) Nothing is printed because an infinite loop occurs

6.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

The Dog class is shown below. The GoldenRetriever class inherits from the Dog class. Which methods and variables does the GoldenRetriever class inherit?

public class Dog

{

private int numLegs = 4;

private String name = "Spot";


public Dog(String theName)

{

/* implementation not shown */

}


public String bark()

{

return "Woof!";

}


public String getName()

{

return name;

}


public int getNumLegs()

{

return numLegs;

}

}


I. public Dog(String theName)


II. bark()


III. getName()


IV. private String name;

(A) I only

(B) I and II only

(C) III only

(D) II and III only

(E) I, II, III, and IV

7.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Which of these loops will output 02468?

I. for (int i = 0; i <= 8; i++)

{

System.out.print(i);

}


II. int i = 0;

while (i < 8)

{

i +=2;

System.out.print(i);

}


III. for (int i = 0; i <= 8; i +=2)

{

System.out.print(i);

}

(A) I only

(B) II only

(C) III only

(D) I and II only

(E) I, II, and III

Create a free account and access millions of resources

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?

Discover more resources for Computers