OOPs Concepts in Java

There are four basic OOPs Concepts in Java

  1.  Abstraction
  2.  Encapsulation
  3.  Polymorphism
  4.  Inheritance

Definition of Class / Object

Class describes all the attributes of object, as well as the methods that implements the behavior of member object. That means this is a template or blue print.
In object-oriented programming , a class is a template definition of the method s and variable s in a particular kind of object . Thus, an object is a specific instance of a class; it contains real values instead of variables.

Object is an instance of a class, it contains real values instead of variables.

Person employee=new Person();

OOPs Concepts in Java

Abstraction

Abstraction is separating the functions and properties that logically can be separated to a separate entity.
Abstraction in Object Oriented Programming helps to hide the irrelevant details of an object.

Encapsulation

Encapsulation is an OOPS concept to create and define the permissions and restrictions of an object and its member variables and methods. A very simple example to explain the concept is to make the member variables of a class private and providing public getter and setter methods. Java provides four types of access level modifiers: public, protected, no modifier and private.

Polymorphism

Polymorphism is the occurrence of something in various forms. Java supports various forms of polymorphism like polymorphic reference variables, polymorphic method, polymorphic return types and polymorphic argument types.

Polymorphic reference variables can hold any of its subtype class reference.

class A extends C{}
class B extends C{}
C cType = new A();
cType = new B();

Polymorphic method can be overloading or overriding.

Polymorphic return types and polymorphic argument types:

public class Poly {
public static void main(String[] args) {
setNumber(new Integer(1));
System.out.println(getNumber());
}

public static Number getNumber() {
Integer i = new Integer(1);
return i;
}

public static void setNumber(Number n) {
}
}

Inheritance

In object-oriented programming (OOP), inheritance is a way to reuse code of existing objects.
A class can inherit attributes and behavior from pre-existing class called base classes, superclasses, or parent classes. The resulting class is known as derived classes, subclasses, or child classes

Thanks for reading our “OOPs Concepts in Java” article. If you liked it, then please share with your friends and colleagues. If you have any feedback or doubt then please leave us a comment.

By the way, I am also really happy to announce some very exciting news: to celebrate the imminent release of Spring 5 and Java 9,  we launched our simulators SALE CAMPAIGN. We halved the price of our simulators at www.springmockexams.com and www.javamockexams.com for limited time only. Take a look here bit.ly/SMEBP and here bit.ly/JMEBP

If you are interested in collaborating with us, you can join our partner program at bit.ly/SMEPART  and here bit.ly/JMEPART

What is new in Spring Framework 5?

What is new in Spring Framework 5?

  • JDK 8+9 and Java EE 7 Baseline
  • Minimum Java requirement will be raised to JDK 8.
  • Also there is upgrade to the minimum Java EE versions. The current minimum version is Servlet 2.5, this will be raised to Servlet 3.0.
  • JPA 1.1+ and Bean Valication API 1.1+ will be the minimum requirements.
  • Reactive Programming Model

Reference Links:

By the way, I am also really happy to announce some very exciting news: to celebrate the imminent release of Spring 5 and Java 9,  we launched our simulators SALE CAMPAIGN. We halved the price of our simulators at www.springmockexams.com and www.javamockexams.com for limited time only. Take a look here bit.ly/SMEBP and here bit.ly/JMEBP

If you are interested in collaborating with us, you can join our partner program at bit.ly/SMEPART  and here bit.ly/JMEPART

Top 5 Spring Boot Interview Questions with Answers for Java/JEE Programmers 2018

Here is our top 5 list of the most common Spring Boot Interview Questions based on our recent survey.

1. What is Spring Boot? Why should we use it?

Spring Boot is a Java framework from Sring umbrella which is developed to simplify the use of Spring Framework for Java development. It helps in automation, configuration, and dependencies.

Why should we use it? It provides a lot of convenience by auto-configuration which helps improve productivity because it allows developers and programmers to focus on writing the business logic.

2. What is starter dependency in Spring Boot? 

This question is usually asked because after examining several Spring-based projects, they noticed that there is always some set of libraries which are used together e.g. Spring MVC with Jackson for creating RESTful web services. Since declaring a dependency in Maven’s pom.xml is difficult, they combined many libraries into one based upon functionality and created this starter package.

This saves you a lot of hassles from declaring many dependencies. Moreover, frees you from compatibility and version mismatch issue.

3. What is Spring Initializer and why should you use it?

It helps in initial setup – it’s a web application that helps you to create initial Spring boot project structure and provides Maven or Gradle build file to build your code.

4. Where do you define properties in Spring Boot application?

You can define related properties into a file called application.properties. This can be done manually or you can use Spring Initializer to create this file, albeit empty.

You don’t need to do any special configuration to instruct Spring Boot load this file. If it exists in classpath then Spring Boot automatically loads it and configure itself and application code according.

5. What is the difference between an embedded container and a WAR?

The main difference between these two is that you can run Spring Boot application as a JAR from the command prompt without setting up a web server. To run a WAR file, you need to set up a web server.

Thanks for reading our first article so far. If you like these Spring Boot Interview Questions then please share with your friends and colleagues. If you have any feedback or doubt then please leave us a comment.

By the way, I am also really happy to announce some very exciting news: to celebrate the imminent release of Spring 5 and Java 9,  we launched our simulators SALE CAMPAIGN. We halved the price of our simulators at www.springmockexams.com and www.javamockexams.com for limited time only. Take a look here bit.ly/SMEBP and here bit.ly/JMEBP

If you are interested in collaborating with us, you can join our partner program at bit.ly/SMEPART  and here bit.ly/JMEPART