MCQ's but not really
Define define define
tSro -> Sort
Interfaces
Abstracts
100

If a, b, and c are integers, which of the following conditions is sufficient to guarantee that the expression a < c || a < b && !(a == c) evaluates to true?  

Form : p > q


a < c

100

Attributes or properties or instance variables; characteristics of an object; what the object knows; should be declared private on CS exam.

What are fields?

100

The sorting algorithm that involves finding the minimum (or maximum) element from the unsorted section and swapping it with the leftmost (or rightmost) unsorted element, progressively moving the boundary of the sorted section one element to the right.

What is Selection Sort?

100

This contains a list of abstract methods that need to be implemented by classes.

What is an Interface?

100

Which of the following is true about abstract classes?

A. Abstract classes cannot be instantiated, but they can be sub-classed.

B. Abstract classes can be instantiated, but they cannot be sub-classed.

C. Abstract classes can only contain abstract methods. They can be sub-classed.

D. Abstract classes can only contain abstract methods. They cannot be sub-classed. 

A. Abstract classes cannot be instantiated, but they can be sub-classed.

200

public static int mystery(int n) {
   if (n == 1)
      return 3;
   else
      return 3 * mystery(n - 1);
}
 What value does mystery(4) return?

81

200

A modifier that declares that the variable will be a constant.

What is final?

200

The sorting algorithm that builds the final sorted array (or list) one item at a time by removing one element from the input data, finding the location it belongs within the sorted list, and inserting it there, thus extending the sorted list one element at a time?

What is Insertion Sort?

200

Which of the following is true about interfaces?

I. Interfaces can only contain abstract methods or class constants.
II.  Interfaces can be extended.
III.  Interfaces can be instantiated (you can create an object of the interface type).

I and II

200

How many Abstract classes can a subclass extend?

How many Interfaces can a subclass implement?

1 extension. 

Unlimited Implementations.

300

DAILY DOUBLE #1

rise bow aria encore

300

This is a process of a method invoking itself.

What is recursion?

300

The sorting algorithm that divides the list, then pairs them together in a systematic manner to produce lists of sorted sequences which are then merged again, utilizing a divide-and-conquer approach to sort the elements efficiently

What is Merge Sort?

300

Consider the following declarations.
public interface Shape {
   int isLargerThan(Shape other);
 }
 public class Circle implements Shape {
   // Other methods not shown
 }
Which of the following method headings of isLargerThan can be added to the declaration of the Circle class so that it will satisfy the Shape interface? I. public int isLargerThan(Shape other)
II. public int isLargerThan(Circle other)
III. public boolean isLargerThan(Object other)

I Only.

300

We can’t instantiate an abstract class. Then why constructors are allowed in abstract class?

To set the fields of a subclass that extends a abstract class. 

400

10112 * 348 + 1E16 + 235

351

400

Methods that have the same name in the same class that have different parameters. The parameter order/number must be distinct from the other methods with the same name.

What is Overloading?

400

{1, 9, 5, 4, 2, 0, 4}

What would the set of numbers look like after four iterations of Insertion Sort?

{1, 4, 5, 9, 2, 0, 4}

400

How is an interface different from a class?
(3 of 4 required)

An interface can only have abstract methods, while a class can have both abstract and non-abstract methods.

An interface cannot have constructors, while a class can have constructors.

An interface cannot have instance variables, while a class can have instance variables.

An interface can be implemented by a class, while a class can only be extended by another class.

400

Which methods are acceptable in an Abstract class. (Choose all)

I. public abstract void sue();
II. public abstract void getName(){}
III. private abstract void helpWalk{}
IV. abstract String help();

I and IV

500

Consider the following method that will access a square matrix mat:
0 1 2 3
4 5 6 7
3 2 1 0
7 6 5 4
public static void printSomething(int[][] mat) {
   for (int r = 0; r < mat.length; r++) {
      for (int c=0; c<=r; c++)
         System.out.print(mat[r][c] + " ");
      System.out.println();
   }
}
 

0

4 5

3 2 1

7 6 5 4

500

Dynamic lists that store the same type of object. Cannot hold primitive types. Uses .size() and not .length. 

What are ArrayLists?

500

Suppose an int array contains the following values, in the order given: 36 48 37 7 19 29
Assuming descending order, determine the order of the array after 3 passes using the following sort algorithms...
Bubble Sort __ __ __ __ __ __  
Selection Sort __ __ __ __ __ __  
Insertion Sort __ __ __ __ __ __

Bubble: 7, 19, 29, 36, 37, 48
Selection: 7, 29, 19, 36, 37, 48 or 7, 19, 29, 36, 48, 37
Insertion:7, 36, 37, 48, 19, 29

500

Write an interface AnimalThings, with one method for drinking water and one field for the name of the zoo. 

public interface AnimalThings {

public static final String zoo = "Point Defiance";

public void drinkWater();

}

500

DAILY DOUBLE #2

C) It requires that any class that extends it must implement the makeSound method.