{"id":24671,"date":"2023-05-15T10:12:34","date_gmt":"2023-05-15T04:42:34","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/"},"modified":"2025-01-06T19:11:16","modified_gmt":"2025-01-06T13:41:16","slug":"oops-concepts-in-java","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/","title":{"rendered":"Mastering OOP Concepts in Java with Examples"},"content":{"rendered":"\n<p>OOP is all about designing software using objects, where data and behaviour come together. Unlike traditional procedural programming that focuses on sequences of tasks, OOP revolves around the interaction of objects to solve problems.<\/p>\n\n\n\n<p>Its four key principles, <strong>Encapsulation<\/strong>, <strong>Inheritance<\/strong>, <strong>Polymorphism<\/strong>, and <strong>Abstraction, <\/strong>form the building blocks of this approach.<\/p>\n\n\n\n<p>Learning OOP in Java will help you write efficient, easily maintainable code that can be reused in other projects when developing large applications.<\/p>\n\n\n\n    <div class=\"courses-cta-container\">\n        <div class=\"courses-cta-card\">\n            <div class=\"courses-cta-header\">\n                <div class=\"courses-learn-icon\"><\/div>\n                <span class=\"courses-learn-text\">Academy Pro<\/span>\n            <\/div>\n            <p class=\"courses-cta-title\">\n                <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-java-programming\" class=\"courses-cta-title-link\">Java Programming Course<\/a>\n            <\/p>\n            <p class=\"courses-cta-description\">Learn Java the right way! Our course teaches you essential programming skills, from coding basics to complex projects, setting you up for success in the tech industry.<\/p>\n            <div class=\"courses-cta-stats\">\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-user-icon\"><\/div>\n                    <span>16.05 Hrs<\/span>\n                <\/div>\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-star-icon\"><\/div>\n                    <span>3 Projects<\/span>\n                <\/div>\n            <\/div>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-java-programming\" class=\"courses-cta-button\">\n                Learn Java Programming\n                <div class=\"courses-arrow-icon\"><\/div>\n            <\/a>\n        <\/div>\n    <\/div>\n\n\n\n<p>Let's dive deep into these concepts and see how they work in Java!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"understanding-the-basics-of-oop\"><strong>Understanding the Basics of OOP<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-a-class\"><strong>What is a Class?<\/strong><\/h3>\n\n\n\n<p>A class is a blueprint for creating objects. It defines the attributes (data) and methods (behaviours) of the objects. Think of a class as a template.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Car {\n\n\u00a0\u00a0\u00a0\u00a0String brand;\n\n\u00a0\u00a0\u00a0\u00a0int speed;\n\n\u00a0\u00a0\u00a0\u00a0void drive() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(brand + &quot; is driving at &quot; + speed + &quot; km\/h.&quot;);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n\nHere, Car is a class with attributes brand and speed, and a behavior drive().\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-an-object\"><strong>What is an Object?<\/strong><\/h3>\n\n\n\n<p>An object is an instance of a class. It represents a specific entity with its own values for the defined attributes.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nCar myCar = new Car();\n\nmyCar.brand = &quot;Toyota&quot;;\n\nmyCar.speed = 120;\n\nmyCar.drive();\u00a0 \/\/ Output: Toyota is driving at 120 km\/h.\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"attributes-and-methods\"><strong>Attributes and Methods<\/strong><\/h3>\n\n\n\n<p>Attributes (fields) store data, while methods define actions an object can perform. The brand and speed in the example are attributes, and drive() is a method.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"first-pillar-of-oop-encapsulation\"><strong>First Pillar of OOP: Encapsulation<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"definition\"><strong>Definition:<\/strong><\/h3>\n\n\n\n<p>Encapsulation bundles all the data (attributes) and method (behaviours) which are related in their functionality and role are grouped together or packaged in a single entity or class. It also limits the direct input and output of object data and allows input and output only by means of <strong>getters <\/strong>and <strong>setters<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"benefits-of-encapsulation\"><strong>Benefits of Encapsulation:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Data Security<\/strong>: Protects information from being accessed by unauthorized personnel.<\/li>\n\n\n\n<li><strong>Flexibility<\/strong>: Enables change in the implementation aspect without any effect on the other part of the code.<\/li>\n\n\n\n<li><strong>Improved Maintenance<\/strong>: Facilitates first and foremost debugging and secondly, makes the code more comprehensible.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Person {\n\n\u00a0\u00a0\u00a0\u00a0private String name;\u00a0 \/\/ Private attribute\n\n\u00a0\u00a0\u00a0\u00a0private int age;\n\n\u00a0\u00a0\u00a0\u00a0\/\/ Getter for name\n\n\u00a0\u00a0\u00a0\u00a0public String getName() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return name;\n\n\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0\/\/ Setter for name\n\n\u00a0\u00a0\u00a0\u00a0public void setName(String name) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.name = name;\n\n\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0\/\/ Getter for age\n\n\u00a0\u00a0\u00a0\u00a0public int getAge() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return age;\n\n\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0\/\/ Setter for age\n\n\u00a0\u00a0\u00a0\u00a0public void setAge(int age) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (age &gt; 0) {\u00a0 \/\/ Validation\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.age = age;\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} else {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;Age must be positive.&quot;);\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<p><strong>Usage:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nPerson p = new Person();\n\np.setName(&quot;John&quot;);\n\np.setAge(25);\n\nSystem.out.println(p.getName() + &quot; is &quot; + p.getAge() + &quot; years old.&quot;);\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"second-pillar-of-oop-inheritance\"><strong>Second Pillar of OOP: Inheritance<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"definition\"><strong>Definition:<\/strong><\/h3>\n\n\n\n<p>Inheritance allows a class (child) to obtain its attributes and actions from another class (parent). It supports the <strong>reuse of code<\/strong> and also gives classes a well-defined relationship where one class is a specialized version of the other.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"benefits-of-inheritance\"><strong>Benefits of Inheritance:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Eliminates code redundancy.<\/li>\n\n\n\n<li>Enables hierarchical classifications.<\/li>\n\n\n\n<li>Facilitates the use of polymorphism.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n\/\/ Parent class\n\nclass Animal {\n\n\u00a0\u00a0\u00a0\u00a0void eat() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;This animal eats food.&quot;);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n\n\/\/ Child class\n\nclass Dog extends Animal {\n\n\u00a0\u00a0\u00a0\u00a0void bark() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;The dog barks.&quot;);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<p><strong>Usage:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nDog myDog = new Dog();\n\nmyDog.eat();\u00a0 \/\/ Output: This animal eats food.\n\nmyDog.bark(); \/\/ Output: The dog barks.\n<\/pre><\/div>\n\n\n<p>To learn more about this concept, check the <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/inheritance-in-java\">free inheritance in the Java course<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"third-pillar-of-oop-polymorphism\"><strong>Third Pillar of OOP: Polymorphism<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"definition\"><strong>Definition:<\/strong><\/h3>\n\n\n\n<p>Polymorphism allows objects to take multiple forms, enabling the same method to behave differently based on context. It is achieved through:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Compile-time Polymorphism (Method Overloading)<\/strong><\/li>\n\n\n\n<li><strong>Runtime Polymorphism (Method Overriding)<\/strong><\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-method-overloading-compile-time-polymorphism\"><strong>1. <a href=\"https:\/\/www.mygreatlearning.com\/blog\/method-overloading-in-java\/\">Method Overloading<\/a> (Compile-time Polymorphism):<\/strong><\/h3>\n\n\n\n<p>Allows methods with the same name but different parameter lists.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Calculator {\n\n\u00a0\u00a0\u00a0\u00a0int add(int a, int b) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return a + b;\n\n\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0double add(double a, double b) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return a + b;\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<p><strong>Usage:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nCalculator calc = new Calculator();\n\nSystem.out.println(calc.add(2, 3)); \u00a0 \u00a0 \u00a0 \/\/ Output: 5\n\nSystem.out.println(calc.add(2.5, 3.5)); \u00a0 \/\/ Output: 6.0\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"2-method-overriding-runtime-polymorphism\"><strong>2. Method Overriding (Runtime Polymorphism):<\/strong><\/h3>\n\n\n\n<p>Allows a subclass to provide a specific implementation of a method already defined in its superclass.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Animal {\n\n\u00a0\u00a0\u00a0\u00a0void sound() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;Some generic animal sound&quot;);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n\nclass Cat extends Animal {\n\n\u00a0\u00a0\u00a0\u00a0@Override\n\n\u00a0\u00a0\u00a0\u00a0void sound() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;Meow&quot;);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<p><strong>Usage:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nAnimal myAnimal = new Cat();\n\nmyAnimal.sound();\u00a0 \/\/ Output: Meow\n<\/pre><\/div>\n\n\n<p>Explore more about<a href=\"https:\/\/www.mygreatlearning.com\/blog\/polymorphism-in-java\/\"> <strong>Polymorphism in Java<\/strong><\/a> with this in-depth guide.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"fourth-pillar-of-oop-abstraction\"><strong>Fourth Pillar of OOP: Abstraction<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"definition\"><strong>Definition:<\/strong><\/h3>\n\n\n\n<p>Abstraction focuses on <strong>what an object does<\/strong> rather than <strong>how it does it.<\/strong> It hides implementation details and exposes only essential features.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"benefits-of-abstraction\"><strong>Benefits of Abstraction:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reduces complexity.<\/li>\n\n\n\n<li>Enhances maintainability.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"example-using-abstract-classes\"><strong>Example Using Abstract Classes:<\/strong><\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nabstract class Shape {\n\n\u00a0\u00a0\u00a0\u00a0abstract void draw();\u00a0 \/\/ Abstract method\n\n}\n\nclass Circle extends Shape {\n\n\u00a0\u00a0\u00a0\u00a0void draw() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;Drawing a Circle&quot;);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n\nclass Rectangle extends Shape {\n\n\u00a0\u00a0\u00a0\u00a0void draw() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;Drawing a Rectangle&quot;);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<p><strong>Usage:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nShape s1 = new Circle();\n\nShape s2 = new Rectangle();\n\ns1.draw();\u00a0 \/\/ Output: Drawing a Circle\n\ns2.draw();\u00a0 \/\/ Output: Drawing a Rectangle\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"building-blocks-in-java-oop\"><strong>Building Blocks in Java OOP<\/strong><\/h2>\n\n\n\n<p>Java's OOP features rely on several key building blocks that enhance the creation, organization, and visibility of objects and their behaviour.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-constructors-special-methods-to-initialize-objects\"><strong>1. Constructors: Special Methods to Initialize Objects<\/strong><\/h3>\n\n\n\n<p>A <a href=\"https:\/\/www.mygreatlearning.com\/blog\/constructor-in-java\/\">constructor<\/a> is a special method invoked when an object is created. It initializes the object and sets its state.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Features of Constructors:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The name of the constructor is the same as the class name.<\/li>\n\n\n\n<li>It does not have a return type.<\/li>\n\n\n\n<li>Constructors can be overloaded.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Car {\n\n\u00a0\u00a0\u00a0\u00a0String brand;\n\n\u00a0\u00a0\u00a0\u00a0int speed;\n\n\u00a0\u00a0\u00a0\u00a0\/\/ Constructor\n\n\u00a0\u00a0\u00a0\u00a0Car(String brand, int speed) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.brand = brand;\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.speed = speed;\n\n\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0void display() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;Brand: &quot; + brand + &quot;, Speed: &quot; + speed);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n\npublic class Main {\n\n\u00a0\u00a0\u00a0\u00a0public static void main(String&#x5B;] args) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Car myCar = new Car(&quot;Toyota&quot;, 120); \/\/ Constructor called\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0myCar.display(); \/\/ Output: Brand: Toyota, Speed: 120\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<p>Here, the constructor initializes brand and speed when the object myCar is created.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-this-keyword-refers-to-the-current-object\"><strong>2. this Keyword: Refers to the Current Object<\/strong><\/h3>\n\n\n\n<p>The this keyword is a reference to the current object and is used for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Resolving naming conflicts between class attributes and method parameters.<\/li>\n\n\n\n<li>Calling another constructor in the same class.<\/li>\n\n\n\n<li>Referring to the current object in a method or constructor.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Employee {\n\n\u00a0\u00a0\u00a0\u00a0String name;\n\n\u00a0\u00a0\u00a0\u00a0Employee(String name) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.name = name; \/\/ Refers to the class attribute\n\n\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0void display() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;Employee Name: &quot; + this.name);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"3-access-modifiers-control-the-visibility-of-attributes-and-methods\"><strong>3. Access Modifiers: Control the Visibility of Attributes and Methods<\/strong><\/h3>\n\n\n\n<p>Access modifiers define the scope of variables, methods, and classes. Java provides four types of access modifiers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Private:<\/strong> Accessible only within the class.<\/li>\n\n\n\n<li><strong>Default:<\/strong> Accessible within the same package.<\/li>\n\n\n\n<li><strong>Protected:<\/strong> Accessible within the package and by subclasses.<\/li>\n\n\n\n<li><strong>Public:<\/strong> Accessible from anywhere.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Example {\n\n\u00a0\u00a0\u00a0\u00a0private int privateValue = 10; \/\/ Private: restricted to this class\n\n\u00a0\u00a0\u00a0\u00a0public int publicValue = 20;\u00a0 \/\/ Public: accessible anywhere\n\n\u00a0\u00a0\u00a0\u00a0public int getPrivateValue() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return privateValue; \/\/ Controlled access via a public method\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<p>Learn more about <a href=\"https:\/\/www.mygreatlearning.com\/blog\/the-access-modifiers-in-java\/\"><strong>Access Modifiers in Java<\/strong><\/a> with this insightful guide.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-static-members-define-shared-variables-and-methods\"><strong>4. Static Members: Define Shared Variables and Methods<\/strong><\/h3>\n\n\n\n<p>The static keyword denotes that a field or method belongs to the class, not any specific instance. These are shared across all instances of the class.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nclass Counter {\n\n\u00a0\u00a0\u00a0\u00a0static int count = 0; \/\/ Static variable shared by all objects\n\n\u00a0\u00a0\u00a0\u00a0Counter() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0count++;\n\n\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0static void displayCount() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;Count: &quot; + count); \/\/ Static method accessing static field\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n\npublic class Main {\n\n\u00a0\u00a0\u00a0\u00a0public static void main(String&#x5B;] args) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0new Counter();\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0new Counter();\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Counter.displayCount(); \/\/ Output: Count: 2\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"advanced-oop-features\"><strong>Advanced OOP Features<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-interfaces-define-contracts-for-implementing-classes\"><strong>1. Interfaces: Define Contracts for Implementing Classes<\/strong><\/h3>\n\n\n\n<p>An <a href=\"https:\/\/www.mygreatlearning.com\/blog\/interface-in-java\/\">interface<\/a> is a blueprint of a class that contains abstract methods. Classes that implement an interface must provide implementations for its methods.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\ninterface Printable {\n\n\u00a0\u00a0\u00a0\u00a0void print(); \/\/ Abstract method\n\n}\n\nclass Document implements Printable {\n\n\u00a0\u00a0\u00a0\u00a0public void print() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;Printing Document...&quot;);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n\npublic class Main {\n\n\u00a0\u00a0\u00a0\u00a0public static void main(String&#x5B;] args) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Printable doc = new Document();\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0doc.print(); \/\/ Output: Printing Document...\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"2-inner-classes-enable-modular-organization\"><strong>2. Inner Classes: Enable Modular Organization<\/strong><\/h3>\n\n\n\n<p>Inner classes are defined within another class and can access its private members. They are used for better encapsulation and logical grouping.<\/p>\n\n\n\n<p><strong>Types of Inner Classes:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Member Inner Class<\/strong><\/li>\n\n\n\n<li><strong>Static Nested Class<\/strong><\/li>\n\n\n\n<li><strong>Local Inner Class<\/strong><\/li>\n\n\n\n<li><strong>Anonymous Inner Class<\/strong><\/li>\n<\/ol>\n\n\n\n<p><strong>Example of Member Inner Class:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nclass Outer {\n\n\u00a0\u00a0\u00a0\u00a0private String message = &quot;Hello from Outer class&quot;;\n\n\u00a0\u00a0\u00a0\u00a0class Inner {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0void display() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(message); \/\/ Accessing private member of Outer class\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n\npublic class Main {\n\n\u00a0\u00a0\u00a0\u00a0public static void main(String&#x5B;] args) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Outer outer = new Outer();\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Outer.Inner inner = outer.new Inner();\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0inner.display(); \/\/ Output: Hello from Outer class\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"3-anonymous-classes-simplify-short-lived-object-creation\"><strong>3. Anonymous Classes: Simplify Short-lived Object Creation<\/strong><\/h3>\n\n\n\n<p>Anonymous classes are unnamed inner classes, often used to override methods or provide specific functionality.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\ninterface Greeting {\n\n\u00a0\u00a0\u00a0\u00a0void sayHello();\n\n}\n\npublic class Main {\n\n\u00a0\u00a0\u00a0\u00a0public static void main(String&#x5B;] args) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Greeting greet = new Greeting() { \/\/ Anonymous class\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0public void sayHello() {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0System.out.println(&quot;Hello, Anonymous World!&quot;);\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0};\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0greet.sayHello(); \/\/ Output: Hello, Anonymous World!\n\n\u00a0\u00a0\u00a0\u00a0}\n\n}\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Java supports Object Oriented Programming (OOP) which gives developers the chance to build scalable, reusable and maintainable software. Being able to use classes, objects, inheritance, and polymorphism are basic, and advanced features such as interfaces and design patterns will enable you to make robust, efficient applications.<\/p>\n\n\n\n<p>OOP principles like encapsulation, abstraction and modularity help us handle complex problems by simplifying code and allowing us to manage and extend code. Experience of SOLID principles and design patterns will help you gain more experience.<\/p>\n\n\n\n<p>Mastering OOP is the key to building scalable and robust software. However, if you try to learn these advanced features without a plan, it can feel like trying to build a house without a blueprint. The best way to turn these abstract concepts into real-world skill is with a hands-on start. To build your expertise the right way, join our <strong><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/java-programming\" target=\"_blank\" rel=\"noreferrer noopener\">free Java Course<\/a><\/strong>. It is the easiest way for absolute beginners to go from zero experience to a pro with a clear, step-by-step path.<\/p>\n\n\n\n<p>To enhance your skills further, check out the<a href=\"https:\/\/www.mygreatlearning.com\/academy\"> free programming courses<\/a> that can help you build a solid foundation for your development journey.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faqs-on-oop-concepts-in-java\"><strong>FAQs on OOP Concepts in Java<\/strong><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1733378167739\"><strong class=\"schema-faq-question\"><strong>1. What is the difference between a class and an object in Java?<\/strong><\/strong> <p class=\"schema-faq-answer\">A class is a blueprint or template that defines the properties and behaviors of a type. An object is an instance of a class that holds specific values for the properties defined by the class.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1733378176651\"><strong class=\"schema-faq-question\"><strong>2. Why is the static keyword important in Java OOP?<\/strong><\/strong> <p class=\"schema-faq-answer\">The static keyword signifies that a field or method belongs to the class rather than any individual object. This allows shared access to the field or method across all instances of the class.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1733378187280\"><strong class=\"schema-faq-question\"><strong>3. What is the main difference between method overloading and method overriding?<\/strong><\/strong> <p class=\"schema-faq-answer\"><strong>Method Overloading:<\/strong> Occurs within the same class and involves methods with the same name but different parameter lists.<br\/><strong>Method Overriding:<\/strong> Happens between a superclass and a subclass where a method in the subclass has the same signature as a method in the superclass.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1733378203787\"><strong class=\"schema-faq-question\"><strong>4. How does Java implement abstraction?<\/strong><\/strong> <p class=\"schema-faq-answer\">Java achieves abstraction using abstract classes and interfaces. Abstract classes can have both abstract methods and implemented methods, while interfaces define a contract that implementing classes must follow.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1733378210428\"><strong class=\"schema-faq-question\"><strong>5. What is encapsulation, and why is it important?<\/strong><\/strong> <p class=\"schema-faq-answer\">Encapsulation is the practice of restricting direct access to a class's fields and methods, usually by using private access modifiers and providing public getter and setter methods. This ensures data security and control over how the data is modified.<\/p> <\/div> <\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"\"><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>Learn Object-Oriented Programming (OOP) in Java effortlessly! This guide covers key topics like classes, methods, inheritance, and abstraction with easy-to-follow examples for real-world applications.<\/p>\n","protected":false},"author":41,"featured_media":24681,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36826],"content_type":[36252],"class_list":["post-24671","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-java","content_type-tutorials"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>OOPs Concepts in Java with Examples<\/title>\n<meta name=\"description\" content=\"OOPs Concepts in Java: In this blog, we will learn more about OOPS concepts in Java. These aim to implement real-world entities in programs.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mastering OOP Concepts in Java with Examples\" \/>\n<meta property=\"og:description\" content=\"OOPs Concepts in Java: In this blog, we will learn more about OOPS concepts in Java. These aim to implement real-world entities in programs.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-15T04:42:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-06T13:41:16+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1198\" \/>\n\t<meta property=\"og:image:height\" content=\"876\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Mastering OOP Concepts in Java with Examples\",\"datePublished\":\"2023-05-15T04:42:34+00:00\",\"dateModified\":\"2025-01-06T13:41:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/\"},\"wordCount\":1249,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/iStock-518002738.jpg\",\"keywords\":[\"java\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/\",\"name\":\"OOPs Concepts in Java with Examples\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/iStock-518002738.jpg\",\"datePublished\":\"2023-05-15T04:42:34+00:00\",\"dateModified\":\"2025-01-06T13:41:16+00:00\",\"description\":\"OOPs Concepts in Java: In this blog, we will learn more about OOPS concepts in Java. These aim to implement real-world entities in programs.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378167739\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378176651\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378187280\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378203787\"},{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378210428\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/iStock-518002738.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/iStock-518002738.jpg\",\"width\":1198,\"height\":876,\"caption\":\"OOPS concepts in Java\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Mastering OOP Concepts in Java with Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378167739\",\"position\":1,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378167739\",\"name\":\"1. What is the difference between a class and an object in Java?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"A class is a blueprint or template that defines the properties and behaviors of a type. An object is an instance of a class that holds specific values for the properties defined by the class.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378176651\",\"position\":2,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378176651\",\"name\":\"2. Why is the static keyword important in Java OOP?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"The static keyword signifies that a field or method belongs to the class rather than any individual object. This allows shared access to the field or method across all instances of the class.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378187280\",\"position\":3,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378187280\",\"name\":\"3. What is the main difference between method overloading and method overriding?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"<strong>Method Overloading:<\\\/strong> Occurs within the same class and involves methods with the same name but different parameter lists.<br\\\/><strong>Method Overriding:<\\\/strong> Happens between a superclass and a subclass where a method in the subclass has the same signature as a method in the superclass.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378203787\",\"position\":4,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378203787\",\"name\":\"4. How does Java implement abstraction?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Java achieves abstraction using abstract classes and interfaces. Abstract classes can have both abstract methods and implemented methods, while interfaces define a contract that implementing classes must follow.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378210428\",\"position\":5,\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/oops-concepts-in-java\\\/#faq-question-1733378210428\",\"name\":\"5. What is encapsulation, and why is it important?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Encapsulation is the practice of restricting direct access to a class's fields and methods, usually by using private access modifiers and providing public getter and setter methods. This ensures data security and control over how the data is modified.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"OOPs Concepts in Java with Examples","description":"OOPs Concepts in Java: In this blog, we will learn more about OOPS concepts in Java. These aim to implement real-world entities in programs.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/","og_locale":"en_US","og_type":"article","og_title":"Mastering OOP Concepts in Java with Examples","og_description":"OOPs Concepts in Java: In this blog, we will learn more about OOPS concepts in Java. These aim to implement real-world entities in programs.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2023-05-15T04:42:34+00:00","article_modified_time":"2025-01-06T13:41:16+00:00","og_image":[{"width":1198,"height":876,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Mastering OOP Concepts in Java with Examples","datePublished":"2023-05-15T04:42:34+00:00","dateModified":"2025-01-06T13:41:16+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/"},"wordCount":1249,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg","keywords":["java"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/","url":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/","name":"OOPs Concepts in Java with Examples","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg","datePublished":"2023-05-15T04:42:34+00:00","dateModified":"2025-01-06T13:41:16+00:00","description":"OOPs Concepts in Java: In this blog, we will learn more about OOPS concepts in Java. These aim to implement real-world entities in programs.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378167739"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378176651"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378187280"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378203787"},{"@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378210428"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg","width":1198,"height":876,"caption":"OOPS concepts in Java"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"Mastering OOP Concepts in Java with Examples"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378167739","position":1,"url":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378167739","name":"1. What is the difference between a class and an object in Java?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"A class is a blueprint or template that defines the properties and behaviors of a type. An object is an instance of a class that holds specific values for the properties defined by the class.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378176651","position":2,"url":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378176651","name":"2. Why is the static keyword important in Java OOP?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"The static keyword signifies that a field or method belongs to the class rather than any individual object. This allows shared access to the field or method across all instances of the class.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378187280","position":3,"url":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378187280","name":"3. What is the main difference between method overloading and method overriding?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"<strong>Method Overloading:<\/strong> Occurs within the same class and involves methods with the same name but different parameter lists.<br\/><strong>Method Overriding:<\/strong> Happens between a superclass and a subclass where a method in the subclass has the same signature as a method in the superclass.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378203787","position":4,"url":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378203787","name":"4. How does Java implement abstraction?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Java achieves abstraction using abstract classes and interfaces. Abstract classes can have both abstract methods and implemented methods, while interfaces define a contract that implementing classes must follow.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378210428","position":5,"url":"https:\/\/www.mygreatlearning.com\/blog\/oops-concepts-in-java\/#faq-question-1733378210428","name":"5. What is encapsulation, and why is it important?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Encapsulation is the practice of restricting direct access to a class's fields and methods, usually by using private access modifiers and providing public getter and setter methods. This ensures data security and control over how the data is modified.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg",1198,876,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738-300x219.jpg",300,219,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738-768x562.jpg",768,562,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738-1024x749.jpg",1024,749,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg",1198,876,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg",1198,876,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg",640,468,false],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg",96,70,false],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/01\/iStock-518002738.jpg",150,110,false]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":1,"uagb_excerpt":"Learn Object-Oriented Programming (OOP) in Java effortlessly! This guide covers key topics like classes, methods, inheritance, and abstraction with easy-to-follow examples for real-world applications.","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/24671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=24671"}],"version-history":[{"count":128,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/24671\/revisions"}],"predecessor-version":[{"id":110405,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/24671\/revisions\/110405"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/24681"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=24671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=24671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=24671"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=24671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}