OOPS concept of JAVA required for Selenium

OOPs (Object Oriented Programming System)

Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation
Object

Any entity that has state and behavior is known as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical.
Class
 Collection of objects is called class. It is a logical entity.

Inheritance in Detail:-

The process of obtaining the data members and methods from one class to another class is known as inheritance. It is one of the fundamental features of object-oriented programming.
In the inheritance the class which is give data members and methods is known as base or super or parent class.
The class which is taking the data members and methods is known as sub or derived or child class.
The data members and methods of a class are known as features.
The concept of inheritance is also known as re-usability or extendable classes or sub classing or derivation.
Why use Inheritance?
For Method Overriding (used for Runtime Polymorphism).
It's main uses are to enable polymorphism and to be able to reuse code for different classes by putting it in a common super class
For code Re-usability
Syntax of Inheritance
class Subclass-Name extends Superclass-Name
{
   //methods and fields
}
  • Advantage of inheritance
If we develop any application using concept of Inheritance than that application have following advantages,
•      Application development time is less.
•      Application takes less memory.
•      Application execution time is less.
•      Application performance is enhancing (improved).
•      Redundancy (repetition) of the code is reduced or minimized so that we get consistence results and less storage cost.
Note: In Inheritance the scope of access modifier increasing is allow but decreasing is not allow. Suppose in parent class method access modifier is default then it's present in child class with default or public or protected access modifier but not private (it decreased scope).
Types of Inheritance
Based on number of ways inheriting the feature of base class into derived class we have five types of inheritance; they are:
•      Single inheritance, Multiple inheritance, Hierarchical inheritance, Multilevel inheritance, Hybrid inheritance
Single inheritance
In single inheritance there exists single base class and single derived class.
Example of Single Inheritance
class Faculty
float salary=30000; 
class Science extends Faculty
{
float bonous=2000;
public static void main(String args[])
{
Science obj=new Science();
System.out.println("Salary is:"+obj.salary); 
System.out.println("Bonous is:"+obj.bonous); 
}
Output
Salary is: 30000.0
Bonous is: 2000.0


Comments

Popular posts from this blog

Handling Dynamic Web Tables Using Selenium WebDriver

Importance of testng.xml file

Read it out for TESTNG before going for an iterview