Skip to main content

Posts

Showing posts from September, 2019

polymorphism

Polymorphism : Polymorphism refers to the ability of OOPs programming languages to differentiate between entities with the same name efficiently. This is done by Java with the help of the signature and declaration of these entities. For Example: // Java program to demonstrate Polymorphism // This class will contain // 3 methods with same name, // yet the program will // compile & run successfully public class Sum { // Overloaded sum(). // This sum takes two int parameters public int sum(int x, int y) { return (x + y); } // Overloaded sum(). // This sum takes three int parameters public int sum(int x, int y, int z) { return (x + y + z); } // Overloaded sum(). // This sum takes two double parameters public double sum(double x, double y) { return (x + y); } // Driver code public static void main(String args[]) { Sum s = new Sum(); System.out.println(s.sum(10, 20)); System.out.println(s.sum(10, 20, 30)); System.out....

Object Oriented Programming Concept in Java

Object Oriented Programming Concept in Java  Object-oriented programming:  Object-Oriented Programming or OOPs refers to languages that uses objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function. OOPs Concepts 1. Polymorphism 2 . Inheritance 3.Encapsulation 4.Abstraction 5.Class 6.Object 7.Method 8.Message Passing polymorphism