{"id":333,"date":"2020-01-22T07:28:34","date_gmt":"2020-01-22T07:28:34","guid":{"rendered":"http:\/\/lotusithub.com\/blog\/?p=333"},"modified":"2020-01-22T07:28:34","modified_gmt":"2020-01-22T07:28:34","slug":"learn-oops-all-java-concept-at-lotuithub","status":"publish","type":"post","link":"https:\/\/lotusithub.com\/blog\/learn-oops-all-java-concept-at-lotuithub\/","title":{"rendered":"Learn OOPs &#038; All Java Concept At LotuITHub?"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">In the interview, the usual question you face is regarding \u201cObject-Oriented Programming\u201d (OOP) which is associated with concepts like class, object, inheritance, encapsulation, abstraction, polymorphism, etc. <\/span><\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-357 size-full\" src=\"https:\/\/growbizzserver.in\/lotusithub\/blog\/wp-content\/uploads\/2020\/01\/Learn-OOPs-All-Java-Concept-At-LotuITHub.png\" alt=\"Learn OOPs &amp; All Java Concept At LotuITHub\" width=\"810\" height=\"450\" srcset=\"https:\/\/lotusithub.com\/blog\/wp-content\/uploads\/2020\/01\/Learn-OOPs-All-Java-Concept-At-LotuITHub.png 810w, https:\/\/lotusithub.com\/blog\/wp-content\/uploads\/2020\/01\/Learn-OOPs-All-Java-Concept-At-LotuITHub-300x167.png 300w, https:\/\/lotusithub.com\/blog\/wp-content\/uploads\/2020\/01\/Learn-OOPs-All-Java-Concept-At-LotuITHub-768x427.png 768w, https:\/\/lotusithub.com\/blog\/wp-content\/uploads\/2020\/01\/Learn-OOPs-All-Java-Concept-At-LotuITHub-585x325.png 585w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Java is one of the sought-after languages for beginners and professionals also. But the heck is for what classes, objects and methods are used? Why do we need inheritance and polymorphism? and more. At <\/span><a href=\"https:\/\/lotusithub.com\/java-training-in-pune.html\"><b>Java classes in Pune<\/b><\/a><span style=\"font-weight: 400;\">, an aspirant can learn everything about the OOPs, in detail.<\/span><\/p>\n<ul>\n<li>\n<h2><b>Inheritance<\/b><\/h2>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">In the Inheritance class properties of one class can be inherited by the other where reuse of code is possible to establish relationships between different classes. As we know in the biological system due to DNA child inherits some of the parent properties. Similarly, here \u201cChild Class\u201d (Subclass or derived class) inherits the properties from the \u201cParent Class\u201d (Super or base class), inheritance is further classified into four types:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let\u2019s understand the concept with examples, where, Class A is your parent class and Class B is your child class<\/span><\/p>\n<ol>\n<li><b><\/b><b> \u00a0 \u00a0 \u00a0 <\/b><b>Single Inheritance<\/b><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Example<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Class A<\/span> <span style=\"font-weight: 400;\">{&#8212;}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Class B extends A {&#8212;}<\/span><\/p>\n<ol start=\"2\">\n<li><b><\/b><b> \u00a0 \u00a0 \u00a0 <\/b><b>Multilevel Inheritance<\/b><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Please find the example below, where, A is the parent class for B and class B is the parent class for C.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Example<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Class A {&#8212;}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Class B extends A {&#8212;}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Class C extends B {&#8212;}<\/span><\/p>\n<ol start=\"3\">\n<li><b><\/b><b> \u00a0 \u00a0 \u00a0 <\/b><b>Hierarchical Inheritance<\/b><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Please find the example below, where, Class B and C are the child classes that are inheriting from the parent class i.e Class A.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Class A {&#8212;}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Class B extends A {&#8212;}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Class C extends A {&#8212;}<\/span><\/p>\n<ol start=\"4\">\n<li><b><\/b><b> \u00a0 \u00a0 \u00a0 <\/b><b>Hybrid Inheritance<\/b><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Class A and B extends class C \u2192 Hierarchical inheritance<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Class D extends class A \u2192 Single inheritance<\/span><\/p>\n<p><span style=\"font-weight: 400;\">class C {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0public void disp() {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">System.out.println(&#8220;C&#8221;);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0}}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">class A extends C{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0public void disp(){<\/span><\/p>\n<p><span style=\"font-weight: 400;\">System.out.println(&#8220;A&#8221;);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">class B extends C{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0public void disp(){<\/span><\/p>\n<p><span style=\"font-weight: 400;\">System.out.println(&#8220;B&#8221;);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0}}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">class D extends A{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0public void disp(){<\/span><\/p>\n<p><span style=\"font-weight: 400;\">System.out.println(&#8220;D&#8221;);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0public static void main(String args[]){<\/span><\/p>\n<p><span style=\"font-weight: 400;\">D obj = new D();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">obj.disp();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}}<\/span><\/p>\n<ul>\n<li>\n<h2><b>Encapsulation<\/b><\/h2>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">We can achieve encapsulation in Java by:<\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400;\"> Variable of the class are private.<\/span><\/li>\n<li><span style=\"font-weight: 400;\"> Public setter and getter methods are defined to modify and view the variable\u2019s values.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Example<\/span><\/p>\n<p><span style=\"font-weight: 400;\">public class Employee {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0private String name;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0public String getName() {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0return name;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0public void setName(String name) {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0this.name = name;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0public static void main(String[] args) {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0}}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n<ul>\n<li>\n<h2><b>Abstraction<\/b><\/h2>\n<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">At<\/span><b> Java coaching classes in Pune<\/b><span style=\"font-weight: 400;\">, an aspirant will learn the abstraction concept of Java programming in two ways:<\/span><\/p>\n<ol>\n<li><b><\/b><b> \u00a0 \u00a0 \u00a0 <\/b><b>Abstract Class<\/b><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">For the abstraction, you need to inherit the class from another class<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The syntax of an abstract class:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Abstract class Mobile { \u00a0 \/\/ abstract class mobile<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Abstract void run();\u00a0 \u00a0 \u00a0 \/\/ abstract method<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><\/p>\n<ol start=\"2\">\n<li><b><\/b><b> \u00a0 \u00a0 \u00a0 <\/b><b>Interface<\/b><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">In the abstraction class, an interface is a group of related methods with empty bodies.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Example<\/span><\/p>\n<p><span style=\"font-weight: 400;\">public interface ParentCar {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">public void changeGear( int newValue);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">public void speedUp(int increment);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">public void applyBrakes(int decrement);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}<\/span><\/p>\n<ul>\n<li>\n<h2><b>Polymorphism<\/b><\/h2>\n<\/li>\n<\/ul>\n<p><b><a href=\"https:\/\/lotusithub.com\/java-training-in-pune.html\">Java training institutes in Pune<\/a> <\/b><span style=\"font-weight: 400;\">is the best place to understand the keen concepts of Java programming with real-life examples. Polymorphism defines one interface or method with multiple implementations.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Polymorphism in Java is of two types:<\/span><\/p>\n<ol>\n<li><b><\/b><b> \u00a0 \u00a0 \u00a0 <\/b><b>Runtime polymorphism<\/b><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Example<\/span><\/p>\n<p><span style=\"font-weight: 400;\">public Class BowlerClass{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">void bowlingMethod(){<\/span><\/p>\n<p><span style=\"font-weight: 400;\">System.out.println(&#8221; bowler &#8220;);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">public Class FastPacer{<\/span><\/p>\n<p><span style=\"font-weight: 400;\">void bowlingMethod(){<\/span><\/p>\n<p><span style=\"font-weight: 400;\">System.out.println(&#8221; fast bowler &#8220;);<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Public static void main(String[] args){<\/span><\/p>\n<p><span style=\"font-weight: 400;\">FastPacer obj= new FastPacer();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">obj.bowlingMethod();<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}}<\/span><\/p>\n<ol start=\"2\">\n<li><b><\/b><b> \u00a0 \u00a0 \u00a0 <\/b><b>Compile time polymorphism<\/b><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">Example<\/span><\/p>\n<p><span style=\"font-weight: 400;\">class Adder {<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Static int add(int a, int b){<\/span><\/p>\n<p><span style=\"font-weight: 400;\">return a+b;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">static double add( double a, double b){<\/span><\/p>\n<p><span style=\"font-weight: 400;\">return a+b;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}<\/span><\/p>\n<p><span style=\"font-weight: 400;\">public static void main(String args[]){<\/span><\/p>\n<p><span style=\"font-weight: 400;\">System.out.println(Adder.add(11,11));<\/span><\/p>\n<p><span style=\"font-weight: 400;\">System.out.println(Adder.add(12.3,12.6));<\/span><\/p>\n<p><span style=\"font-weight: 400;\">}}\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">This will help the aspirant to get an overview of the Object-Oriented programming concept of Java. To learn in-detail Java programming with practical implementation, visit<\/span><b> LotusITHub institute<\/b><span style=\"font-weight: 400;\"> at any of our branches in Pune. You can meet us at Karve Nagar, Kothrud, Narhe, Warje, Dhayari in our office for a free demo session on any of software technology, aptitude, English speaking along with expert guidance. Got a question for us? Please visit our site for detail knowledge at<\/span><a href=\"http:\/\/www.lotusithub.com\/\"> <span style=\"font-weight: 400;\">www.lotusithub.com<\/span><\/a><span style=\"font-weight: 400;\"> or visit us asap.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the interview, the usual question you face is regarding \u201cObject-Oriented Programming\u201d (OOP) which is&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,23],"tags":[99,102,105,107,111],"class_list":["post-333","post","type-post","status-publish","format-standard","hentry","category-c-programing","category-java","tag-java-classes","tag-java-classes-in-pune","tag-java-course-in-pune","tag-java-programming","tag-java-training-institutes-in-pune"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/posts\/333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/comments?post=333"}],"version-history":[{"count":0,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/posts\/333\/revisions"}],"wp:attachment":[{"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/media?parent=333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/categories?post=333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/tags?post=333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}