Things all DevOps Engineer should know in Java: OOPS Basics

      Comments Off on Things all DevOps Engineer should know in Java: OOPS Basics

This tutorial will walk you through the basics of Java every DevOps Engineer should know with OOPS concept.

Introduction :

Java is one of the most popular programming languages used to create Web applications and platforms.

This is very important for a DevOps Engineer should have the basic understanding if the want to write Shared Libraries for Automation since groovy because Groovy is a Java-syntax-compatible object-oriented programming language for the Java platform.

Key Things to Know:

Classes:

Classes are collections of methods which contains all the behaviours.
Classes are a specification or blueprint which we can be used to create the actual objects [Perform operations]. Class doesn’t consume any space. Child class can not have more than one parent class.

Syntax:

class ClassName {      
         // default constructor is hidden
}
Objects:

Objects will do the actual operations in the program. Every objects has its own behaviours. Objects are runtime concepts, it does not exist until our application runs. Static classes will be initialised when we run program. Object will be initialized only when we use keyword “new”.

It is important to know that the only possible way to access an object is through a reference variable.

Methods:

A method(function) is basically a behaviour. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed.

Constructor:

If we don’t define a constructor we will have a constructor by default for every classes. This is to construct objects, Constructor is only required if we need to initiate some variables at class initialization.

Constructor example :

public class Maven {
   public Maven(){
	Test = false   //initiate this variable at class initialization
	}
}

Syntax:

class ClassName {
   ClassName() {
   }
}

Example :

 

Note: Constructor we are not using in this example since we don’t initialize any variables at class initialization

Object Oriented Programming Basics :

It gives code orientation. This is to organize the code better. It simplifies the software development and maintenance by providing some concepts.

Principles of OOPS :

There are four principles,

  • Inheritance
  • Polymorphism
  • Abstraction
  • Encapsulation

Sharing is caring!

About Dinesh Sobitharaj C

An IT professional having multiple years of experience in IT Infrastructure planning, System integrations, Project implementation and delivery. Devops Enthusiast skilled with broad ranges of technology adoption. Well versed with Cloud Computing and Application Service Offerings such as SaaS/PaaS/IaaS. Expert in aligning business goals, mission and process to architect innovative solutions and strategies.