[go: up one dir, main page]

0% found this document useful (0 votes)
2 views3 pages

Java Inheritance

This document is a Java OOP crash guide designed for last-minute exam revision, covering key concepts such as inheritance, polymorphism, and method overriding. It includes code examples and essential reminders for each topic, such as the use of the 'super' keyword and the characteristics of abstract classes and interfaces. The guide is structured for quick reference to help students prepare effectively for their exams.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Java Inheritance

This document is a Java OOP crash guide designed for last-minute exam revision, covering key concepts such as inheritance, polymorphism, and method overriding. It includes code examples and essential reminders for each topic, such as the use of the 'super' keyword and the characteristics of abstract classes and interfaces. The guide is structured for quick reference to help students prepare effectively for their exams.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

🔥 Java OOP Crash Guide – Exam Survival Sheet

Use this for last-minute revision. Simple, fast, and clean.

🔹 Inheritance
💡 What: One class gets features from another class.

📦 Code Example:

class Animal { void eat() { } } class Dog extends Animal { }

🧠 Remember: Dog gets eat() from Animal

🔹 super keyword
💡 What: Used to call parent class constructor or variable.

📦 Code Example:

super.i = 10;

🧠 Remember: super = parent access

🔹 Constructor Execution
💡 What: Parent constructor runs before child.

📦 Code Example:

class A { A() { } } class B extends A { B() { } }

🧠 Remember: Parent builds first

🔹 Types of Inheritance
💡 What: Single, Multilevel, Hierarchical.

📦 Code Example:

class A {}
class B extends A {}
class C extends B {}

🧠 Remember: Multilevel = A → B → C

🔹 Method Overriding
💡 What: Child changes parent method behavior.
📦 Code Example:

class A { void show() {} } class B extends A { void show() {} }

🧠 Remember: Same method, new rules

🔹 Polymorphism
💡 What: Same call behaves differently for different objects.

📦 Code Example:

A obj = new B(); obj.show();

🧠 Remember: One call, many results

🔹 Dynamic Dispatch
💡 What: Decides at runtime which method to run.

📦 Code Example:

A obj = new B(); obj.show();

🧠 Remember: Runtime method decision

🔹 Abstract Class
💡 What: Cannot be instantiated. Contains abstract methods.

📦 Code Example:

abstract class A { abstract void run(); }

🧠 Remember: Half-done class

🔹 final Keyword
💡 What: Prevents override or inheritance.

📦 Code Example:

final class A {} final void show() {}

🧠 Remember: Freeze this – no change

🔹 Object Class
💡 What: Top class of all Java classes.

📦 Code Example:
obj.toString();

🧠 Remember: Base of all classes

🔹 Interface
💡 What: List of methods to implement. No bodies.

📦 Code Example:

interface A { void show(); }

🧠 Remember: Must-do list

🔹 Default Interface Method


💡 What: Optional method with body (Java 8+).

📦 Code Example:

default void greet() { }

🧠 Remember: Optional ready method

🔹 Static Interface Method


💡 What: Called with InterfaceName.method().

📦 Code Example:

static void help() { }

🧠 Remember: InterfaceName.method()

🔹 Private Interface Method


💡 What: Helper method for reuse (Java 9+).

📦 Code Example:

private void helper() { }

🧠 Remember: Only for use inside interface

You might also like