

{"id":6263,"date":"2018-01-23T04:16:23","date_gmt":"2018-01-22T22:46:23","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=6263"},"modified":"2026-05-16T17:59:35","modified_gmt":"2026-05-16T12:29:35","slug":"java-class-and-object","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/","title":{"rendered":"Classes and Objects in Java &#8211; Fundamentals of OOPs"},"content":{"rendered":"<p>One of the main challenges that programmers face while writing code is that, while writing lengthy code, the code becomes haphazard and unorganized. It becomes very difficult to debug and look for errors while checking them line by line. Here comes the concept of OOPs programming, which basically helps the programmer properly organize the program. However, we will learn about classes and objects in Java, polymorphism, inheritance, encapsulation, and abstraction in Java.<\/p>\n<h3>What are OOPs?<\/h3>\n<p>OOPs stands for Object-Oriented Programming. As we all know, Java is an object-oriented programming language. OOPs programming language tries to map our code with real-world entities like objects, methods, inheritance, abstraction, etc, making the code short and easier to understand. OOPs also makes our programs easier to maintain and debug.<\/p>\n<p><strong>Advantages of Using OOPs in Java:<\/strong><\/p>\n<ul>\n<li><strong>Reusability of code(DRY[Don\u2019t Repeat Yourself] principle):<\/strong> OOPs concepts like inheritance simplify the work in a way that previously written code can be used again by other classes &amp; in other programs.<\/li>\n<li><strong>Data Hiding:<\/strong> Abstraction is useful in terms of hiding the data. It showcases only the required information.<\/li>\n<li><strong>Privacy and Security of our code:<\/strong> It is achieved using access modifiers to maintain the integrity of the data.<\/li>\n<li><strong>Low Maintenance cost:<\/strong> The oops principle has the benefit of easy debugging of the code, and reusing the code, which results in overall low maintenance of the application.<\/li>\n<li><strong>High Readability:<\/strong> Hierarchical presentation of the code by using inheritance makes it more readable. Also, packing up the data using encapsulation increases the readability of a program.<\/li>\n<\/ul>\n<p><strong>Main Principles of OOPs in Java<\/strong><\/p>\n<p><strong>OOPs mainly consists of 6 principles:<\/strong><\/p>\n<ul>\n<li>Class<\/li>\n<li>Object<\/li>\n<li>Abstraction<\/li>\n<li>Inheritance<\/li>\n<li>Polymorphism<\/li>\n<li>Encapsulation<\/li>\n<\/ul>\n<p>There are a few other sub-principles of OOP that we will discuss at the end. They include:<\/p>\n<ul>\n<li>Coupling<\/li>\n<li>Cohesion<\/li>\n<li>Association<\/li>\n<li>Aggregation<\/li>\n<li>Composition<\/li>\n<\/ul>\n<p><strong>Let Us Discuss Each Principle One by One:<\/strong><\/p>\n<h3>Classes in Java<\/h3>\n<p>A Java class is a logical entity or blueprint from which objects can be created. A class can be described as a group of objects having common properties. Classes in Java contain: Fields, Methods, Constructors, Blocks, Nested Classes, and interfaces.<\/p>\n<p><strong>Syntax of a Class in Java:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">class &lt;class name&gt;{\r\n\/\/Statements\r\n}\r\n<\/pre>\n<h3>Objects in Java<\/h3>\n<p>An object in Java is a real-life entity of a class. A class is a logical entity, whereas an object is a physical entity. A class is defined as a template or blueprint; it is only when an object is declared that memory is assigned to the program. An object has a proper state and behaviour. Objects are also known as instances of a class.<\/p>\n<p><strong>Syntax of a Java object:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;Class name&gt; &lt;Object name&gt;= new &lt;class name&gt;();\r\n<\/pre>\n<p>Let us understand the relationship between classes and objects with a real-world example:<\/p>\n<p>Suppose a student is filling out an application form for an internship, he will fill out the form and send it to the company. Here, the application form is the class that contains fields like name, age, gender, etc., which are the contents of the class. After the student fills the form, the final application of the student is known as the object.<\/p>\n<p><strong>Program to understand objects and classes in Java:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.OOPS;\r\npublic class Internshipform\r\n{\r\n  String Name;\r\n  int Age;\r\n  String Gender;\r\n  Internshipform(String name, int age,String gender) {\r\n    this.Name = name;\r\n    this.Age = age;\r\n    this.Gender = gender;\r\n  }\r\n  public static void main(String args[]) {\r\n    Internshipform obj1 = new Internshipform(\"Arka Ghosh\", 21, \"Male\");\r\n    Internshipform obj2 = new Internshipform(\"Aradhya Sarkar\", 22, \"Female\");\r\n    System.out.println(\"Name: \" + obj1.Name);\r\n    System.out.println(\"Age: \" + obj1.Age);\r\n    System.out.println(\"Gender: \"+obj1.Gender);\r\n    System.out.println(\"Name: \" + obj2.Name);\r\n    System.out.println(\"Age: \" + obj2.Age);\r\n    System.out.println(\"Gender: \"+obj2.Gender);\r\n  }\r\n}\r\n<\/pre>\n<p><strong>The output of the above Code:<\/strong><\/p>\n<div class=\"code-output\">Name: Arka Ghosh<br \/>\nAge: 21<br \/>\nGender: Male<br \/>\nName: Aradhya Sarkar<br \/>\nAge: 22<br \/>\nGender: Female<\/div>\n<h3>Abstraction in Java<\/h3>\n<p>Abstraction is the process of hiding implementation details from the end-user. In a programming language, we use a predefined object or previously created objects in another program without caring what that object contains; we only care about what it does. This type of implementation is known as abstraction.<\/p>\n<h4>Real-World Example of Java Abstraction<\/h4>\n<p>We use mobile phones or smartphones to perform various tasks in our day-to-day lives. Each application on the phone performs a specific task. We, as users, only care about what the application does, rather than focusing on how it does the task. This is known as abstraction.<\/p>\n<p><strong>In Java, we can achieve abstraction through two processes:<\/strong><\/p>\n<ul>\n<li>Abstract Class[Partial Abstraction]<\/li>\n<li>Interface[Complete Abstraction]<\/li>\n<\/ul>\n<p>Let us take a look at them individually:<\/p>\n<h4>Java Abstract Class<\/h4>\n<p>A Java class with the keyword abstract in front of it is known as an abstract class. Th, it can have both abstract and non-abstract methods. It cannot be initiated like other methods. The abstract methods in Java need to be extended and implemented. We can achieve partial abstraction with abstract classes.<\/p>\n<p><strong>Program to illustrate Abstract Class in Java:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.OOPS;\r\nabstract class Internship\r\n{\r\n  abstract void success();  \r\n}  \r\npublic class Status extends Internship{  \r\nvoid success(){\r\n    System.out.println(\"You Have Successfully Applied for the Internship!\");\r\n}  \r\npublic static void main(String[] args){  \r\n Internship obj = new Status();  \r\n obj.success();  \r\n}  \r\n}\r\n<\/pre>\n<p><strong>The output of the above Program:<\/strong><\/p>\n<div class=\"code-output\">You Have Successfully Applied for the Internship!<\/div>\n<h4>Java Interface<\/h4>\n<p>As we know, a class is a blueprint of a program; similarly, the blueprint of a class is known as an interface. Unlike abstract classes, interfaces cannot have normal methods; they only have abstract methods. Thus, interfaces provide complete abstraction, unlike abstract classes.<\/p>\n<p><strong>Program to Illustrate Interface in Java:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.OOPS;\r\ninterface Internship\r\n{\r\n    void print();\r\n}\r\npublic class StatusofInternship implements Internship{  \r\npublic void print(){System.out.println(\"You Have Successfully Applied for the Internship!\");\r\n}  \r\npublic static void main(String args[]){  \r\nStatusofInternship obj = new StatusofInternship();  \r\nobj.print();  \r\n }  \r\n}  \r\n<\/pre>\n<p><strong>The output of the above Program:<\/strong><\/p>\n<div class=\"code-output\">You Have Successfully Applied for the Internship!<\/div>\n<h3>Inheritance in Java<\/h3>\n<p>Inheritance, as the name suggests, is the act of inheriting properties of the previously declared class. The class from which the properties are inherited is known as the parent class or superclass, and the classes that derive from the main class are known as subclasses or child classes. Although Inheritance uses the DRY principle. Therefore, it is the act of deriving new things from previously existing things.<\/p>\n<h4>Real-World Example of Java Inheritance<\/h4>\n<p>Phones were invented a long time ago, but they could only be used to communicate with others. In recent times, these phones have been replaced by smartphones, which inherited the properties of those phones and added new and improved features to them.<\/p>\n<h4>Types of Inheritance in Java<\/h4>\n<p><strong>Program of Java Inheritance:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.OOPS;\r\npublic class Intern\r\n{ \r\n String name=\"Arka Ghosh\";\r\n}\r\npublic class Role extends Intern\r\n{\r\n    String Job=\"Technical Writer\";\r\n    String Lang=\"JAVA\";\r\n    void main(String[] args)\r\n   {  \r\n      Topic t=new Topic();  \r\n      System.out.println(\"Intern Name: \"+t.name);  \r\n       System.out.println(\"Intern Role: \"+t.Job+\" in \"+t.Lang);   \r\n   }\r\n}\r\n<\/pre>\n<p><strong>The output of the above program:<\/strong><\/p>\n<div class=\"code-output\">Intern Name: Arka Ghosh<br \/>\nIntern Role: Technical Writer in JAVA<\/div>\n<h3>Encapsulation in Java<\/h3>\n<p>The wrapping up of data into a single entity, for example, a class, is known as encapsulation. However, it is the act of putting various entities together. Therefore, in Java, encapsulation helps to keep the sensitive data hidden from the users.<\/p>\n<h4>Real-world example of encapsulation in Java<\/h4>\n<p>Let us consider the laptop to be a single entity. A laptop contains a speaker, Keyboard, Mouse(Trackpad), wifi, etc. Although we can say that all these components are encapsulated into a single device known as a laptop.<\/p>\n<p>Encapsulation can be done by making all the data members of a class private. Thus, the class is then provided with a setter and getter method to set and get the data. Therefore, A Java Bean class is an example of an encapsulated class. As a result, Encapsulation provides control over data, data hiding, better unit testing, and easy and fast creation.<\/p>\n<p><strong>Program to Illustrate Encapsulation in Java:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Encapsulated Class:\r\npackage com.DataFlair.OOPS;\r\npublic class Interns\r\n{  \r\nprivate String name;   \r\npublic String getName(){  \r\nreturn name;  \r\n} \r\npublic void setName(String name){  \r\nthis.name=name;\r\n}  \r\n}\r\nAccess Class:\r\npackage com.DataFlair.OOPS;\r\npublic class AssignIntern\r\n{\r\n    public static void main(String[] args)\r\n    {   \r\n     Interns I=new Interns();  \r\n     I.setName(\"Arka Ghosh\");  \r\n     System.out.println(I.getName());  \r\n}  \r\n}\r\n<\/pre>\n<p><strong>The output of the above program:<\/strong><\/p>\n<div class=\"code-output\">Arka Ghosh<\/div>\n<h3>Polymorphism in Java<\/h3>\n<p>Polymorphism means many forms. In Java, polymorphism can be achieved using method overloading and method overriding. When a method has the same name but differs in either return type or parameter list, they are known as an overloaded function and is an example of polymorphism.<\/p>\n<p>Although there are two types of polymorphism in Java, namely, compile-time polymorphism and runtime polymorphism.<\/p>\n<h4>Real-world example of Java Polymorphism<\/h4>\n<p>A smartphone can be used as a phone to make calls, and it can also be used as a calculator. Hence, we can see that the entity is the same, but the function differs; this is known as Polymorphism.<\/p>\n<p><strong>Program Illustrating Polymorphism in Java<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.DataFlair.OOPS;\r\npublic class Polymorphism\r\n{\r\n    void area(int r)\r\n    {\r\n        double a=3.14*r*r;\r\n        System.out.println(\"The area of the Circle is: \"+a);\r\n    }\r\n    void area(int l, int b)\r\n    {\r\n        int a= l*b;\r\n        System.out.println(\"The area of the rectangle is: \"+a);\r\n    }\r\n    public static void main(String[] args)\r\n    {\r\n        Polymorphism a = new Polymorphism();\r\n        a.area(5);\r\n        a.area(2,3);\r\n    }\r\n}\r\n<\/pre>\n<p><strong>The output of the above program:<\/strong><\/p>\n<div class=\"code-output\">The area of the Circle is: 78.5<br \/>\nThe area of the rectangle is: 6<\/div>\n<p>A few of the other important terms included in the OOPs Principle are discussed below:<\/p>\n<h3>Java Coupling<\/h3>\n<p>Coupling in Java refers to the access to information that one class has on the other. If a class can access all the information of another class, then the classes are known to be strongly coupled. However, there are access modifiers to modify the access to the information a class gives by adding public, private, or protected. For weaker coupling, interfaces can be used, as there is no proper implementation.<\/p>\n<h3>Cohesion in Java<\/h3>\n<p>The level of an entity that performs a single well-defined task is known as cohesion. When an entity performs a single well-defined task on its own, the entity is said to be highly cohesive. Hence, weakly cohesive entities will split the task. The java.io package is highly cohesive, as it has I\/O related classes and interfaces only. The java.util package is an example of a weakly cohesive entity, as it has unrelated classes and interfaces.<\/p>\n<h3>Association in Java<\/h3>\n<p>Association is the relation between the objects and how they are mapped inside the program. Similar to, functions in mathematics, object mapping can also be done in four ways:<\/p>\n<ul>\n<li>One to one<\/li>\n<li>One to many<\/li>\n<li>Many to one<\/li>\n<li>Many to many<\/li>\n<\/ul>\n<p>Association can be unidirectional as well as bidirectional.<\/p>\n<h3>Java Aggregation<\/h3>\n<p>Aggregation represents the weak relationship between two objects. It can be termed as a has-a relationship in Java, just like inheritance, which represents the is-a relationship. Therefore, Aggregation is basically another way to reuse objects. Therefore, aggregation is a way to achieve association.<\/p>\n<h3>Composition in Java<\/h3>\n<p>Composition represents a strong relationship between the containing object and the dependent object. It is a process where the containing object does not have an independent existence. If the dependent object is deleted, the containing object will also be automatically deleted. It is also another way to achieve association.<\/p>\n<h3>Advantages of OOPs over Procedural Programming Language<\/h3>\n<p>Programmers have shifted to OOPs programming; there must be a reason behind that. Let us see why OOPs programming has a clear advantage over procedural programming languages.<\/p>\n<p>1. OOPs provide an organized way to access and debug a program, thus making maintaining the program easier. However, in procedural programming, each line has to be debugged separately to look for errors, which sometimes becomes too chaotic.<\/p>\n<p>2. It provides security and protection to our data by hiding data using abstraction, encapsulation, etc. Therefore, Procedural Programming doesn\u2019t have such provisions.<\/p>\n<p>3. OOPs can be used to simulate real-life problems and thus can help solve those problems through different algorithms. With Procedural language, this is impossible to achieve.<\/p>\n<h3>Conclusion<\/h3>\n<p>In this article, we saw why OOPs took over the programming world and helped us solve different issues. However, we discussed each and every terminology of OOPs with real-life examples to make it easier for everyone to understand the importance of OOPs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the main challenges that programmers face while writing code is that, while writing lengthy code, the code becomes haphazard and unorganized. It becomes very difficult to debug and look for errors while&#46;&#46;&#46;<\/p>\n","protected":false},"author":7,"featured_media":108844,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[720,22413,2806,2817,6836,7422,7423,15775,15776,15785],"class_list":["post-6263","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-anonymous-objects-in-java","tag-classes-and-objects-in-java","tag-components-of-class","tag-components-of-objects","tag-instantiating-a-class-in-java","tag-java-class-and-object-with-examples","tag-java-class-vs-object","tag-what-is-java-class","tag-what-is-java-class-and-object","tag-what-is-java-object"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Classes and Objects in Java - Fundamentals of OOPs - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn about OOPs concepts in Java. See Classes &amp; objects in Java with example. Also see polymorphism, inheritance, encapsulation, abstraction\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/java-class-and-object\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Classes and Objects in Java - Fundamentals of OOPs - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn about OOPs concepts in Java. See Classes &amp; objects in Java with example. Also see polymorphism, inheritance, encapsulation, abstraction\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/java-class-and-object\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-22T22:46:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-16T12:29:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/java-oop.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Classes and Objects in Java - Fundamentals of OOPs - DataFlair","description":"Learn about OOPs concepts in Java. See Classes & objects in Java with example. Also see polymorphism, inheritance, encapsulation, abstraction","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:\/\/data-flair.training\/blogs\/java-class-and-object\/","og_locale":"en_US","og_type":"article","og_title":"Classes and Objects in Java - Fundamentals of OOPs - DataFlair","og_description":"Learn about OOPs concepts in Java. See Classes & objects in Java with example. Also see polymorphism, inheritance, encapsulation, abstraction","og_url":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-01-22T22:46:23+00:00","article_modified_time":"2026-05-16T12:29:35+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/java-oop.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd"},"headline":"Classes and Objects in Java &#8211; Fundamentals of OOPs","datePublished":"2018-01-22T22:46:23+00:00","dateModified":"2026-05-16T12:29:35+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/"},"wordCount":1718,"commentCount":4,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/java-oop.jpg","keywords":["Anonymous objects in Java","Classes and Objects in Java","components of class","components of objects","Instantiating a class in Java","java class and object with examples","Java class vs object","what is java class","What is Java class and object","what is java object"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/java-class-and-object\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/","url":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/","name":"Classes and Objects in Java - Fundamentals of OOPs - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/java-oop.jpg","datePublished":"2018-01-22T22:46:23+00:00","dateModified":"2026-05-16T12:29:35+00:00","description":"Learn about OOPs concepts in Java. See Classes & objects in Java with example. Also see polymorphism, inheritance, encapsulation, abstraction","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/java-class-and-object\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/java-oop.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/java-oop.jpg","width":1200,"height":628,"caption":"java oop"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/java-class-and-object\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"Classes and Objects in Java &#8211; Fundamentals of OOPs"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team specializes in creating clear, actionable content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Backed by industry expertise, we make learning easy and career-oriented for beginners and pros alike.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam3\/"}]}},"amp_enabled":false,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/6263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=6263"}],"version-history":[{"count":22,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/6263\/revisions"}],"predecessor-version":[{"id":148308,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/6263\/revisions\/148308"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/108844"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=6263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=6263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=6263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}