Object Oriented Principles

Java is object-oriented programming language. They key principles of object-oriented programming are
Abstraction
Encapsulation
Inheritance
Polymorphism

Abstraction

Abstraction is hiding or managing complexity. For example, when we think of a car, we think of well-defined object with states and behaviour. While driving a car we ignore many internal details of the car like engine, gear system, brake system etc. We manage the complexity of the car through abstractions. Abstractions allows us to shield with inevitable changes in the sub systems.

Encapsulation

Encapsulation is binding of data and the methods that operate on the data. For example, you can make a method that changes a variable as private. This keeps the data safe from outside misuse of the data.
Encapsulation acts like a protective shield that prevents code and data from outside interference. Access will be allowed through well-defined interface. In Java class we have variables and methods.

Inheritance

Inheritance is that one object called as sub class or child class acquires or inherits state and behavior from another object called as super class or parent class. The child class and the parent class share a “IS-A” relationship. For example, cat is an animal. In Java, we use extends keyword to use inheritance.

public Cat extends Pet {
…
}

 

Polymorphism

Polymorphism means having many forms and shapes. Java supports static as well as dynamic Polymorphism. It has the ability to process multiple objects of various classes through a single interface. Any object in Java is polymorphic in nature. We will discuss more about static and dynamic polymorphism in detail in another post.

Related Posts

Call By Value Screen

C++, Programming

Call-by-Value and Call-by-Reference Example

Classes and Objects in Java

Java, Programming

Working with Classes and Objects in Java

Java Documentation Comments

Java, Programming

Working with Documentation comments in Java

Warining-in-C-Program-1024x534

Programming

Dissecting a C program

UMLet Eclipse Plugin

Programming

UMLet: An open source Tool for Fast UML Diagrams

New-Project-CodeBlocks-1024x454

Programming

Download and Install Code::Blocks

Navigation

  • Home
  • Selenium
  • JBehave
  • Questions
  • Contact
  • Privacy
  • About

Random Posts

  • List_OperationsJava List Interface Example
  • Test webpage urlTesting webpage mobile-friendliness using a tool
  • Timeout test JUnitTesting timeouts with JUnit 4
  • JUnit Jupiter APIJUnit 5 Jupiter API Annotations
  • JUnit LibraryAdding JUnit5 library to a Project
  • Serenity BDD JBehave Result JenkinsRunning Serenity BDD stories with Jenkins
  • SerenityReportDebugDebug Serenity BDD JBehave project
  • Git Commit JBehave ProjectAdding Stories to JBehave project
  • Filtering stories JBehave MavenFiltering Stories in JBehave
  • Serenity Project Information 2Create Serenity JBehave project from command line.
  • Screenshot Test StepRunning Serenity Tests
  • No goals specified Maven ErrorHow to fix Maven error No goals specified
  • Sample_Eclipse_Check_programAutomation Environment Setup Verification
  • Blue Ocean UIBlue Ocean Jenkins Plugin
  • Android Virtual Device ManagerCreating Android Virtual Device with AVD Manager
TestingDocs.com
© 2016 - 2019 TestingDocs.com All Rights Reserved
TestingDocs.com

TestingDocs.com

Links

  • Home
  • Selenium
  • JBehave
  • Questions
  • Contact
  • Privacy
  • About

Search