OOP
Name That Data Structure!
Grammars/Regex
The Last Third
¯\_(ツ)_/¯
100

Is the following an example of overloading or overriding?

public class Test {

    public void add(int a, int b){
        return a+b;
    }

    public void add(int a, int b, int c) {
        return a+b+c;
    }
}

Overloading

100

With a fixed size and ordered elements, this data structure is very fast.

Array

100

<assignment> ::= <variable> = <literalInteger>;
<variable> ::= <letter>+
<literalInteger> ::= <digit>+
<letter> ::= <upperCaseLetter> | <lowerCaseLetter>
<lowerCaseLetter> ::= a | b | ... | z
<upperCaseLetter> ::= A | B | ... | Z
<digit> ::= 0 | 1 | ... | 9

Which of the following are valid for the above rules

A) Scanner Scanny = new Scanner(System.in);
B) integer = 123453.6
C) int inty = 2345
D) number = 31415926536

D

100

Given table [null, 1, 9, null, 11, 26, 13] and hash function h(k) = k % 7. Using single hashing, where does 4 get inserted?

Index 0

100

For a class to implement the Comparable<T> interface which method MUST you implement?

A) int compareTo(T other)
B) int compare(T object1, T object2)
C) int comparison(T object1, T object2)
D) int difference(T object1, T object2)

A

200

In this example does B have access to the member variable "myNum" in class A?

public class Test {    

    static class A{
        protected static int myNum = 5;
    }
    static class B{
        static String var = "hello";
        public void getA(){
            //CODE HERE
        }
    }
}

No

200

An element with high priority is served before an element with low priority in this data structure.

Priority Queue/Heap

200

Which of the following matches a all lowercase word followed by a - then another lowercase word followed by a - and 9 numbers?

(A) [a-z]*-[a-z]*-[0-9]{9}
(B) ([a-z]*-){2}[0-9]{9}
(C)[A-Z]*-[a-z]*-[0-9]{9}

A, B

200

Given hash table [null, 1, 35, null, 26, 5, 50, null, null, 31, 10], using hash functions h1(k) = k % 11, h2(k) = 13 - (k % 13) and double hashing, where is 24 inserted? where do collisions occur?

Collisions: 2, 4, 6

Insert: 8

200

This type of testing involves checking outputs with their expected values, without examining the code directly.

Black Box Testing

300

public class test {
    static class A {  }

    static class B extends A {
        void print() {
            System.out.println("B");
        }
    }

    static class C extends B {
        void print() {
            System.out.println("C");
        }

    public static void main(String[] agrs) {
            A a = new C();
            B b = new B();
            C c = new C();
            a.print()
            b.print();
            c.print();
        }
    }
}


What will this output?

Nothing - the code will not compile because class A does not have a print() method.

300

A data structure that can map keys to values, usually using a function to determine the index at which the key/value pair is placed.

Hash Map/Hash Table

300

Which of the following match the expression:([0-9]*.[A-Z]*)

874>ADG
324A
AA
AAAA
AAAAAAA
9hH
9-D
A----Z

All but A----Z

300

Run depth first search on the provided, undirected graph starting at Node A.

Priority is based on alphabetic order.

A C B E I G H J D F

300

How many calls to fib() are there of fib(4) given?

int fib(int n){
            if(n<=1){
                return n;
            }
            return fib(n-1)+fib(n-2);
        }

9

400

class Animal {}
class Mammal extends Animal {}
class Dog extends Mammal {}
class Turtle extends Animal {}

Which of the following will not throw an error?

(A) Animal a1 = new Turtle();
(B) Mammal a2 = new Dog();
(C) Dog a3 = new Animal();
(D) Mammal a4 = new Turtle();
(E) Turtle a5 = new Dog();

A, B

400

A _____ binary tree is a tree in which every node other than the leaves has two children.

A _____ binary tree is a tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. 

Full

Complete

400

Which one of the following best matched the data structure mm/dd/yyyy:

(A) ([0-1][0-9]\ /){2}[0-9]{4}
(B) ([0-1][0-9])\ /([0-3][0-9])\ /[0-9]{4}
(C) [0-9]{2}\ /[0-9]{2}\ /[0-9]{4}
(D) ([0-9]{2}\ /){2}[0-9]{4}

B
400

Run breadth first search on the provided, undirected graph starting at Node A.

Priority is based on alphabetic order.

A C D B E H F G I J

400

Convert the following infix expression to prefix(insert one space in between each operator and operand e.g. 5+4 would be + 5 4): 

(5/(4*7))%9

% / 5 * 4 7 9

500

The following is primarily an example of :

A) Inheritance
B) Abstraction
C) Encapsulation
D) Polymorphism

public class Test {        

    private int id;
    private String name;
    private int salary;
    public Test(int id, String name, int salary){
         this.id = id;
         this.name = name;
         this.salary = salary;
    }
    public int getId(){
        return id;
    }
    public String getName(){
        return name;
    }
    public int getSalary(){
        return salary;
    }
    public void setId(int newId){
        id = newId;
    }
    public void setName(String newName){
        name = newName;
    }
    public void setSalary(int newSalary){
        salary = newSalary
    }
}

C

500

This tree-based structure had both index nodes and data nodes. The data form a linked list and the index allow for O(log(n)) access of elements in the middle

B+ Tree
500

Which of the Following match the expression: ([-]*.[A-Z])*.*([A-Z])? 

A) ([-]*.[A-Z])*.*([A-Z])?
B) Hello there
C) General Kenobi
D) --------------------------
E) anything 

A, B, C, D, E

500

Which of the following are valid topological sorts on the provided DAG.

A) A C H J I G B E D F
B) A H J C I B E G D F
C) H J I A C G D F B E

C

500

What is the error in the following declaration of classes:

 

public class Car{
    int maxSpeed;
}
public class RaceCar{
    int raceNumber;
    int fastness;
}
public class LightningMcQueen extends Car, RaceCar {  
    String catchPhrase;
    public LightningMcQueen(){
        catchPhrase = "Ka-Chow!!!";
    }
}

Extending Multiple Classes