Please define Polymorphism Inheritance Encapsulation Predefi
Please define:
Polymorphism
Inheritance
Encapsulation
Predefined Methods (toString(), getDate(),CharAt(), TOUPPER(), TOLOWER(), subString() etc.)
Solution
Polymorphism, Inheritance and Encapsulation are features of Object Oriented Programming.
Polymorphism
It means different things having same name, for instance, a function named area() can be used to calculate areas for different figures. It is implemented by defining three different functions with same name but different number of arguments.
For rectangle : int area ( int length, int breadth);
For Triangle : float area ( int a, int b, int c);
For square : int area ( int side);
Inheritance
It is the ability of a class to inherit functions and properties of another class.
e.g, class car can be inherited from class vehicle, or class dog and class cat can be inherited from super class animal.
Then there are various modes of inheritance available in OOP.
Encapsulation
The wrapping up of the data into a single unit called class is encapsulation.
1) toString() : It takes an object and returns its string representation.
2) getDate() : This method returns the day of the month for the specified month according to local time.
3) CharAt() : It takes an integer as input, which is a 0-based index, and it returns a char value for that index number. from a string.
4) TOUPPER() : It is used to convert all the characters of a string to UPPERCASE letters.
5) TOLOWER() : It is used to convert all the characters of a string to lowercase letters.
6) subString() : It takes an integer value as begin index and returns a new string starting from new index.
