0% found this document useful (0 votes)
4 views62 pages

Chapter 4Updated

Chapter 4 discusses Object-Oriented principles, focusing on encapsulation, data abstraction, inheritance, and polymorphism. It explains how encapsulation protects data integrity by bundling data and methods within a class, while inheritance allows classes to inherit properties and behaviors from other classes, promoting code reuse. The chapter also highlights the importance of access control and the use of getters and setters in managing class attributes.

Uploaded by

Daniel Amare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views62 pages

Chapter 4Updated

Chapter 4 discusses Object-Oriented principles, focusing on encapsulation, data abstraction, inheritance, and polymorphism. It explains how encapsulation protects data integrity by bundling data and methods within a class, while inheritance allows classes to inherit properties and behaviors from other classes, promoting code reuse. The chapter also highlights the importance of access control and the use of getters and setters in managing class attributes.

Uploaded by

Daniel Amare
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Chapter 4

Object Oriented principles

1
Outline
 Encapsulation and data abstraction

 Data Hiding and Encapsulation

 Inheritance &class hierarchy

 Interfaces and Abstract Classes

2
Data abstraction and encapsulation

 Imagine you have a treasure chest with valuable items. You want to keep the items safe and secure, so
you put them inside the treasure chest and lock it. You don't want anyone to directly access the items
without your permission or knowledge.

 In this example: The treasure chest represents a class inprogramming.

 The valuable items represent the data (attributes) inside the class.

 The act of putting the items inside the chest and locking it represents encapsulation

3
Data abstraction and encapsulation

 Encapsulation, in a general sense, is the act of enclosing or containing something within a capsule or
container

 Classes normally hide the details of their implementation from their client . This is called information
hiding. Access control is often referred to as implementation hiding.

 The client cares about what functionality program offers, not about how that functionality is
implemented. This is referred to as data abstraction. wrapping data and methods with implementation
hiding is often called encapsulation.

 Encapsulation can be described as a protective barrier that prevents the code and data being randomly
accessed by the other code defined outside the class.
4
Data abstraction and encapsulation

 In the context of object-oriented programming, encapsulation refers to the bundling of data (attributes)
and methods (behaviors) together within a class and controlling access to them.

 The term "encapsulation" in programming is just as enclosing or encapsulating related elements within
a protective container, similar to how we encapsulate objects in real-life containers to protect them.

 In programming, encapsulation allows us to group related data and behaviors together, providing a way
to organize and structure code.

 By encapsulating data and methods within a class, we establish boundaries and control access to the
internal workings of the class.

5
Data abstraction and encapsulation
 It helps to safeguard the integrity of the data and provides a well-defined interface for interacting with the class.

 The primary point of encapsulating data fields and methods together in a class is to promote proper information hiding
and to provide a well defined interface for interacting with the class.

 Let's explore the benefits and reasons behind this:

Information Hiding:

 It allows us to hide the internal details of how the class works.

 It enables us to prevent direct access to the internal state of the object from outside the class.

 protect the data integrity, ensuring that it can only be modified through controlled methods, thus preventing
unintended or incorrect usage.

 Hiding the internal implementation details also reduces complexity and enhances code maintainability.
6
Data abstraction and encapsulation
Modularity and Organization

 Encapsulation promotes modular design by grouping related data fields and methods together within a class.

 It provides a logical and organized structure for your code, making it easier to understand, read, and
maintain.

 With encapsulation, each class represents a distinct entity or concept, encapsulating its specific data and
behaviors, which improves code organization and separation of concerns.

 Access Control:

 Encapsulation allows you to control the visibility and access levels of data fields and methods.

 By using access modifiers (e.g., public, private, protected), you can restrict access to certain members of the
class.
7
Data abstraction and encapsulation
.Access Control:
 Example
 This enables you to define a clear interface for
interacting with the class, hiding unnecessary
implementation details and exposing only the
essential methods and attributes.

 Encapsulation means no more direct usage of the


class member variables but rather with other
public setter and getter methods

8
Data abstraction and encapsulation
Example
 Example
 A class’s private variable can only be accessed by
its methods.

 We can not be directly access the instance


variables of the class members which are
preceded by the access modifier private.

 To set value we will use Objname.set(“”) rather


than objName.instanceVariableName.

 To display the value of the instance variable we


use System.out.println(obJName.getName());

9
Continued…. Constructor and Encapsulation
 The following are characteristics of well  In Java, objects are constructed. Every time
designed encapsulated class
you make a new object, at least one
 Data variables ,fields are hidden from the user constructor is invoked.
object  Every class has a constructor, although if
 Methods provide explicit service to the user we don't create one explicitly, the compiler
object but hide the implementation. will build one for you.

 As long as the service do not change the  The first thing to notice is that constructors
implementation can be modified without look an awful lot like methods. A key
impacting the user. difference is that a constructor can't have a
return type.
10
Continued….
 The other BIG RULE, to understand about constructors is that they must have the same name as the class in which
they are declared.

 Constructors can't be marked static (they are after all associated with object instantiation), they can't be marked
final or abstract (because they can't be overridden)

11
ENCAPSULATION IN ACHIEVING DATA ABSTRACTION

 Encapsulation plays a vital role in achieving data abstraction. Let's explore how encapsulation is used as a data
abstraction process:

Bundling Data and Methods:

 Encapsulation allows you to bundle related data fields (attributes) and methods (behaviors) together within a class.

 Data fields represent the state or properties of an object, while methods define the operations or behaviors that can
be performed on the data.

 By encapsulating data and methods within a class, you establish a cohesive unit that represents an abstraction of a
real-world entity or concept.

12
Hiding Implementation Details:

 Encapsulation enables you to hide the internal implementation details of a class from external entities.

 The internal state of an object, represented by its data fields, is kept private or protected, preventing direct access from
outside the class.

 his information hiding ensures that the internal implementation details of a class are not exposed, promoting a higher
level of abstraction.

Providing an Interface:

Encapsulation provides a well-defined interface through which external entities can interact with the class.

The class exposes a set of public methods, while keeping the internal implementation details hidden

13
Providing an Interface:
 Example
 The class exposes a set of public methods, while keeping
the internal implementation details hidden.

 The public methods act as an abstraction layer, allowing


users to manipulate the class's data and invoke its
behaviors without needing to know the underlying
implementation details.

14
Hiding Implementation Details:
Separating Interface from Implementation:

 Encapsulation separates the interface (public methods) from the implementation (internal details) of a class.

 This separation allows for better maintenance and evolution of the codebase.

 Changes made to the internal implementation details do not impact the external users of the class, as long as the
interface remains unchanged.

 This separation of concerns enables abstraction by providing a clear distinction between how the class is used and how
it internally accomplishes its tasks.

15
Hiding Implementation Details:

 The public methods act as an abstraction layer, allowing users to manipulate the class's data and invoke its behaviors

without needing to know the underlying implementation details.

Abstracting Complexity:

 By encapsulating complex data structures and algorithms within a class, encapsulation serves as a form of data
abstraction.

 Users of the class only need to understand and interact with the simplified interface provided by the public methods.

 The complex details of how the data is stored, processed, or manipulated are abstracted away, making it easier for users
to work with the class.

16
SETTERS AND GETTERS
 public methods, commonly known as getters and setters, serve as access points to the fields (variables) of a class from
the external Java world.

Getters:

 Getters are public methods that allow external entities to access the values of private fields (variables) of a class.

 Getters typically have the prefix "get“ followed by the name of the field they provide access to.

 Getters provide read-only access to the values of the fields, allowing users to retrieve the current state of an object.

 By encapsulating the fields and providing getters, you can control how the values are accessed and potentially add
additional logic or transformations if needed.

17
SETTERS AND GETTERS
Setters:

 Setters are public methods that allow external entities to modify or set the values of private fields of a class.

 Setters typically have the prefix "set“ followed by the name of the field they modify.

 Setters provide write access to the fields, allowing users to update the state of an object.

 By encapsulating the fields and providing setters, you can control how the values are modified, validate inputs, or
perform other operations when the field is updated.

18
Examples
Getter and setter

19
Examples
Getter and setter Example

20
Continued….
 Example:

21
Polymorphism
► Polymorphism means "many forms", and it occurs when we have many classes that are related to each
other by inheritance.

 Enables us to “program in the general” rather than “program in the specific.”

 Polymorphism enables you to write programs that process objects that share the same superclass as if
they’re all objects of that superclass, simplifying programming.

 With polymorphism systems are easily extensible.

 Polymorphism uses those methods to perform different tasks. This allows us to perform a single
action in different ways.

22
Inheritance in java
 Inheritance is a fundamental concept in object oriented programming that allows classes
to inherit properties (fields and methods) from other classes.

 It enables the creation of hierarchical relationships between classes, where a subclass


inherits the characteristics of its superclass.

 Inheritance promotes code reuse and enables the creation of more specialized classes
based on existing classes.

 The superclass serves as a template or blueprint for creating subclasses, which can add
new features or modify existing ones.

23
 In object-oriented programming (OOP) Inheritance
 Inheritance is a way to form new classes using classes that have
already been defined.
 Inheritance is employed to help reuse existing code with little or no
modification.
 The new classes, known as derived classes, inherit attributes and
behavior of the pre-existing classes, which are referred to as base
classes (or ancestor classes).
 The inheritance relationship of sub- and superclasses gives rise to a
hierarchy.
 polymorphism and inheritance are useful for code reusability: reuse
attributes and methods of an existing class when you create a new
class.
24
Inheritance in java
 Subclasses inherit the fields and methods of the superclass and can also introduce their
own unique fields and methods.
 The superclass is higher in the inheritance hierarchy and represents a more general or
abstract concept, while subclasses are lower in the hierarchy and represent more specific
or specialized concepts.
 Subclasses inherit the attributes and behaviors of their superclass and can further
refine/embellish or specialize them as needed.
 Inheritance supports the principle of "is-a“ relationship, where a subclass is considered to
be a specific type of the superclass. For example, a "Car" class can be a subclass of a
more general "Vehicle" class, as a car is a specific type of vehicle. Car is-a vehicle

25
Inheritance in java
 This type of inheritance is not allowed in
 In Java, inheritance is achieved using the
java.
extends keyword. A class can extend only  Java allows only single inheritance to solve
one superclass, but multiple levels of this it brings interface.
inheritance can be created through a chain
of subclasses.

26
Private method can’t be overridden
 In Java, an instance method can be overridden by a subclass if it is accessible,
meaning it can be accessed and invoked by other classes or subclasses.
 However, a private method cannot be overridden because it is not accessible outside
its own class.
 When a method is declared as private in a super class, it is intended to be used only
within that class only.
 Private methods are not visible or accessible to other classes, including subclasses.
Therefore, it is not possible for a subclass to override a private method from its
superclass since it cannot access or modify the private method
27
Private method can’t be overridden
 This restriction ensures encapsulation and prevents subclasses from altering the
behavior of private methods, maintaining the integrity and consistency of the
superclass.

 Overriding is applicable to methods that are accessible and meant to be overridden,


such as public or protected methods.

 Private methods are not accessible which means they can not be overridden in the
sum class

28
APPLICATIONS OF INHERITANCE
 Specialization: Inheritance allows the creation of specialized classes or objects that
inherit data or behavior from a more general or parent class.

 The new class or object can add additional data fields or behaviors that are specific to
its specialized nature.

 This enables the modeling of more specific concepts in the program and promotes a
more organized and hierarchical structure in the codebase.

29
APPLICATIONS OF INHERITANCE
 Overriding: One of the key features of inheritance is the ability to override methods
in the subclass.

 This allows a subclass to provide its own implementation of a method that it inherits
from its superclass. By overriding a method, the subclass can modify or extend the
behavior defined in the superclass to suit its specific needs.

 This enables customization and flexibility in the behavior of objects based on their
specific class types.

30
APPLICATIONS OF INHERITANCE
Code re-use: Inheritance promotes code reusability by allowing classes to inherit
properties and behaviors from existing classes.

► When a class inherits from another class, it automatically gains access to all the fields
and methods defined in the superclass. This eliminates the need to duplicate code and
promotes a more modular and efficient development approach.

► By reusing existing code through inheritance, developers can save time and effort by
leveraging the functionality and structure already implemented in the superclass.

31
APPLICATIONS OF INHERITANCE
Code re-use: Inheritance promotes code reusability by allowing classes to inherit
properties and behaviors from existing classes.

► When a class inherits from another class, it automatically gains access to all the fields
and methods defined in the superclass. This eliminates the need to duplicate code and
promotes a more modular and efficient development approach.

► By reusing existing code through inheritance, developers can save time and effort by
leveraging the functionality and structure already implemented in the superclass.

32
Inheritance

Applications of inheritance the new class or object


has data or behavior
aspects that are not part
 Specialization of the inherited class.

permit a class or object


to replace the
implementation of an
 Overriding aspect—typically a
behavior—that it has
inherited.

 Code re-use re-use of code which


already existed in
another class.

33
Inheritance
 In Java inheritance is represented by the key word extends.
 Syntax
modifier class SubclassName extends SuperclassName
{
//body
}
Example
public class Mammal extends Animal
{
//body
}

34
Inheritance
Note: Object is the super class of all Java Classes.
public class Student
{
protected String name;
public Student()
{
name = “”;
}
public Student(String s)
{
name = s;
}
public String getName()
{
return name;
35 }
Examples of Inheritance

36
Examples of Inheritance

37
“Instance of” operator
This can be used to identify whether an object  Example
is an instance of a certain class or implements a
specific interface.

Here is the general syntax

ObjectName instanceof ClassName

If that defined object is an instance of that class


the result of that Boolean value will be True
else it show as incompatible error.

38
Super keyword
► The super keyword in java program is mainly used to infer the immediate parent class the
defined sub class.

► It paves the way to access and call members (Methods, variables and constructors) of the
super class inside the child class.

► When a class extends from an other class it inherits all the class members of the parent
class except the private members.

► It uses the super keyword to access its inherited members from the super class.

► It can access the member variables as follows

39
Super keyword
Member

1. Method

► If the subclass wants to define the method having the same name with the super class and
it wants to call the implementation of the super class it uses the super keyword .

► 2. Variables :

► As we have seen before when a class extends an other class it will inherit all non private
variables of the super class, but it can embellish itself with adding additional variables to
the existing super class variables.

► It uses the super keyword to infer the super class variables instead of reinventing them in
the
40
sub class/
Super keyword
Calling superclass’s constructor

► The subclass constructor automatically invoke the parent class constructor using super()
before initializing its specific variables.

► The initializing code defined in the super class is executed before the subclasses
initialization is executed.

► Generally, the super keyword enables the subclass to leverage and extend the functionality
of the super class within the subclass, which enable code reuse and create hierarchical
relationship between different classes

41
Super keyword
Calling superclass’s constructor example

42
Final Class and Final Method
► Final can be applied to class, variables and methods .

► a class which is preceded by a final keyword can not be sub-classed.

► It is typically used for classes that are intended to be secure, efficient, or provide
specialized functionality that should not be altered.

► A Method preceded by a final keyword can not be overridden.

► It is commonly used to prevent subclasses from altering the behavior of a crucial method
that is essential to the class's functionality or consistency.

43
Example

Final class  Final method

44
Abstract Classes and Methods
 Abstract classes
 Sometimes it’s useful to declare classes for which you never intend to create objects.

 Used only as superclasses in inheritance hierarchies, so they are sometimes called abstract
superclasses.

 Cannot be used to instantiate objects—abstract classes are incomplete.

 Subclasses must declare the “missing pieces” to become “concrete” classes, from which
you can instantiate objects; otherwise, these subclasses too, will be abstract.

 An abstract class provides a superclass from which other classes can inherit and thus share a
common design.
Abstract Classes and Methods
 Classes that can be used to instantiate objects are called concrete classes.

 Such classes provide implementations of every method they declare (including those inherited).

 Concrete classes provide the specifics that make it reasonable to instantiate objects.

 Not all hierarchies contain abstract classes.

 Programmers often write client code that uses only abstract superclass types to reduce client code’s
dependencies on a range of subclass types.

 You can write a method with a parameter of an abstract superclass type.

 When called, such a method can receive an object of any concrete class that directly or indirectly extends the
superclass specified as the parameter’s type.

 Abstract classes sometimes constitute several levels of a hierarchy.


(Cont.)
 You make a class abstract by declaring it with keyword abstract.
 An abstract class contains one or more abstract methods.
 An abstract method is one with keyword abstract in its declaration, as in
public abstract void draw(); // abstract method

 Abstract methods do not provide implementations.


 A class that contains abstract methods must be an abstract class even if that class contains some
concrete (non-abstract) methods.
 Each concrete subclass of an abstract superclass, must provide concrete implementations of each
of the superclass’s abstract methods.
 Constructors and static methods cannot be declared abstract.
abstract Methods in Abstract Classes

 Abstract methods are typically declared in abstract classes, which serve as blueprints for
other classes.

 An abstract class can have one or more abstract methods along with regular (nonabstract)
methods.

 Subclasses that extend an abstract class must implement all the abstract methods
inherited from the abstract class.

 Subclasses that inherit an abstract method from an abstract class must provide an
implementation for that method.
Example
package ethioTechnoTube; class Dog extends Animal{
abstract class Animal{ Dog(String Name) {
protected String Name; super(Name);
Animal(String n) { }
this.Name=n; public void Status() {
} System.out.println("it is
protected abstract void barking");
Sound();//abtsract class }
public void Status() { @Override
System.out.println("it has protected void Sound() {
slept"); System.out.println(Name+":
}} Bark");
}}
.
Example
class Cat extends Animal{ Example
Cat(String Name) {//
constructor of the cat class
super(Name);
}
public void Status() {
System.out.println("the cat
has gone out");
}
@Override
protected void Sound() {
System.out.println(Name+" :
mew");}}
.
Case Study: Payroll System Using Polymorphism
 Use an abstract method and polymorphism to perform payroll calculations based
on the type of inheritance hierarchy headed by an employee.

 Enhanced employee inheritance hierarchy requirements:


 Salaried employees are paid a fixed weekly salary

 Hourly employees are paid by the hour and receive overtime pay (i.e., 1.5 times their hourly
salary rate) for all hours worked in excess of 40 hours

 Commission employees are paid a percentage of their sales

 Base-salaried commission employees receive a base salary plus a percentage of their sales.

 For the current pay period employees will receive an additional 10% to their base salaries.
Case Study: Payroll System Using Polymorphism (Cont.)
 abstract class Employee represents the
general concept of an employee.

 Subclasses: SalariedEmployee,
CommissionEmployee, HourlyEmployee
and BasePlusCommissionEmployee (an
indirect subclass)

 Fig. shows the inheritance hierarchy for our


polymorphic employee-payroll application.
Case Study: Payroll System Using Polymorphism (Cont.)
 Abstract superclass Employee declares the
 An abstract method—there is not enough
methods that are common down the hierarchy.
information to determine what amount
 Each employee has a first name, a last name and a
earnings should return.
social security number defined in abstract superclass
Employee.  Each subclass overrides earnings with an

 Class Employee provides methods earnings and appropriate implementation.


toString, in addition to the get and set methods that  Iterate through the array of Employees and
manipulate Employee’s instance variables.
call method earnings for each Employee
 An earnings method applies to all employees, but
subclass object.
each earnings calculation depends on the
 Method calls processed polymorphically.
employee’s class.
Abstract class
package dduOop; public String getLastName() {
public abstract class Employee { return lastName;
private String FirstName;
private String lastName; }
private String socialSecurityNumber;
public Employee(String FN,String public void setLastName(String last) {
LName,String SSN) { lastName=last;
this.FirstName=FN;
this.lastName=LName; }
this.socialSecurityNumber=SSN;
} public String toString() {
public String getFirstName() { return
return FirstName;
} String.format("%s,$s\nSocialSecurity",getFirstNa
public void setFirstName(String first) {
FirstName=first; me(),getLastName(),getSocialSecurityNumber());
} }
public String getSocialSecurityNumber() {
return socialSecurityNumber; public abstract double Earnings();// abtsract
}
public void Method
setsocialSecurityNumber(String ssn) { }
socialSecurityNumber=ssn;
}
54
Abstract class public double Earnings()
package dduOop; {
public class HourlyEmployee extends Employee {
private double wage ;
if(getHours()<=40)
private double hours; return getWage()
public HourlyEmployee(String FN, String LName, *getHours();
String SSN,double hourlyWage,double
hoursWorked) { else
super(FN, LName, SSN); return
setWage(hourlyWage); 40*getWage()+(getHours()-
setHours(hoursWorked);}
public double getWage() 40)*getWage()*1.5;}
{ @Override
return wage;}
public void setHours(double hoursWorked) { public String toString() {
if((hoursWorked>=0.0)&&(hoursWorked<=168.0)) return
hours=hoursWorked; String.format("Hourly
else
throw new IllegalArgumentException("hours Employee:%s\n%s:$%,.2f:%s:%
worked must be >=0.0 and <=168.0");}
public void setWage(double hourlyWage) {
,.2f"
if(hourlyWage>0.0) { ,super.toString(),"hourly
wage=hourlyWage;} wage",
else getWage(),"hours
throw new IllegalArgumentException("Hourly wage
must be >0");} worked",getHours());
public double getHours()
{
}
}
return
55 hours; }
@Override
Abstract class public void setGrossSales(double
sales) {
package dduOop; if(sales >=0.0)
public class CommisionEmployee extends grossSales=sales;
Employee{ else
private double grossSales;// gross weekly sales throw new IllegalArgumentException("
private double CommissionRate;// commission gross sales must be >=0.0");
percentage }
public CommisionEmployee(String FN, String public double getGrossSales()
LName, String SSN,double sales,double rate) { {
super(FN, LName, SSN); return grossSales;
setGrossSales(sales); }
setCommissionRate(rate);
// TODO Auto-generated constructor stub @Override
} public double Earnings() {
public void setCommissionRate(double rate) { return
if(rate>0.0 && rate<1.0) getCommisionRate()*getGrossSales();
CommissionRate=rate; }
else @Override
throw new IllegalArgumentException("Commision public String toString() {
rate must be >0.0 ans <1.0"); return
} String.format("%s:%s\n%s:$%,.2f:%s:%,.
public double getCommisionRate() { 2f","Commision
return CommissionRate; employee",super.toString(),
} "gross salary",getGrossSales(),
"commission rate",getCommisionRate());
56 }}
Abstract class @Override
package dduOop; public double Earnings() {
public class BasePlusCommisionEmployee return
extends CommisionEmployee { getBaseSalary()+super.Earnings();
private double baseSalary; }
public BasePlusCommisionEmployee(String FN, @Override
String LName, public String toString() {
String SSN, double sales, double rate,double return
salary) { String.format("%s %s; %s:
super(FN, LName, SSN, sales, rate); $%,.2f","Base-
setBaseSalary(salary); Salaried",super.toString(),
} "Base
public void setBaseSalary(double salary) { salary",getBaseSalary()
if(salary>=0.0) );
baseSalary=salary; }
else
throw new IllegalAccessError("Salary must }
be>=0.0 ");
}
public double getBaseSalary() {
return baseSalary;
}
57
Interface
► An interface is not a class.
 The interface contains method declarations
► An interface contains only behaviors
and may contain constants.
(i.e. methods) that a class implements.
 All the methods are public (even if the
► If a class (provided it is not abstract)
modifier is missing)
implements an interface, then all the
 Interfaces are pure abstract classes →
methods of interface need to be defined
cannot be instantiated.
in it.
 The implementer classes should implement
all the methods declared in the interface.

 A class can extend a single class but may


implement any number of interfaces
58
Properties of an interface
►A class can extend only one class, but can
 An interface is implicitly (i.e. by default)
abstract. We do not need to use the abstract implement many interfaces.
► An interface itself can extend another
keyword when declaring an interface.
interface.
 Each method in an interface is also
► We cannot instantiate (i.e. create object)
implicitly (i.e. by default) abstract, so the
an interface but we can instantiate a class.
abstract keyword is not needed
► An interface does not contain any
 Methods in an interface are implicitly (i.e.
constructors but a class may contain any
by default) public.
constructors.
 A class can implement more than one
interface at a time.
Syntax of defining an interface
59
Syntax of defining an interface
Implementing interface
 Syntax

 Example

60
Interfaces Can Be Extended  Example
 One interface can inherit another by use
of the keyword extends.

 The syntax is the same as for inheriting


classes.

 When a class implements an interface that


inherits another interface, it must provide
implementations for all methods defined
within the interface inheritance chain.

61
Class Work
 Make a group of 4 students  4th Group:

 1st Group: Difference between java class  Getter and setter methods
and main class with Example, conditional  Inheritance with example
statements
 2nd Group: Data inputs in java With
Example, how to instantiate an object,
 3rd group: Method and Constructor with
example overriding and constructor
overloading

62

You might also like