
Exam 2 MC

Quiz
•
Computers
•
10th - 12th Grade
•
Medium
Adam Lueken
Used 11+ times
FREE Resource
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
Similar Resources on Wayground
10 questions
AppsLab_Q2

Quiz
•
10th Grade - Professi...
11 questions
Python Quiz

Quiz
•
12th Grade
10 questions
Программирование C#

Quiz
•
1st - 10th Grade
10 questions
LATIHAN 4

Quiz
•
10th Grade
15 questions
Python Arrays Quiz P7

Quiz
•
11th Grade
15 questions
Input Commands Quiz

Quiz
•
10th Grade
15 questions
Java Variables, Input and Output

Quiz
•
10th - 12th Grade
10 questions
Белгіленген сипаттары бар элементті іздеу

Quiz
•
9th - 12th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
20 questions
Analog vs Digital

Quiz
•
9th - 12th Grade
10 questions
CTEA Computer Vocab Terms #1

Quiz
•
12th Grade
10 questions
Exploring Cybersecurity Techniques and Threats

Interactive video
•
6th - 10th Grade
10 questions
Understanding the Internet and Data Transmission

Interactive video
•
7th - 12th Grade