In object-oriented programming, which feature allows a subclass to provide a specific implementation of a method already defined in its superclass?
Programming Oop
Question · Easy
T-C-P vs U-D-P: the rap battle
Short
Which OOP principle is most directly violated when a class exposes its instance variables as public and allows external code to modify them freely?
A class Shape has a method area(). Classes Circle and Rectangle both inherit from Shape and define their own area() methods. Calling shape.area() executes the correct version at run-time based on the actual object type. This is an example of which concept?
Question · Medium
What is the relationship described when a class Car has-a Engine object as one of its fields?
An abstract class in Java contains at least one abstract method. Which statement about abstract classes is correct?
Which design principle states that subclass objects should be substitutable for objects of their superclass without altering program correctness?
Question · Hard
In a recursive algorithm, what is the purpose of the base case?
Recursion
Consider this Python function: fact(n): if n <= 1: return 1 return n * fact(n-1) What is fact(5)?
Why does deep recursion sometimes cause a stack overflow error?
Which of the following problems is most naturally expressed using recursion?
Which of the following is a defining feature of a stack data structure?
Data Structures Linear
Which abstract data type is most appropriate for modelling jobs arriving at a printer where the first job sent should be printed first?
In a singly linked list, what is the time complexity of inserting a new node at the head, given a pointer to the head?
Which statement about arrays compared with linked lists is correct?
A circular queue uses a fixed-size array of length n with front and rear indices. What condition is commonly used to indicate that the queue is full?
Stacks are typically used to implement which of the following?
In a binary search tree (BST) where every node's left subtree contains only smaller keys and right subtree only larger keys, what is the average-case time complexity of searching for a key?
Data Structures Nonlinear
Which property must an AVL tree satisfy at every node?
What is collision resolution by separate chaining in a hash table?
Which representation of a graph uses O(V + E) memory and is efficient when the graph is sparse?
Pre-order traversal of a binary tree visits nodes in which order?
Given a sorted array of 1,024 elements, the maximum number of comparisons that a standard binary search performs is closest to which value?
Searching
Which precondition must hold before binary search can be applied to a list?
What is the worst-case time complexity of linear search on an unsorted array of n elements?
What is the average-case time complexity of bubble sort?
Sorting
Which sorting algorithm uses a divide-and-conquer strategy by splitting the array into halves, recursively sorting each half, and then merging the two sorted halves?
Quicksort's worst-case time complexity is O(n²). Under which condition does this worst case typically arise with a naive pivot choice?
Which statement about insertion sort is correct?
Depth-first search (DFS) of a graph is typically implemented using which data structure (whether explicit or implicit via recursion)?
Traversal
Breadth-first search (BFS) finds the shortest path between two nodes when which condition holds?
In-order traversal of a binary search tree produces the keys in which order?
Which Big-O notation describes an algorithm whose run-time doubles every time the input size increases by one?
Complexity
Which of the following describes a constant-time, O(1), operation?
Which list of complexity classes is in correctly increasing order of growth for large n?
A Turing machine is a model of computation that consists of which essential components?
Theory Computation
The halting problem states which of the following?
Which language class can be recognised by a finite-state automaton (FSA)?
What does it mean for a problem to be computable?
Which language is context-free but not regular?
What is the denary (decimal) value of the unsigned 8-bit binary number 10110101?
Data Representation
What is the two's complement 8-bit representation of −5?
Convert the hexadecimal value 2F to denary.
In IEEE-style floating-point representation, what is meant by 'normalisation' of the mantissa?
Which statement about floating-point arithmetic is correct?
Which encoding represents each character as 1 to 4 bytes and is backwards compatible with ASCII for code points 0–127?
Bitmap and vector graphics differ in storage. Which statement is correct?
What is the effect of increasing the sampling rate when digitising an analogue audio signal, holding bit depth constant?
Loading more…