Java OOP notes

0.0(0)
Studied by 2 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/80

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:08 AM on 6/15/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

81 Terms

1
New cards

Which programming paradigm is characterised by a step-by-step approach to execution?

Procedural paradigm

2
New cards

The paradigm that breaks down a system into discrete objects is known as _____.

Object-Oriented Programming (OOP)

3
New cards

Term: Declarative paradigm

Definition: A programming paradigm that expresses the logic of a computation without describing its control flow.

4
New cards

What is the primary purpose of 'abstraction' in Object-Oriented Programming?

To hide implementation details from the user.

5
New cards

The process of hiding data inside a class so it is inaccessible from the outside is called _____.

Encapsulation

6
New cards

Concept: Inheritance

Definition: The mechanism by which objects of a class acquire the properties and behaviours of that class.

7
New cards

How is 'polymorphism' defined in the context of OOP?

The ability of an entity to take on more than one form.

8
New cards

Where are local variables declared in a Java programme?

Within methods, constructors, or blocks.

9
New cards

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.

10
New cards

True or False: Local variables in Java can use access modifiers.

FALSE

11
New cards

Where are instance variables declared within a Java class?

Inside the class but outside any method, constructor, or block.

12
New cards

At what point is a Java instance variable created?

When an object of the class is created.

13
New cards

What is the visibility of instance variables within their own class?

They are visible to all methods, constructors, and blocks within that class.

14
New cards

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.

15
New cards

Which keyword is required to declare a class variable in Java?

static

16
New cards

How many copies of a static/class variable exist per class?

Only one copy exists per class, regardless of how many objects are instantiated.

17
New cards

What is the main restriction regarding the instantiation of an 'abstract' class?

It cannot be instantiated.

18
New cards

What types of methods can be contained within an abstract class?

Both abstract and non-abstract methods.

19
New cards

What is the defining characteristic of a 'final' class regarding inheritance?

It cannot be inherited by any other class.

20
New cards

From where can a 'public' access modifier be reached?

From anywhere within the application.

21
New cards

What is the scope of a 'private' access modifier in Java?

Only within the class in which it is declared.

22
New cards

Which locations have access to 'protected' members in Java?

The same package and subclasses located in different packages.

23
New cards

What is the scope of 'default' access in Java when no modifier is specified?

Only classes within the same package.

24
New cards

How does 'method overloading' differ from 'method overriding' regarding parameters?

Overloading uses the same method name with different parameters.

25
New cards

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.

26
New cards

Identify one of the three types of methods that cannot be overridden in Java.

Final methods (or static methods, or private methods).

27
New cards

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).

28
New cards

What data can a static method access directly?

Only static data.

29
New cards

Which two keywords are prohibited from being used inside a static method?

this and super

30
New cards

True or False: Static methods can be overloaded.

TRUE

31
New cards

What is the effect of applying the 'final' keyword to a variable?

The value of the variable cannot be modified.

32
New cards

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.

33
New cards

Concept: Multi-level inheritance

Definition: A type of inheritance where a class is derived from another derived class.

34
New cards

Concept: Hierarchical inheritance

Definition: A type of inheritance where one superclass is inherited by multiple subclasses.

35
New cards

How does Java handle the lack of support for multiple inheritance between classes?

It uses interfaces to allow a class to implement multiple behaviours.

36
New cards

What is the rule regarding a class inheriting from itself in Java?

A class cannot inherit from itself.

37
New cards

Are constructors inherited by subclasses in Java?

No, but they can be invoked from the subclass.

38
New cards

What is the order of execution for constructors in an inheritance hierarchy?

They are called in order of derivation, from superclass to subclass.

39
New cards

Which keyword is used to call a superclass constructor from a subclass?

super

40
New cards

When does 'static polymorphism' occur, and what mechanism does it use?

It occurs at compile time and uses method overloading.

41
New cards

When does 'dynamic polymorphism' occur, and what mechanism does it use?

It occurs at runtime and uses method overriding.

42
New cards

What is the definition of an 'exception' in Java?

A runtime error.

43
New cards

What are the two components of a Java interface?

Abstract methods and static constants.

44
New cards

True or False: A Java interface can be instantiated.

FALSE

45
New cards

what OOP concept allows a class to implement multiple interfaces in java?

polymorphism

46
New cards

Concept: Instruction space

Definition: The space required to store the compiled version of the programme instructions.

47
New cards

What is 'data space' in the context of space complexity?

The space needed to store all constants, variables, arrays, and class instances.

48
New cards

In time complexity analysis, what is the assumed time cost for a single Assignment Operation?

$1$ arbitrary time unit.

49
New cards

In time complexity analysis, what is the assumed time cost for a single Arithmetic Operation?

$1$ arbitrary time unit.

50
New cards

In time complexity analysis, what is the assumed time cost for a Function Return?

$1$ arbitrary time unit.

51
New cards

How is the running time of a selection statement (if/switch) calculated?

Condition evaluation time plus the maximum running time of the individual clauses.

52
New cards

How is the running time of a single loop determined?

The running time of the statements inside multiplied by the number of iterations.

53
New cards

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.

54
New cards

What is the recommended directional approach for analysing nested loops?

Inside out.

55
New cards

When calculating loop complexity, how many iterations should always be assumed?

The maximum number of iterations possible.

56
New cards

What is the setup cost (in time units) for a function call?

$1$ unit.

57
New cards

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.

58
New cards

Which OOP principle focuses on grouping data and methods into a single unit while restricting access?

Encapsulation

59
New cards

Java variables: Which variable type has a 'one copy per class' rule?

Static (or class) variables.

60
New cards

Java variables: Which variable type is unique to each object instance?

Instance variables.

61
New cards

The ability of a subclass to provide a specific implementation of a method already defined by its parent is called _____.

Method overriding

62
New cards

Why is 'protected' visibility broader than 'default' visibility?

Because it allows access to subclasses in different packages, which default does not.

63
New cards

Which Java keyword prevents a method from being overridden in a subclass?

final

64
New cards

If a class inherits from a subclass, what type of inheritance is being demonstrated?

Multi-level inheritance.

65
New cards

What does 'hierarchical inheritance' look like in a class diagram?

One parent class with multiple child classes branching out from it.

66
New cards

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.

67
New cards

Which component of space complexity deals with dynamically allocated objects like arrays?

Data space

68
New cards

In DAA, what is the time complexity assigned to a Single Boolean Operation?

$1$ unit.

69
New cards

True or False: Static methods can access instance variables directly.

False (they can only access static data).

70
New cards

How does method overloading achieve static polymorphism?

By resolving which method to call at compile time based on the parameter list.

71
New cards

If a constructor is called in a subclass, which class's constructor executes first?

The superclass constructor.

72
New cards

What keyword is used to define a 'blueprint' that contains only abstract methods and constants?

interface

73
New cards

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.

74
New cards

What type of knowledge is represented by 'Assignment Operation = 1'?

Time complexity analysis rule.

75
New cards

In Java, what is the default access level if no modifier is used?

Default (package-private).

76
New cards

Can a final method be overloaded?

Yes (it just cannot be overridden).

77
New cards

Does an abstract class require at least one abstract method?

No, it can have zero or more abstract methods.

78
New cards

The space needed to store constants and variables is part of _____ space.

Data

79
New cards

What is the time complexity for a single Input/Output operation?

$1$ unit.

80
New cards

In nested loops, if the outer loop runs $n$ times and the inner loop runs $m$ times, the total iterations are _____.

$n \times m$

81
New cards