Java OOPs Concepts

we will help you to understand about Java OOP’S concepts with examples. oops concepts in java

Difference Encapsulation Abstraction

Difference Encapsulation Abstraction Summary: It is very confusing concept, as one depends on other, for a Java beginner to understand. Explained in simple terms in this tutorial "Difference Encapsulation Abstraction". How to explain the difference between Encapsulation and Abstraction before an Interviewer? Encapsulation is an OOPS concept. As everyone says, Encapsulation is binding the data …

Difference Encapsulation Abstraction Read More »

Protected Constructor Example Java

A Java constructor can be anyone one of the four access specifiers Java supports – public, protected, default and private. An examples on Protected Constructor is given with screenshots. public class Demo { protected Demo() { System.out.println(“Hello 1”); } public static void main(String args[]) { Demo d1 = new Demo(); } } Replace protected with …

Protected Constructor Example Java Read More »

Java Made Simple: Is it possible static class in Java?

Is it possible static class in Java? The answer is both "YES" and "NO". Let us see. Java comes with two types of classes – top-level classes and inner classes (also known as nested classes). A top-level class cannot be static where as a nested class can be static. Top-level class cannot be static. See …

Java Made Simple: Is it possible static class in Java? Read More »

Can you write a final constructor in Java?

When a class is inherited, the subclass inherits the methods and variables of super class but not constructors. For this reason, constructors are not members of class; only variables and methods are members of a class. As members are inherited, they are permitted by subclass to override with its own functionality. When constructors are not …

Can you write a final constructor in Java? Read More »

Does Java support static local variables inside method?

To answer this question, first we must know the concept of static with variables. Static variables are clearly and more elaborately discussed in . For our question sake, I quote a few points about static variables. A static variable does not maintain encapsulation. There will be only one location for static variable accessed by all …

Does Java support static local variables inside method? Read More »

What is Java static keyword, static variable, static method?

Java static is keyword used as an access modifier. It modifies the accessing technique of variables and methods in Java coding. "static" keyword can be applied to variables, methods, inner classes and blocks. We know, to call an instance variable and method, Java requires an object (and thus Java maintains encapsulation). But declaring a variable …

What is Java static keyword, static variable, static method? Read More »

What is static blank final variable in Java with Example?

We have seen earlier, blank final variable and let us see now static blank final variable. 1. What is blank final variable? A final variable declared but not initialized (or not given a value) is known as blank final variable. It can be given a value through a constructor only (but not through a method …

What is static blank final variable in Java with Example? Read More »

What is blank final variable with Example?

1. What is blank final variable or uninitialized final variable? A final variable declared but not assigned is known as a blank final variable or uninitialized final variable. Introduced with JDK 1.1. 2. How to initialize or give a value for an uninitialized final variable? It is possible with a constructor call only. That is, …

What is blank final variable with Example? Read More »

Java Made Simple: What is Java final variable with Example?

In Java programming, Java final keyword attains good importance as it can be applied in three places for three different entities – variables, methods and classes. In each place works differently and gives three different functionalities (outputs). A Java final variable cannot be reassigned. A Java final method cannot be overridden. A Java final class …

Java Made Simple: What is Java final variable with Example? Read More »

Java Made Simple: What is final keyword with Example?

Java comes with a final keyword that can be applied to variables, classes and methods and in each place when applied gives different meaning. A final variable cannot be reassigned. A final method cannot be overridden. A final class cannot be extended. Eventhough, final keyword works differently, one common purpose(functionality) we can derive is something …

Java Made Simple: What is final keyword with Example? Read More »

Java Made Simple: Java final method overriding with Example

Java final Method : final keyword can be applied to methods apart variables and classes. The main advantage of declaring a method final is to prevent subclass to override. Let us go through a simple program on final method. class Test { public final void display() // it is final method and cannot be overridden …

Java Made Simple: Java final method overriding with Example Read More »

Can we override static method in Java with Example?

The super class static methods cannot be overridden by sub class because they do not represent the state of the object or with static methods no encapsulation exists. For this reason, the super class static methods are not part of subclass. When they are not part of subclass, they cannot be overridden. Let us write …

Can we override static method in Java with Example? Read More »

Java Clear Concepts: Can we override protected method?

Protected method can be overridden by subclass. What are permitted access specifiers of sub class overridden method when super class method is protected? Discussed clearly with Example and Screenshot for a Beginner. The answer for the question is "YES". "protected" methods of super class can be overridden by subclass (but private methods cannot be overridden). …

Java Clear Concepts: Can we override protected method? Read More »

Java Clear Concepts: Can you override private method with Example?

Override private method: This is a very tricky question and is worthy to be answered clearly for a beginner. Let us start with a small code and clear explanation. First let us see an example on override private method class Test { private void display() { System.out.println(“From Test”); } } public class Demo extends Test …

Java Clear Concepts: Can you override private method with Example? Read More »

Java Made Simple: Java protected and protected method

Java protected specifier and protected method are explained also with method overriding rules. Given Example with Screenshot in Simple terms for a Beginner. Go on read. "public" specifier does not give any restrictions to any class from any package. But "protected" gives a small restriction over public. Restrictions of protected specifier If a member of …

Java Made Simple: Java protected and protected method Read More »

Java Made Simple: What is Java private method?

Java private method accessibility restrictions and overriding permissions are given. Go on read. "private" is known as access specifier in Java. Like other specifiers, private is a keyword. An access specifier specifies the access to other classes belonging to the same package or other packages. The private access specifier can be applied to instance variables …

Java Made Simple: What is Java private method? Read More »

Java Made Simple: What is Java private and private variable?

Private means purely private to that class. Private variable means can not be used by other class or even subclass. Given Example Screenshot Simple terms. Go on read. In Java, "private" is a keyword known as access specifier. As an access specifier, private gives maximum restrictions and no permissions. In common sense and generally also, …

Java Made Simple: What is Java private and private variable? Read More »