Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
PROGRAMMING
Assignment- 2
S.Arjeen
ITT/2015/2016/002
0169
Discussion Topic set 1
Data Hiding
}
}
Abstraction
Object-oriented programming, abstraction is a process of hiding the
implementation details from the user, only the functionality will be provided to
the user. In other words, the user will have the information on what the object
does instead of how it does it.
class Student {
A tightly encapsulated class does not allow public access to any data member that
can be changed in any way.so encapsulation helps to protect internal data from the
possibility of corruption from external influences.
public class A {
private int x;
public static void main(String[] args){
}
}
class B {
private int x;
public void setX(int x) {
this.x = x;
}
public int getX() {
return x;
}
}
IS-A Relationship
In object-oriented programming, the concept of IS-A is a totally based on Inheritance,
which can be of two types Class Inheritance or Interface Inheritance. It is just like saying
"A is a B type of thing". For example, Apple is a Fruit, Car is a Vehicle etc. Inheritance is
uni-directional. For example, House is a Building. But Building is not a House.
}
HAS-A Relationship
In Has-A relationship an object of one class is created as data member in
another class the relationship between these two classes is Has-A. In Has-A
relationship there existed physical memory space and it is also known as part
of or kind of relationship.
this.color = color;
this.maxSpeed = maxSpeed;
}
Overloading
Method Overloading is a feature that allows a class to have more than one method
having the same name, if their argument lists are different. It is similar to constructor
overloading in Java, that allows a class to have more than one constructor having
different argument lists.
class Overriding {
void run() {
System.out.println("Vehicle is running");
}
}
}
}