1/80
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Which programming paradigm is characterised by a step-by-step approach to execution?
Procedural paradigm
The paradigm that breaks down a system into discrete objects is known as _____.
Object-Oriented Programming (OOP)
Term: Declarative paradigm
Definition: A programming paradigm that expresses the logic of a computation without describing its control flow.
What is the primary purpose of 'abstraction' in Object-Oriented Programming?
To hide implementation details from the user.
The process of hiding data inside a class so it is inaccessible from the outside is called _____.
Encapsulation
Concept: Inheritance
Definition: The mechanism by which objects of a class acquire the properties and behaviours of that class.
How is 'polymorphism' defined in the context of OOP?
The ability of an entity to take on more than one form.
Where are local variables declared in a Java programme?
Within methods, constructors, or blocks.
What is the visibility range of a local variable in Java?
It is only visible within the method, constructor, or block where it was declared.
True or False: Local variables in Java can use access modifiers.
FALSE
Where are instance variables declared within a Java class?
Inside the class but outside any method, constructor, or block.
At what point is a Java instance variable created?
When an object of the class is created.
What is the visibility of instance variables within their own class?
They are visible to all methods, constructors, and blocks within that class.
How many copies of an instance variable exist in a programme with multiple objects of the same class?
Every instance (object) has its own unique copy of the variable.
Which keyword is required to declare a class variable in Java?
static
How many copies of a static/class variable exist per class?
Only one copy exists per class, regardless of how many objects are instantiated.
What is the main restriction regarding the instantiation of an 'abstract' class?
It cannot be instantiated.
What types of methods can be contained within an abstract class?
Both abstract and non-abstract methods.
What is the defining characteristic of a 'final' class regarding inheritance?
It cannot be inherited by any other class.
From where can a 'public' access modifier be reached?
From anywhere within the application.
What is the scope of a 'private' access modifier in Java?
Only within the class in which it is declared.
Which locations have access to 'protected' members in Java?
The same package and subclasses located in different packages.
What is the scope of 'default' access in Java when no modifier is specified?
Only classes within the same package.
How does 'method overloading' differ from 'method overriding' regarding parameters?
Overloading uses the same method name with different parameters.
Under what condition does 'method overriding' occur?
When a subclass provides a method with the same name and type signature as one in its superclass.
Identify one of the three types of methods that cannot be overridden in Java.
Final methods (or static methods, or private methods).
What are the two requirements for a constructor's name and return type?
It must have the same name as the class and no return type (not even void).
What data can a static method access directly?
Only static data.
Which two keywords are prohibited from being used inside a static method?
this and super
True or False: Static methods can be overloaded.
TRUE
What is the effect of applying the 'final' keyword to a variable?
The value of the variable cannot be modified.
state the differences between instance, class/static and local variables in java
instance variables: declared in a class but outside of any block or method. they belong to an instance or object and each time a new object is created a new copy is made.
class/static variables: declared inside a class outside any method but with static keyword. they belong to the class itself not any specific object, so there is only one copy shared by all instances of that class.
local variables: declared inside a method, a constructor, or a block of code. belong specifically to the block theyâre declared in.
Concept: Multi-level inheritance
Definition: A type of inheritance where a class is derived from another derived class.
Concept: Hierarchical inheritance
Definition: A type of inheritance where one superclass is inherited by multiple subclasses.
How does Java handle the lack of support for multiple inheritance between classes?
It uses interfaces to allow a class to implement multiple behaviours.
What is the rule regarding a class inheriting from itself in Java?
A class cannot inherit from itself.
Are constructors inherited by subclasses in Java?
No, but they can be invoked from the subclass.
What is the order of execution for constructors in an inheritance hierarchy?
They are called in order of derivation, from superclass to subclass.
Which keyword is used to call a superclass constructor from a subclass?
super
When does 'static polymorphism' occur, and what mechanism does it use?
It occurs at compile time and uses method overloading.
When does 'dynamic polymorphism' occur, and what mechanism does it use?
It occurs at runtime and uses method overriding.
What is the definition of an 'exception' in Java?
A runtime error.
What are the two components of a Java interface?
Abstract methods and static constants.
True or False: A Java interface can be instantiated.
FALSE
what OOP concept allows a class to implement multiple interfaces in java?
polymorphism
Concept: Instruction space
Definition: The space required to store the compiled version of the programme instructions.
What is 'data space' in the context of space complexity?
The space needed to store all constants, variables, arrays, and class instances.
In time complexity analysis, what is the assumed time cost for a single Assignment Operation?
$1$ arbitrary time unit.
In time complexity analysis, what is the assumed time cost for a single Arithmetic Operation?
$1$ arbitrary time unit.
In time complexity analysis, what is the assumed time cost for a Function Return?
$1$ arbitrary time unit.
How is the running time of a selection statement (if/switch) calculated?
Condition evaluation time plus the maximum running time of the individual clauses.
How is the running time of a single loop determined?
The running time of the statements inside multiplied by the number of iterations.
What is the total running time of a statement inside a group of nested loops?
The statement's running time multiplied by the product of the sizes of all loops.
What is the recommended directional approach for analysing nested loops?
Inside out.
When calculating loop complexity, how many iterations should always be assumed?
The maximum number of iterations possible.
What is the setup cost (in time units) for a function call?
$1$ unit.
What three factors constitute the total running time of a function call?
Setup time, parameter calculation time, and the execution time of the function body.
Which OOP principle focuses on grouping data and methods into a single unit while restricting access?
Encapsulation
Java variables: Which variable type has a 'one copy per class' rule?
Static (or class) variables.
Java variables: Which variable type is unique to each object instance?
Instance variables.
The ability of a subclass to provide a specific implementation of a method already defined by its parent is called _____.
Method overriding
Why is 'protected' visibility broader than 'default' visibility?
Because it allows access to subclasses in different packages, which default does not.
Which Java keyword prevents a method from being overridden in a subclass?
final
If a class inherits from a subclass, what type of inheritance is being demonstrated?
Multi-level inheritance.
What does 'hierarchical inheritance' look like in a class diagram?
One parent class with multiple child classes branching out from it.
Why can static methods NOT use the 'this' keyword?
Because 'this' refers to a specific instance, and static methods belong to the class, not an instance.
Which component of space complexity deals with dynamically allocated objects like arrays?
Data space
In DAA, what is the time complexity assigned to a Single Boolean Operation?
$1$ unit.
True or False: Static methods can access instance variables directly.
False (they can only access static data).
How does method overloading achieve static polymorphism?
By resolving which method to call at compile time based on the parameter list.
If a constructor is called in a subclass, which class's constructor executes first?
The superclass constructor.
What keyword is used to define a 'blueprint' that contains only abstract methods and constants?
interface
In the analysis of an 'if-else' block, why do we take the maximum running time of the clauses?
To ensure we account for the worst-case execution time.
What type of knowledge is represented by 'Assignment Operation = 1'?
Time complexity analysis rule.
In Java, what is the default access level if no modifier is used?
Default (package-private).
Can a final method be overloaded?
Yes (it just cannot be overridden).
Does an abstract class require at least one abstract method?
No, it can have zero or more abstract methods.
The space needed to store constants and variables is part of _____ space.
Data
What is the time complexity for a single Input/Output operation?
$1$ unit.
In nested loops, if the outer loop runs $n$ times and the inner loop runs $m$ times, the total iterations are _____.
$n \times m$