Posts

Showing posts with the label composition

Association, Aggregation & Composition,

Image
Association Association is relation between two separate classes which establishes through their Objects. Association can be one-to-one, one-to-many, many-to-one, many-to-many. In Object-Oriented programming, an Object communicates to other Object to use functionality and services provided by that object. Composition and Aggregation are the two forms of association. Program //Java program to understand the concept of association class School { private String school_name; School(String school_name) { this.school_name = school_name; } public String getSchoolName() { return this.school_name; } } class Student { private String student_name; Student(String student_name) { this.student_name = student_name; } public String getStudentName() { return this.student_name; } } public class Main { public static void main(String args[]) { School s = new School("Sarsvati ...

OOPs concepts

Image
In this article we will learn about OOP ( Object oriented programing ) concepts. If you want to learn further lessons about objects, classes, inheritance, polymorphism, how objects interact with each other then you must read these lesson carefully. There are total 7 core OOPs concepts.  1. Abstraction  Abstraction is the concept of hiding the internal details and describing things in simple terms. For example, a method that adds two integers. The method internal processing is hidden from outer world. There are many ways to achieve abstraction in object oriented programming, such as encapsulation and inheritance. A java program is also a great example of abstraction. Here java takes care of converting simple statements to machine language and hides the inner implementation details from outer world.  2. Encapsulation Encapsulation is the technique used to implement abstraction in object oriented programming. Encapsulation is used for access restriction ...