// API callback
related_results_labels_thumbs({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$blogger":"http://schemas.google.com/blogger/2008","xmlns$georss":"http://www.georss.org/georss","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$thr":"http://purl.org/syndication/thread/1.0","id":{"$t":"tag:blogger.com,1999:blog-9163537232404844123"},"updated":{"$t":"2024-11-24T15:41:26.540+05:30"},"category":[{"term":"Core Java"},{"term":"Oracle Java Programming"},{"term":"Oracle Java"},{"term":"Quiz"},{"term":"JVM"},{"term":"Java 8"},{"term":"JDK"},{"term":"Java Interface"},{"term":"oracle java certification"},{"term":"Java SE"},{"term":"JDBC"},{"term":"Java EE"},{"term":"Java OOPs"},{"term":"GraalVM"},{"term":"Java Abstract Class"},{"term":"Java Magazine"},{"term":"Java Management Service"},{"term":"JavaFX"},{"term":"Java 17"},{"term":"Java Card Technology"},{"term":"Java Classes"},{"term":"java certification"},{"term":"Jakarta EE"},{"term":"Java Collection"},{"term":"Java Multithreading"},{"term":"Java Thread"},{"term":"Oracle Java Database"},{"term":"Graal Cloud"},{"term":"Graal Cloud Native"},{"term":"JRE"},{"term":"Java 18"},{"term":"Java 9"},{"term":"Java Object"},{"term":"Polymorphism"},{"term":"GraalVM Technology"},{"term":"JSP Servlet"},{"term":"JVM Developer"},{"term":"Java IO"},{"term":"Lambda"},{"term":"OpenJDK"},{"term":"Oracle Cloud"},{"term":"Oracle Java Security"},{"term":"1Z0-808"},{"term":"1Z0-809"},{"term":"Garbage Collection"},{"term":"Hibernate"},{"term":"JSON"},{"term":"Java"},{"term":"Java Applet"},{"term":"Java Inheritance"},{"term":"Microservices"},{"term":"SQL"},{"term":"Spring"},{"term":"Synchronization"},{"term":"java se 8 certification"},{"term":"1Z0-807"},{"term":"1Z0-808 exam"},{"term":"1Z0-808: Java SE 8 Programmer I"},{"term":"1Z0-900"},{"term":"1z0-808 practice test"},{"term":"AWS"},{"term":"Coding"},{"term":"History of Java"},{"term":"J2EE"},{"term":"J2SE"},{"term":"JIT"},{"term":"Java 16"},{"term":"Java 19"},{"term":"Java AOP"},{"term":"Java Card Platform"},{"term":"Java Collections"},{"term":"Java ME"},{"term":"Java Platform"},{"term":"Java Reflection"},{"term":"Java SE 8"},{"term":"JavaOne"},{"term":"JavaScript"},{"term":"MySQL"},{"term":"Oracle 1Z0-809"},{"term":"Oracle JDK"},{"term":"Oracle Java OCI Services"},{"term":"oca 1z0-808"},{"term":"oracle java certification exam"},{"term":"oracle java certification exam questions"},{"term":"oracle java certification practice test"},{"term":"1Z0-809 Certification Exam"},{"term":"1Z0-809 Practice Tests"},{"term":"1z0-808 syllabus"},{"term":"1z0-809 exam"},{"term":"1z0-809 syllabus"},{"term":"1z0-811"},{"term":"1z0-811 exam questions"},{"term":"1z0-811 practice test"},{"term":"1z0-819"},{"term":"1z0-819 exam questions"},{"term":"1z0-819 practice test"},{"term":"1z0-819 questions"},{"term":"1z0-819 study guide pdf"},{"term":"1z0-819 syllabus"},{"term":"1z0-900 book"},{"term":"Advanced Java"},{"term":"Android"},{"term":"Blockchain"},{"term":"C language"},{"term":"Cryptocurrency"},{"term":"Frameworks"},{"term":"GraalOS"},{"term":"IoT Certification"},{"term":"J2ME"},{"term":"JDK 17"},{"term":"JIR"},{"term":"Jakarata EE 10"},{"term":"Java 21"},{"term":"Java 5"},{"term":"Java 6"},{"term":"Java Agents"},{"term":"Java Certification Practice Exams"},{"term":"Java Cloud"},{"term":"Java Code"},{"term":"Java Concrete Class"},{"term":"Java EE 7"},{"term":"Java Exercises"},{"term":"Java Management Extensions"},{"term":"Java Package"},{"term":"Java SE 17"},{"term":"Java Servlet"},{"term":"Java Sockets"},{"term":"Java Specification"},{"term":"Java Stream"},{"term":"Java Technology"},{"term":"OCPJP 1Z0-809"},{"term":"Oracle 1Z0-808"},{"term":"Oracle 1Z0-808 exam"},{"term":"Oracle Cloud Infrastructure"},{"term":"Oracle Java Documentation"},{"term":"Oracle Java Networking"},{"term":"Product"},{"term":"SQL Server"},{"term":"Spring Integration"},{"term":"Tribuo"},{"term":"Web Services"},{"term":"exam 1z0-809"},{"term":"java 1z0-808"},{"term":"java 1z0-809"},{"term":"java certification exam"},{"term":"java certification practice exam"},{"term":"java ee 6 enterprise architect certified master"},{"term":"java ee 7 application developer"},{"term":"java ee 7 application developer 1z0-900 study guide pdf"},{"term":"java foundations 1z0-811"},{"term":"java foundations 1z0-811 pdf"},{"term":"java se 11 developer 1z0-819"},{"term":"java se 11 developer 1z0-819 study guide pdf"},{"term":"java se 8 programmer"},{"term":"java se 8 programmer 1 1z0-808"},{"term":"oca java certification"},{"term":"oca java se 8 programmer i exam guide"},{"term":"ocm java ee 6 enterprise architect exam guide pdf"},{"term":"ocmjea"},{"term":"ocmjea 6 mock test"},{"term":"ocmjea certification"},{"term":"ocp 1z0-809"},{"term":"ocp java se 8 programmer ii"},{"term":"ocp java se 8 programmer ii exam guide"},{"term":"oracle certified associate java se 8 programmer exam"},{"term":"oracle certified associate java se 8 programmer exam questions"},{"term":"oracle certified associate java se 8 programmer syllabus"},{"term":"oracle certified master"},{"term":"oracle certified professional java se 8 programmer syllabus"}],"title":{"type":"text","$t":"Oracle Java Certified"},"subtitle":{"type":"html","$t":""},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https:\/\/oraclejavacertified.blogspot.com\/feeds\/posts\/default"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/-\/Java+OOPs?alt=json-in-script\u0026max-results=6"},{"rel":"alternate","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/search\/label\/Java%20OOPs"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"},{"rel":"next","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/-\/Java+OOPs\/-\/Java+OOPs?alt=json-in-script\u0026start-index=7\u0026max-results=6"}],"author":[{"name":{"$t":"Keturah Carol"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/17621317473280987274"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"generator":{"version":"7.00","uri":"http://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"11"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"6"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-9163537232404844123.post-6510582849315223976"},"published":{"$t":"2022-09-12T10:57:00.005+05:30"},"updated":{"$t":"2022-09-12T10:57:58.210+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Core Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Java AOP"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Java OOPs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Spring"}],"title":{"type":"text","$t":"Spring Boot – Difference Between AOP and OOP"},"content":{"type":"html","$t":"\u003Cdiv style=\"text-align: center;\"\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjLXSG9DAgOsLPEJXkLSt14PAWcGpa2YtyGaJdevNvcwHa3IdFJoZlMMDYniQqrjMYIz26ImPQ1U9ImxjUdEOwrAf7ae7iTs5lPmCJmT1cRz58VfaDRXgtcdyi09kjo3X6-npojTBu02jduARSWSewsu8v6aL5yCWpFsI7Yj2yM5ZytQoK_cQhWKFjung\/s560\/Spring%20Boot%20%E2%80%93%20Difference%20Between%20AOP%20and%20OOP.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg alt=\"Spring Boot, AOP, OOP, Oracle Java Certification, Oracle Java Career, Java Skills, Java Jobs, Java Tutorial and Materials, Java Prep, Java Preparation\" border=\"0\" data-original-height=\"315\" data-original-width=\"560\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjLXSG9DAgOsLPEJXkLSt14PAWcGpa2YtyGaJdevNvcwHa3IdFJoZlMMDYniQqrjMYIz26ImPQ1U9ImxjUdEOwrAf7ae7iTs5lPmCJmT1cRz58VfaDRXgtcdyi09kjo3X6-npojTBu02jduARSWSewsu8v6aL5yCWpFsI7Yj2yM5ZytQoK_cQhWKFjung\/s16000\/Spring%20Boot%20%E2%80%93%20Difference%20Between%20AOP%20and%20OOP.png\" title=\"Spring Boot – Difference Between AOP and OOP\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EAOP(Aspect-Oriented Programming)\u003C\/b\u003E complements OOP by enabling modularity of cross-cutting concerns. The Key unit of Modularity(breaking of code into different modules) in Aspect-Oriented Programming is Aspect. one of the major advantages of AOP is that it allows developers to concentrate on business logic. It is more convenient to use because changes need to be done in only one place. AOP is used along with spring Ioc to provide a very capable middleware solution.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cb\u003E\u003C\/b\u003E\u003C\/i\u003E\u003C\/div\u003E\u003Cblockquote\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cb\u003ENote:\u003C\/b\u003E Cross cutting concerns are one of the concerns in any application such as logging, security, caching, etc. They are present in one part of the program but they may affect other parts of the program too.\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003C\/div\u003E\u003C\/blockquote\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhmvDxploYP7yG1zbaMKrSKu52NX64RkCSJiTGuVzvFxxfqcLWqbZxA8XoAUCkGmwewx6-ZVjzC1bILfNqJZTlrSQj5-oC5vtC_DqaVrN2yYbxmG5W06-VMwYPZigcR8Jqo9mwX27ypTC_C-Oqd-dJp1JzROuoAqj6mv0QqRpFvCfvkeyl5PtgEsbbhdQ\/s702\/1.png\" imageanchor=\"1\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"\u003E\u003Cimg alt=\"Spring Boot, AOP, OOP, Oracle Java Certification, Oracle Java Career, Java Skills, Java Jobs, Java Tutorial and Materials, Java Prep, Java Preparation\" border=\"0\" data-original-height=\"336\" data-original-width=\"702\" height=\"96\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhmvDxploYP7yG1zbaMKrSKu52NX64RkCSJiTGuVzvFxxfqcLWqbZxA8XoAUCkGmwewx6-ZVjzC1bILfNqJZTlrSQj5-oC5vtC_DqaVrN2yYbxmG5W06-VMwYPZigcR8Jqo9mwX27ypTC_C-Oqd-dJp1JzROuoAqj6mv0QqRpFvCfvkeyl5PtgEsbbhdQ\/w200-h96\/1.png\" title=\"Spring Boot – Difference Between AOP and OOP\" width=\"200\" \/\u003E\u003C\/a\u003E\u003C\/div\u003EAOP is used along with Oop as it also works around classes and objects, etc. We can also say that Oop is a basic term for AOP. Different Frameworks used in Aop are AspectJ, JBoss, and Spring. AOP makes the program loosely coupled. AOP separates business logic from cross-cutting concerns. The aspect class which contains cross-cutting concerns is annotated by @Aspect and @EnableAspectJAutoProxy annotations\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EAOP\u003C\/b\u003E has different terms like Aspect, Weaving, different types of advices, JoinPoints and Pointcut expressions, etc. These terms are explained below:\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E◉ Aspect: \u003C\/b\u003EThe cross-cutting concerns are modularized as Aspect. The classes which contain such cross-cutting concerns are annotated with @Aspect annotation.\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E◉ Join point:\u003C\/b\u003E Method execution is represented by using Joinpoint.\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E◉ Advice:\u003C\/b\u003E Aspect takes action on a particular Joinpoint. This action depends on various advice which is explained below:\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E◉ Before advice:\u003C\/b\u003E It runs before the method execution.\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E◉ After returning advice: \u003C\/b\u003EIt runs after the result is returned by the method.\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E◉ After throwing advice:\u003C\/b\u003E It runs after an exception is thrown by the method.\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E◉ After (finally) advice:\u003C\/b\u003E It is executed after method execution or after an exception is thrown or the result is returned by the method.\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E◉ Around advice:\u003C\/b\u003E It can perform the behavior before and after the method invocation.\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E◉ Pointcut: \u003C\/b\u003EPointcut is a signature that matches the join points.\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EIllustration: \u003C\/b\u003EA pointcut expression with before advice:\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ Annotation\u003C\/div\u003E\u003Cdiv\u003E@Before(\"execution(* abc.efg.gettingstarted.dao.*.add(..))\")\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003Epublic void allMethods(Point Point)\u0026nbsp;\u003C\/div\u003E\u003Cdiv\u003E{\u0026nbsp; \/\/ Aspect body }\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EObject-Oriented Programming\u003C\/b\u003E\u003C\/h3\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EThe object-oriented programming model works around classes and objects. The main building blocks of Oop are classes, objects, methods, attributes, etc. Oop has various advantages such as code reusability, flexibility, etc. It also maintains modularity using classes.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cb\u003E\u003C\/b\u003E\u003C\/i\u003E\u003C\/div\u003E\u003Cblockquote\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cb\u003ENote:\u003C\/b\u003E Object is an instance of class and class is a blueprint of an object created.\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003C\/div\u003E\u003C\/blockquote\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EThe Key unit of Modularity(breaking of code into different modules) in Object-Oriented Programming is class. Oop contains objects, classes, interfaces, etc. Oop lacks the feature of using cross-cutting concerns. It consists of various concepts such as Data abstraction, Encapsulation, Polymorphism, and Inheritance.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EIllustration:\u003C\/b\u003E If there is a fruit class then apple, orange, banana are various objects of the fruit class.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: center;\"\u003ESource:\u0026nbsp;geeksforgeeks.org\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/oraclejavacertified.blogspot.com\/feeds\/6510582849315223976\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2022\/09\/spring-boot-difference-between-aop-and.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/6510582849315223976"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/6510582849315223976"},{"rel":"alternate","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2022\/09\/spring-boot-difference-between-aop-and.html","title":"Spring Boot – Difference Between AOP and OOP"}],"author":[{"name":{"$t":"Keturah Carol"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/17621317473280987274"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjLXSG9DAgOsLPEJXkLSt14PAWcGpa2YtyGaJdevNvcwHa3IdFJoZlMMDYniQqrjMYIz26ImPQ1U9ImxjUdEOwrAf7ae7iTs5lPmCJmT1cRz58VfaDRXgtcdyi09kjo3X6-npojTBu02jduARSWSewsu8v6aL5yCWpFsI7Yj2yM5ZytQoK_cQhWKFjung\/s72-c\/Spring%20Boot%20%E2%80%93%20Difference%20Between%20AOP%20and%20OOP.png","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-9163537232404844123.post-1984039408358785073"},"published":{"$t":"2021-08-13T11:10:00.005+05:30"},"updated":{"$t":"2021-08-13T11:13:21.086+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Core Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Java OOPs"}],"title":{"type":"text","$t":"Four Main Object Oriented Programming Concepts of Java"},"content":{"type":"html","$t":"\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjbyFe9VDXK_j5NwkSVzpMq9Sbfnguoes6de_uuMiMlXSDr-8pBq07bopF0WfxFUYi0Y8aUctXAEa6shdh5HQS2j2DRO80hb1B2fKdnCuAdfcxX6EhJkq8TfL6vxS_VX_GHG0li0tc8-sjG\/s1280\/javaoops.jpg\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg alt=\"Object Oriented Programming Concepts of Java, Oracle Java Tutorial and Material, Oracle Java Certification, Oracle Java Career, Core Java, Oracle Java OOP\" border=\"0\" data-original-height=\"720\" data-original-width=\"1280\" height=\"360\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjbyFe9VDXK_j5NwkSVzpMq9Sbfnguoes6de_uuMiMlXSDr-8pBq07bopF0WfxFUYi0Y8aUctXAEa6shdh5HQS2j2DRO80hb1B2fKdnCuAdfcxX6EhJkq8TfL6vxS_VX_GHG0li0tc8-sjG\/w640-h360\/javaoops.jpg\" title=\"Four Main Object Oriented Programming Concepts of Java\" width=\"640\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\u003Cp\u003EObject-oriented programming generally referred to as OOPS is the backbone of java as java being a completely object-oriented language. Java organizes a program around the various objects and well-defined interfaces. There are four pillars been here in OOPS which are listed below. These concepts aim to implement real-world entities in programs.\u003C\/p\u003E\u003Cp\u003E◉ Abstraction\u003C\/p\u003E\u003Cp\u003E◉ Encapsulation\u003C\/p\u003E\u003Cp\u003E◉ Inheritance\u003C\/p\u003E\u003Cp\u003E◉ Polymorphism\u003C\/p\u003E\u003Cp\u003EAbstraction is a process of hiding implementation details and exposes only the functionality to the user. In abstraction, we deal with ideas and not events. This means the user will only know “what it does” rather than “how it does”.\u003C\/p\u003E\u003Cp\u003E\u003Cb\u003EThere are two ways to achieve abstraction in Java\u003C\/b\u003E\u003C\/p\u003E\u003Cp\u003E1. Abstract class (0 to 100%)\u003C\/p\u003E\u003Cp\u003E2. Interface (100%)\u003C\/p\u003E\u003Cp\u003E\u003Ci\u003E\u003Cb\u003EReal-Life Example:\u003C\/b\u003E A driver will focus on the car functionality (Start\/Stop -\u0026gt; Accelerate\/ Break), he\/she does not bather about how the Accelerate\/ brake mechanism works internally. And this is how the abstraction works.\u003C\/i\u003E\u003C\/p\u003E\u003Cp\u003ECertain key points should be remembered regarding this pillar of OOPS as follows:\u003C\/p\u003E\u003Cp\u003E◉ The class should be abstract if a class has one or many abstract methods\u003C\/p\u003E\u003Cp\u003E◉ An abstract class can have constructors, concrete methods, static method, and final method\u003C\/p\u003E\u003Cp\u003E◉ Abstract class can’t be instantiated directly with the new operator. It can be possible as shown in pre tag below:\u003C\/p\u003E\u003Cp\u003EA b = new B();\u003C\/p\u003E\u003Cp\u003E◉\u0026nbsp;The child class should override all the abstract methods of parent else the child class should be declared with abstract keyword\u003C\/p\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjYASt-bqXy821b8Ie7NrGBRCXtGc-hFEmoxs1n1paWfhTfaVgug_VpFz_lVDVPksG8XsMw_oKoCgxJApF6s96NZ_SFWkBLKi1rTd0cwf6oLC81fgsgnuWFmtyTKvEHRvv290BWRexRVTj2\/s1000\/m1.png\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg alt=\"Object Oriented Programming Concepts of Java, Oracle Java Tutorial and Material, Oracle Java Certification, Oracle Java Career, Core Java, Oracle Java OOP\" border=\"0\" data-original-height=\"338\" data-original-width=\"1000\" height=\"216\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjYASt-bqXy821b8Ie7NrGBRCXtGc-hFEmoxs1n1paWfhTfaVgug_VpFz_lVDVPksG8XsMw_oKoCgxJApF6s96NZ_SFWkBLKi1rTd0cwf6oLC81fgsgnuWFmtyTKvEHRvv290BWRexRVTj2\/w640-h216\/m1.png\" title=\"Four Main Object Oriented Programming Concepts of Java\" width=\"640\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: left;\"\u003E\u003Cb\u003EExample:\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: left;\"\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\/\/ Abstract class\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003Epublic abstract class Car {\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic abstract void stop();\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E}\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\/\/ Concrete class\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003Epublic class Honda extends Car {\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ Hiding implementation details\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E@Override public void stop()\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESystem.out.println(\"Honda::Stop\");\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESystem.out.println(\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\u003C\/span\u003E\"Mechanism to stop the car using break\");\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E}\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003Epublic class Main {\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic static void main(String args[])\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ECar obj\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\u003C\/span\u003E= new Honda(); \/\/ Car object =\u0026gt;contents of Honda\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Eobj.stop(); \/\/ call the method\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both;\"\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EPillar 2: Encapsulation\u003C\/b\u003E\u003C\/h3\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EEncapsulation is the process of wrapping code and data together into a single unit.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Ci\u003EReal-Life Example:\u003C\/i\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cbr \/\u003E\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003EA capsule which is mixed of several medicines. The medicines are hidden data to the end user.\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EIn order to achieve encapsulation in java follow certain steps as proposed below:\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv\u003E◉ Declare the variables as private\u003C\/div\u003E\u003Cdiv\u003E◉ Declare the setters and getters to set and get the variable values\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cb\u003ENote: \u003C\/b\u003EThere are few disadvantages of encapsulation in java as follows:\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cbr \/\u003E\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cb\u003E1. Control Over Data:\u003C\/b\u003E We can write the logic in the setter method to not store the negative values for an Integer. So by this way we can control the data.\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cb\u003E2. Data Hiding: \u003C\/b\u003EThe data members are private so other class can’t access the data members.\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cb\u003E3. Easy to test: \u003C\/b\u003EUnit testing is easy for encapsulated classes\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EExample:\u003C\/b\u003E\u003C\/div\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ AJavaclasswhichisafullyencapsulatedclass.\u003C\/div\u003E\u003Cdiv\u003Epublicclass Car\u003C\/div\u003E\u003Cdiv\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ privatevariable\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EprivateStringname;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ gettermethodforname\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EpublicStringgetName()\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E returnname;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ settermethodforname\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EpublicvoidsetName(Stringname)\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E this.name = name\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ Javaclasstotesttheencapsulatedclass.\u003C\/div\u003E\u003Cdiv\u003Epublic class Test\u003C\/div\u003E\u003Cdiv\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E publicstaticvoidmain(String[]args)\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\u003C\/span\u003E\/\/ creatinginstanceoftheencapsulatedclass\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\u003C\/span\u003ECarcar\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\u003C\/span\u003E= newCar();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\u003C\/span\u003E\/\/ settingvalueinthenamemember\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\u003C\/span\u003Ecar.setName(\"Honda\");\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\u003C\/span\u003E\/\/ gettingvalueofthenamemember\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\u003C\/span\u003ESystem.out.println(car.getName());\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EPillar 3: Inheritance\u003C\/b\u003E\u003C\/h3\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EInheritance is the process of one class inheriting properties and methods from another class in Java. Inheritance is used when we have is-a relationship between objects.\u0026nbsp; Inheritance in Java is implemented using extends keyword.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Ci\u003EReal-life Example:\u003C\/i\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cbr \/\u003E\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003EThe planet Earth and Mars inherits the super class Solar System and Solar system inherits the Milky Way Galaxy. So Milky Way Galaxy is the top super class for Class Solar System, Earth and Mars.\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003ELet us do discuss the usage of inheritance in java applications with a generic example before proposing the code. So consider an example extending the Exception class to create an application-specific Exception class that contains more information like error codes. For example NullPointerException.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EThere are 5 different types of inheritance in java as follows:\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E1. Single Inheritance:\u003C\/b\u003E Class B inherits Class B using extends keyword\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E2. Multilevel Inheritance: \u003C\/b\u003EClass C inherits class B and B inherits class A using extends keyword\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E3. Hierarchy Inheritance:\u003C\/b\u003E Class B and C inherits class A in hierarchy order using extends keyword\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E4. Multiple Inheritance\u003C\/b\u003E: Class C inherits Class A and B. Here A and B both are superclass and C is only one child class. Java is not supporting Multiple Inheritance, but we can implement using Interfaces.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E5. Hybrid Inheritance:\u003C\/b\u003E Class D inherits class B and class C. Class B and C inherits A. Here same again Class D inherits two superclass, so Java is not supporting Hybrid Inheritance as well.\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EExample:\u003C\/b\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv\u003E\/\/ super class\u003C\/div\u003E\u003Cdiv\u003Eclass Car {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ the Car class have one field\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic String wheelStatus;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic int noOfWheels;\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ the Car class has one constructor\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic Car(String wheelStatus, int noOfWheels)\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Ethis.wheelStatus = wheelStatus;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Ethis.noOfWheels = noOfWheels;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ the Car class has three methods\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic void applyBrake()\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EwheelStatus = \"Stop\" System.out.println(\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\u003C\/span\u003E\"Stop the car using break\");\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ toString() method to print info of Car\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic String toString()\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Ereturn (\"No of wheels in car \" + noOfWheels + \"\\n\"\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\t\u003C\/span\u003E+ \"status of the wheels \" + wheelStatus);\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ sub class\u003C\/div\u003E\u003Cdiv\u003Eclass Honda extends Car {\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ the Honda subclass adds one more field\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic Boolean alloyWheel;\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ the Honda subclass has one constructor\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic Honda(String wheelStatus, int noOfWheels,\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\t\u003C\/span\u003EBoolean alloyWheel)\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ invoking super-class(Car) constructor\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Esuper(wheelStatus, noOfWheels);\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EalloyWheel = alloyWheel;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ the Honda subclass adds one more method\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic void setAlloyWheel(Boolean alloyWheel)\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EalloyWheel = alloyWheel;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ overriding toString() method of Car to print more\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ info\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E@Override public String toString()\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Ereturn (super.toString() + \"\\nCar alloy wheel \"\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\t\t\u003C\/span\u003E+ alloyWheel);\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ driver class\u003C\/div\u003E\u003Cdiv\u003Epublic class Main {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic static void main(String args[])\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EHonda honda = new Honda(3, 100, 25);\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESystem.out.println(honda.toString());\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EPillar 4: Polymorphism in java\u0026nbsp;\u003C\/b\u003E\u003C\/h3\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EPolymorphism is the ability to perform many things in many ways. The word Polymorphism is from two different Greek words- poly and morphs. “Poly” means many, and “Morphs” means forms. So polymorphism means many forms. The polymorphism can be present in the case of inheritance also. The functions behave differently based on the actual implementation.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cb\u003EReal-life Example:\u003C\/b\u003E\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003E\u003Cbr \/\u003E\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003EA delivery person delivers items to the user. If it’s a postman he will deliver the letters. If it’s a food delivery boy he will deliver the foods to the user. Like this polymorphism implemented different ways for the delivery function.\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EThere are two types of polymorphism as listed below:\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E1. Static or Compile-time Polymorphism\u003C\/div\u003E\u003Cdiv\u003E2. Dynamic or Run-time Polymorphism\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EStatic or Compile-time Polymorphism when the compiler is able to determine the actual function, it’s called compile-time polymorphism. Compile-time polymorphism can be achieved by method overloading in java. When different functions in a class have the same name but different signatures, it’s called method overloading. A method signature contains the name and method arguments. So, overloaded methods have different arguments. The arguments might differ in the numbers or the type of arguments.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EExample 1:\u003C\/b\u003E Static Polymorphism\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv\u003Epublic class Car{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic void speed() {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic void speed(String accelerator) {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic int speed(String accelerator, int speedUp) {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Ereturn carSpeed;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv\u003E\u003Cb\u003EDynamic or Run-time Polymorphism\u003C\/b\u003E occurs when the compiler is not able to determine whether it’s superclass method or sub-class method it’s called run-time polymorphism. The run-time polymorphism is achieved by method overriding. When the superclass method is overridden in the subclass, it’s called method overriding.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EExample 2:\u003C\/b\u003E Dynamic Polymorphism\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv\u003Eimport java.util.Random;\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003Eclass DeliveryBoy {\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic void deliver() {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESystem.out.println(\"Delivering Item\");\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic static void main(String[] args) {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EDeliveryBoy deliveryBoy = getDeliveryBoy();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EdeliveryBoy.deliver();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Eprivate static DeliveryBoy getDeliveryBoy() {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ERandom random = new Random();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Eint number = random.nextInt(5);\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Ereturn number % 2 == 0 ? new Postman() : new FoodDeliveryBoy();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003Eclass Postman extends DeliveryBoy {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E@Override\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic void deliver() {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESystem.out.println(\"Delivering Letters\");\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003Eclass FoodDeliveryBoy extends DeliveryBoy {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E@Override\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic void deliver() {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESystem.out.println(\"Delivering Food\");\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv\u003E\u003Cb\u003EOutput\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EDelivering Letters\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: center;\"\u003ESource: geeksforgeeks.org\u003C\/div\u003E\u003C\/div\u003E\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/oraclejavacertified.blogspot.com\/feeds\/1984039408358785073\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2021\/08\/four-main-object-oriented-programming.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/1984039408358785073"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/1984039408358785073"},{"rel":"alternate","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2021\/08\/four-main-object-oriented-programming.html","title":"Four Main Object Oriented Programming Concepts of Java"}],"author":[{"name":{"$t":"Keturah Carol"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/17621317473280987274"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEjbyFe9VDXK_j5NwkSVzpMq9Sbfnguoes6de_uuMiMlXSDr-8pBq07bopF0WfxFUYi0Y8aUctXAEa6shdh5HQS2j2DRO80hb1B2fKdnCuAdfcxX6EhJkq8TfL6vxS_VX_GHG0li0tc8-sjG\/s72-w640-h360-c\/javaoops.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-9163537232404844123.post-3239402724718040429"},"published":{"$t":"2021-08-09T11:03:00.005+05:30"},"updated":{"$t":"2021-08-09T11:14:14.708+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Core Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Java OOPs"}],"title":{"type":"text","$t":"Difference Between Implements and Extends"},"content":{"type":"html","$t":"\u003Ch3 style=\"text-align: center;\"\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEg9XOw6imPOGidWe8XjjgpIQ7QhXmGRdRDy-rI_TpDK9RczX3x8Hj0LSfnbcKyFvQXJLTrutiMeh8PwY0KDm1l7HnznX10G8HfHDOB6fN1wdAlYeLt2R9ehsdHWAFfyQuz53VJhssSn8VrY\/s744\/extends-vs-implementation.png\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg alt=\"Java Implements, Java Extends, Oracle Java Tutorial and Material, Oracle Java Learning, Oracle Java Guides, Java Certification\" border=\"0\" data-original-height=\"360\" data-original-width=\"744\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEg9XOw6imPOGidWe8XjjgpIQ7QhXmGRdRDy-rI_TpDK9RczX3x8Hj0LSfnbcKyFvQXJLTrutiMeh8PwY0KDm1l7HnznX10G8HfHDOB6fN1wdAlYeLt2R9ehsdHWAFfyQuz53VJhssSn8VrY\/s16000\/extends-vs-implementation.png\" title=\"Difference Between Implements and Extends\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\u003C\/h3\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EImplements vs Extends\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003EImplements and Extends are two keywords found in \u003Cb\u003E\u003Ca href=\"http:\/\/oraclejavacertified.blogspot.com\/p\/oracle-java-certifications.html\"\u003E\u003Cspan style=\"font-family: times; font-size: large;\"\u003EJava programming language\u003C\/span\u003E\u003C\/a\u003E\u003C\/b\u003E that provides a means of transferring added functionality to a new class. Implements keyword is used explicitly for implementing an interface, while Extends keyword is used for inheriting from a (super) class. Please note that the concepts of inheritance and interfaces are present in most of the other object oriented programming languages like C# and VB.NET, but they offer different syntax or keywords for applying those concepts. This article only focuses on Implements and Extends keywords defined in Java.\u003C\/p\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EExtends\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003EExtends keyword is used to implement the concept of inheritance in Java programming language. Inheritance essentially provides code reuse by allowing extending properties and behavior of an existing class by a newly defined class. When a new subclass (or derived class) extends a super class (or parent class) that subclass will inherit all attributes and methods of the super class. The subclass can optionally override the behavior (provide new or extended functionality to methods) inherited from the parent class. A subclass cannot extend multiple super classes in Java. Therefore, you cannot use extends for multiple inheritance. In order to have multiple inheritance, you need to use interfaces as explained below.\u003C\/p\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EImplements\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003EImplements keyword in Java programming language is used for implementing an interface by a class. An interface in Java is an abstract type that is used to specify a contract that should be implemented by classes, which implement that interface. Usually an interface will only contain method signatures and constant declarations. Any interface that implements a particular interface should implement all methods defined in the interface, or should be declared as an abstract class. In Java, the type of an object reference can be defined as an interface type. But that object must either be null or should hold an object of a class, which implements that particular interface. Using Implements keyword in Java, you can implement multiple interfaces to a single class. An Interface cannot implement another interface. However an interface can extend a class.\u003C\/p\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EDifference between Implements and Extends\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003EAlthough, Implements and Extends are two keywords that provide a mechanism to inherit attributes and behavior to a class in Java programming language, they are used for two different purposes. Implements keyword is used for a class to implement a certain interface, while Extends keyword is used for a subclass to extend from a super class. When a class implements an interface, that class needs to implement all the methods defined in the interface, but when a subclass extends a super class, it may or may not override the methods included in the parent class. Finally, another key difference between Implements and Extends is that, a class can implement multiple interfaces but it can only extend from one super class in Java. In general, usage of Implements (interfaces) is considered more favorable compared to the usage of Extends (inheritance), for several reasons like higher flexibility and the ability to minimize coupling. Therefore in practice, programming to an interface is preferred over extending from base classes.\u003C\/p\u003E\u003Cp style=\"text-align: center;\"\u003ESource: differencebetween.com\u003C\/p\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/oraclejavacertified.blogspot.com\/feeds\/3239402724718040429\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2021\/08\/difference-between-implements-and.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/3239402724718040429"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/3239402724718040429"},{"rel":"alternate","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2021\/08\/difference-between-implements-and.html","title":"Difference Between Implements and Extends"}],"author":[{"name":{"$t":"Keturah Carol"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/17621317473280987274"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEg9XOw6imPOGidWe8XjjgpIQ7QhXmGRdRDy-rI_TpDK9RczX3x8Hj0LSfnbcKyFvQXJLTrutiMeh8PwY0KDm1l7HnznX10G8HfHDOB6fN1wdAlYeLt2R9ehsdHWAFfyQuz53VJhssSn8VrY\/s72-c\/extends-vs-implementation.png","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-9163537232404844123.post-5892643244624769658"},"published":{"$t":"2021-07-30T09:47:00.003+05:30"},"updated":{"$t":"2021-07-30T09:47:25.394+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java Interface"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Java OOPs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Polymorphism"}],"title":{"type":"text","$t":"Interfaces and Polymorphism in Java"},"content":{"type":"html","$t":"\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgujeomTKI-eFiuQ-JfbQFiTbT2lHaiAcu5B63ITr_BUHZz16msasZq3xoy9CsmdYyUrTLj7ymZwrau8y21x6rsrFRANX51rlFekfYYe7yGGx-h15PWuPoobpOH3ux2tKGehXykWKybI3M0\/s1280\/javaoops.jpg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg alt=\"Java Interfaces, Java Polymorphism, Oracle Java Exam Prep, Oracle Java Tutorial and Material, Oracle Java Career, Oracle Java Certification, Oracle Java OOPs\" border=\"0\" data-original-height=\"720\" data-original-width=\"1280\" height=\"360\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgujeomTKI-eFiuQ-JfbQFiTbT2lHaiAcu5B63ITr_BUHZz16msasZq3xoy9CsmdYyUrTLj7ymZwrau8y21x6rsrFRANX51rlFekfYYe7yGGx-h15PWuPoobpOH3ux2tKGehXykWKybI3M0\/w640-h360\/javaoops.jpg\" title=\"Interfaces and Polymorphism in Java\" width=\"640\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\u003Cp\u003E\u003Cb\u003E\u003Ca href=\"https:\/\/oraclejavacertified.blogspot.com\/p\/1z0-809-java-se-8-programmer-ii.html\"\u003E\u003Cspan style=\"font-family: helvetica; font-size: x-large;\"\u003EJava language\u003C\/span\u003E\u003C\/a\u003E\u003C\/b\u003E is one of the most popular languages among all programming languages. There are several advantages of using the java programming language, whether for security purposes or building large distribution projects. One of the advantages of using JA is that Java tries to connect every concept in the language to the real world with the help of the concepts of classes, inheritance, polymorphism, interfaces, etc. In this article, we will discuss polymorphism and interface concepts.\u003C\/p\u003E\u003Cp\u003EPolymorphism is that it has many forms that mean one specific defined form is used in many different ways. The simplest real-life example is let’s suppose we have to store the name of the person and the phone number of the person, but there are many situations when a person has two different phone numbers. We have to save the same phone number under the same name.\u003C\/p\u003E\u003Cp\u003ELet us interpret it with help . So, in java, the problem can be solved using an \u003Cb\u003E\u003Ca href=\"http:\/\/oraclejavacertified.blogspot.com\/search\/label\/Java%20OOPs\"\u003Eobject-oriented concept\u003C\/a\u003E\u003C\/b\u003E, void insertPhone(String name, int phone). So, this method is used to save the phone number of the particular person. Similarly, we can use the same form but a different signature means different parameters to store the alternative phone number of the person’s void insertPhone(String name, int phone1, int phone2). One method has two different forms and performs different operations. This is an example of polymorphism, which is method overloading.\u003C\/p\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003ETypes of polymorphism in Java:\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003E1. Run time polymorphism\u003C\/p\u003E\u003Cp\u003E2. Compile-time polymorphism\u003C\/p\u003E\u003Cp\u003E\u003Cb\u003EType 1:\u003C\/b\u003E Run time polymorphism\u003C\/p\u003E\u003Cp\u003EThis type of polymorphism is resolved by the java virtual machine, not by the java compiler. That’s why this type of polymorphism is called run-time polymorphism. Run time polymorphism occurs during method overriding in java.\u003C\/p\u003E\u003Cp\u003E\u003Cb\u003EExample\u0026nbsp;\u003C\/b\u003E\u003C\/p\u003E\u003Cp\u003E\/\/ Java Program to Illustrate Run-time polymorphism\u003C\/p\u003E\u003Cp\u003E\/\/ Importing I\/O classes\u003C\/p\u003E\u003Cp\u003Eimport java.io.*;\u003C\/p\u003E\u003Cp\u003E\/\/ Class 1 (Parent class)\u003C\/p\u003E\u003Cp\u003Eclass GFG1 {\u003C\/p\u003E\u003Cp\u003E\/\/name method\u003C\/p\u003E\u003Cp\u003Evoid name() {\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003ESystem.out.println(\"This is the GFG1 class\");\u003C\/p\u003E\u003Cp\u003E}\u003C\/p\u003E\u003Cp\u003E}\u003C\/p\u003E\u003Cp\u003E\/\/ Class 2 (Chile class)\u003C\/p\u003E\u003Cp\u003E\/\/ Main class extending parent class\u003C\/p\u003E\u003Cp\u003Epublic class GFG extends GFG1 {\u003C\/p\u003E\u003Cp\u003E\/\/ Method 1\u003C\/p\u003E\u003Cp\u003Evoid name() {\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ Print statement\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003ESystem.out.println(\"This is the GFG class\");\u003C\/p\u003E\u003Cp\u003E}\u003C\/p\u003E\u003Cp\u003E\/\/ Method 2\u003C\/p\u003E\u003Cp\u003E\/\/ Main drive method\u003C\/p\u003E\u003Cp\u003Epublic static void main(String[] args) {\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ Now creating 2 objects with different references and\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ calling the Method 1 over the objects\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ Case 1: GFG1 reference and GFG1 is the object\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003EGFG1 ob = new GFG1();\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Eob.name();\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ Case 2: GFG1 reference and GFG is the object\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003EGFG1 ob1 = new GFG();\u003C\/p\u003E\u003Cp\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Eob1.name();\u003C\/p\u003E\u003Cp\u003E}\u003C\/p\u003E\u003Cp\u003E}\u003C\/p\u003E\u003Cdiv\u003E\u003Cdiv\u003E\u003Cb\u003EOutput\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EThis is the GFG1 class\u003C\/div\u003E\u003Cdiv\u003EThis is the GFG class\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EOutput explanation:\u0026nbsp;\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EIn the above example, the same function i.e name is called two times, but in both cases, the output is different. The signatures of these methods are also the same. That’s why compilers cannot be able to identify which should be executed. This is determined only after the object creation and reference of the class, which is performed during run time (Memory management ). That’s why this is run-time polymorphism.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EType 2:\u003C\/b\u003E Compile-time polymorphism\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EMethod overloading is an example of the compile-time polymorphism method. Overloading means a function having the same name but a different signature. This is compile-time polymorphism because this type of polymorphism is determined during the compilation time because during writing the code we already mention the different types of parameters for the same function name.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EExample\u0026nbsp;\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv\u003E\/\/ Java Program to Illustrate Run-time polymorphism\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ Importing required classes\u003C\/div\u003E\u003Cdiv\u003Eimport java.io.*;\u003C\/div\u003E\u003Cdiv\u003Eimport java.util.*;\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ Class 1\u003C\/div\u003E\u003Cdiv\u003E\/\/ Helper class\u003C\/div\u003E\u003Cdiv\u003Eclass First {\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ Method of this class\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ Without any parameter\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Evoid check()\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ Print statement if this method is called\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESystem.out.println(\"This is the class First\");\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ Class 2\u003C\/div\u003E\u003Cdiv\u003E\/\/ Main class\u003C\/div\u003E\u003Cdiv\u003Eclass Second extends First {\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ Method overloading\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Evoid check(String name)\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ Printing the name of the class method having the\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ parameter\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESystem.out.println(\"This is the class \" + name);\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ Method 2\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E\/\/ Main driver method\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic static void main(String args[])\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ Creating object of class 2\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESecond ob = new Second();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ Calling method over class 2 object\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Eob.check(\"Second\");\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ Creating object of class 1\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EFirst ob1 = new First();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Eob.check();\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ Upcasting\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003EFirst ob2 = new Second();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Eob.check();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv\u003E\u003Cb\u003EOutput\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003EThis is the class Second\u003C\/div\u003E\u003Cdiv\u003EThis is the class First\u003C\/div\u003E\u003Cdiv\u003EThis is the class First\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgJE-8HrG6_BB0uxOD5NHKf6_7IxuGrjpFhtg0Pr2Kv47PUaw7npSBkHMgE4tAFU_osN3J-WdDaPCI3mV9FMC5Bc5XEg_nMlxAx87oskLc9i6YHKM4EDasRGAdKnIHBB3n_-ntyut5yKFx9\/s583\/java-interfaces.jpg\" imageanchor=\"1\" style=\"clear: left; float: left; margin-bottom: 1em; margin-right: 1em;\"\u003E\u003Cimg alt=\"Java Interfaces, Java Polymorphism, Oracle Java Exam Prep, Oracle Java Tutorial and Material, Oracle Java Career, Oracle Java Certification, Oracle Java OOPs\" border=\"0\" data-original-height=\"468\" data-original-width=\"583\" height=\"257\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgJE-8HrG6_BB0uxOD5NHKf6_7IxuGrjpFhtg0Pr2Kv47PUaw7npSBkHMgE4tAFU_osN3J-WdDaPCI3mV9FMC5Bc5XEg_nMlxAx87oskLc9i6YHKM4EDasRGAdKnIHBB3n_-ntyut5yKFx9\/w320-h257\/java-interfaces.jpg\" title=\"Interfaces and Polymorphism in Java\" width=\"320\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: left;\"\u003EInterfaces are very similar to classes. They have variables and methods but the interfaces allow only abstract methods(that don’t contain the body of the methods), but what is the difference between the classes and the interfaces? The first advantage is to allow interfaces to implement the multiple inheritances in a particular class. The JAVA language doesn’t support multiple inheritances if we extend multiple classes in the class, but with the help of the interfaces, multiple inheritances are allowed in Java.\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Ci\u003EReal-life Example\u003C\/i\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003E\u003Ci\u003E\u003Cbr \/\u003E\u003C\/i\u003E\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Ci\u003EThe real-world example of interfaces is that we have multiple classes for different levels of employees working in a particular company and the necessary property of the class is the salary of the employees and this. We must be implemented in every class and. Also, it is different for every employee here. The concept of the interface is used. We simply create an interface containing an abstract salary method and implement it in all the classes and we can easily define different salaries of the employees.\u003C\/i\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cb\u003EExample\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv\u003E\/\/ Java Program to Demonstarte Concept of interfaces\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ Interfacce\u003C\/div\u003E\u003Cdiv\u003Einterface salary {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Evoid insertsalary(int salary);\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ Class 1\u003C\/div\u003E\u003Cdiv\u003E\/\/ Implementing the salary in the class\u003C\/div\u003E\u003Cdiv\u003Eclass SDE1 implements salary {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Eint salary;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E@Override public void insertsalary(int salary)\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Ethis.salary = salary;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Evoid printSalary() { System.out.println(this.salary); }\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\/\/ Class 2\u003C\/div\u003E\u003Cdiv\u003E\/\/ Implementing the salary inside the SDE2 class\u003C\/div\u003E\u003Cdiv\u003Eclass SDE2 implements salary {\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Eint salary;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E@Override public void insertsalary(int salary)\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Ethis.salary = salary;\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Evoid printSalary() { System.out.println(this.salary); }\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003Epublic class GFG {\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003Epublic static void main(String[] args)\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E{\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESDE1 ob = new SDE1();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003E\/\/ Insert different salaries\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Eob.insertsalary(100000);\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Eob.printSalary();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003ESDE2 ob1 = new SDE2();\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Eob1.insertsalary(200000);\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\t\u003C\/span\u003Eob1.printSalary();\u003C\/div\u003E\u003Cdiv\u003E\u003Cspan style=\"white-space: pre;\"\u003E\t\u003C\/span\u003E}\u003C\/div\u003E\u003Cdiv\u003E}\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cdiv\u003E\u003Cb\u003EOutput\u003C\/b\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv\u003E100000\u003C\/div\u003E\u003Cdiv\u003E200000\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cdiv style=\"text-align: center;\"\u003ESource:\u0026nbsp;geeksforgeeks.org\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/oraclejavacertified.blogspot.com\/feeds\/5892643244624769658\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2021\/07\/interfaces-and-polymorphism-in-java.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/5892643244624769658"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/5892643244624769658"},{"rel":"alternate","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2021\/07\/interfaces-and-polymorphism-in-java.html","title":"Interfaces and Polymorphism in Java"}],"author":[{"name":{"$t":"Keturah Carol"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/17621317473280987274"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEgujeomTKI-eFiuQ-JfbQFiTbT2lHaiAcu5B63ITr_BUHZz16msasZq3xoy9CsmdYyUrTLj7ymZwrau8y21x6rsrFRANX51rlFekfYYe7yGGx-h15PWuPoobpOH3ux2tKGehXykWKybI3M0\/s72-w640-h360-c\/javaoops.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-9163537232404844123.post-1323990731151034553"},"published":{"$t":"2021-07-14T10:11:00.002+05:30"},"updated":{"$t":"2021-07-14T10:11:06.616+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java AOP"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Java OOPs"}],"title":{"type":"text","$t":"Difference Between AOP and OOP"},"content":{"type":"html","$t":"\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EAOP vs OOP\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003EAOP (Aspect-oriented programming) and OOP (Object-oriented programming) are two programming paradigms. A programming paradigm is a fundamental style of computer programming. Programming paradigms differ in how each element of the programs is represented and how each step is defined for solving problems. As the name suggests, OOP focuses on representing problems using real-world objects and their behavior, while AOP deals with breaking down the programs in to separate crosscutting concerns.\u003C\/p\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EWhat is AOP?\u003C\/b\u003E\u003C\/h3\u003E\u003Cdiv style=\"text-align: center;\"\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEi9szV3Q0LfQwcVUaflgAFzk5xP0Usu8GKvOlRQsWXmwgyreuxw72hblk3EYzmnrHhLA_LLmaIYAAmP5SutBVjOSuf3JBP_RamV4V2lByimOlk1SPjKvp_bXsvW3HLfVq_FOp4eQGR_zuQW\/s860\/aop.jpg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg alt=\"Oracle Java Tutorial and Material, Oracle Java Exam Prep, Oracle Java Preparation, Oracle Java Career, Oracle Java Learning\" border=\"0\" data-original-height=\"458\" data-original-width=\"860\" height=\"340\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEi9szV3Q0LfQwcVUaflgAFzk5xP0Usu8GKvOlRQsWXmwgyreuxw72hblk3EYzmnrHhLA_LLmaIYAAmP5SutBVjOSuf3JBP_RamV4V2lByimOlk1SPjKvp_bXsvW3HLfVq_FOp4eQGR_zuQW\/w640-h340\/aop.jpg\" title=\"Difference Between AOP and OOP\" width=\"640\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cp\u003EAOP is a programming paradigm, which deals with breaking down a program in to cohesive areas of functionality (called concerns) that cut across multiple areas, in order to increase modularity. Support for abstractions (such as classes, methods, etc.) to group and encapsulate concerns in to unique entities is provided in many other programming paradigms. But concerns (such as “Logging”) are examples of crosscutting concerns, because every logged part of the system is affected by the strategy used for logging. The main focus of all AOP implementations is to have suitable crosscutting expressions to capture all concerns in a single location.\u003C\/p\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EWhat is OOP?\u003C\/b\u003E\u003C\/h3\u003E\u003Cdiv style=\"text-align: center;\"\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEg_2F2z25yUJmDr-JXzHf5siM2-fltWnJ9OqNutLUgTDbGu2BuqMbSWdfm7Az133zXja9qmQiwW2rd6ZJ77kYyzpGtORHSNHvdKothP3hIz0SuZhpP99x1W5_nDgAO72hFSZVTHeX_N6V2s\/s900\/oop.jpg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg alt=\"Oracle Java Tutorial and Material, Oracle Java Exam Prep, Oracle Java Preparation, Oracle Java Career, Oracle Java Learning\" border=\"0\" data-original-height=\"506\" data-original-width=\"900\" height=\"360\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEg_2F2z25yUJmDr-JXzHf5siM2-fltWnJ9OqNutLUgTDbGu2BuqMbSWdfm7Az133zXja9qmQiwW2rd6ZJ77kYyzpGtORHSNHvdKothP3hIz0SuZhpP99x1W5_nDgAO72hFSZVTHeX_N6V2s\/w640-h360\/oop.jpg\" title=\"Difference Between AOP and OOP\" width=\"640\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cp\u003EIn OOP, the focus is on thinking about the problem to be solved in terms of real-world elements, and representing the problem in terms of objects and their behavior. Classes depict the abstract representations of real world objects. Classes are like blueprints or templates, which gather similar items or things that can be grouped together. Classes have properties called attributes. Attributes are implemented as global and instance variables. Methods in the classes represent or define the behavior of these classes. Methods and attributes of classes are called the members of the class. An instance of a class is called an object. Therefore, an object is a data structure that closely resembles some real-world object.\u003C\/p\u003E\u003Cp\u003EThere are several important OOP concepts such as Data abstraction, Encapsulation, Polymorphism, Messaging, Modularity and Inheritance. Typically, encapsulation is achieved by making the attributes private, while creating public methods that can be used to access those attributes. Inheritance allows the user to extend classes (called sub classes) from other classes (called super classes). Polymorphism allows the programmer to substitute an object of a class in place of an object of its super class. Typically, the nouns found in the problem definition directly become classes in the program. And similarly, verbs become methods. Some of the most popular OOP languages are Java and C#.\u003C\/p\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EWhat is the difference between AOP and OOP?\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003EThe key difference between OOP and AOP is that the focus of OOP is to break down the programming task in to objects, which encapsulate data and methods, while the focus of AOP is to break down the program in to crosscutting concerns. In fact, AOP is not a competitor for OOP, because it emerged out of OOP paradigm. AOP extends OOP by addressing few of its problems. AOP introduces neat ways to implement crosscutting concerns (which might have been scattered over several places in the corresponding OOP implementation) in a single place. Therefore, AOP makes the program cleaner and more loosely coupled.\u003C\/p\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/oraclejavacertified.blogspot.com\/feeds\/1323990731151034553\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2021\/07\/difference-between-aop-and-oop.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/1323990731151034553"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/1323990731151034553"},{"rel":"alternate","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2021\/07\/difference-between-aop-and-oop.html","title":"Difference Between AOP and OOP"}],"author":[{"name":{"$t":"Keturah Carol"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/17621317473280987274"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEi9szV3Q0LfQwcVUaflgAFzk5xP0Usu8GKvOlRQsWXmwgyreuxw72hblk3EYzmnrHhLA_LLmaIYAAmP5SutBVjOSuf3JBP_RamV4V2lByimOlk1SPjKvp_bXsvW3HLfVq_FOp4eQGR_zuQW\/s72-w640-h340-c\/aop.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-9163537232404844123.post-3283894068127569251"},"published":{"$t":"2021-03-31T09:21:00.010+05:30"},"updated":{"$t":"2021-03-31T09:23:35.376+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java OOPs"}],"title":{"type":"text","$t":"Difference Between Structured Programming and Object Oriented Programming"},"content":{"type":"html","$t":"\u003Ch3 style=\"text-align: center;\"\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhG7TbSLTXgLwU8If5gWezFapSpgNZZ21tByRuMXp66rl7PzJSd-vGeXzgnoMJgUu1PdMb7qcMIcQ1uCYsx53nuM1yjezBH0IMqOMEv-AJHBy4NiD57x-L7ddxTZ1qkb06LtUhkZQiM_xTT\/s864\/OOP+vs+Procedure.JPG\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg alt=\"Structured Programming, Object Oriented Programming, Oracle Java Exam Prep, Oracle Java Preparation, Oracle Java Guides\" border=\"0\" data-original-height=\"330\" data-original-width=\"864\" src=\"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhG7TbSLTXgLwU8If5gWezFapSpgNZZ21tByRuMXp66rl7PzJSd-vGeXzgnoMJgUu1PdMb7qcMIcQ1uCYsx53nuM1yjezBH0IMqOMEv-AJHBy4NiD57x-L7ddxTZ1qkb06LtUhkZQiM_xTT\/s16000\/OOP+vs+Procedure.JPG\" title=\"Difference Between Structured Programming and Object Oriented Programming\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\u003C\/h3\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EStructured Programming vs Object Oriented Programming\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003EObject Oriented Programming (OOP) and Structured Programming are two programming paradigms. A programming paradigm is a fundamental style of computer programming. Programming paradigms differ in how each element of the programs is represented and how steps are defined for solving problems. As the name suggests, OOP focuses on representing problems using real-world objects and their behavior, while Structured Programming deals with organizing the program in a logical structure.\u003C\/p\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EWhat is Structured Programming?\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003EIt is assumed that the birth year of Structured Programming is 1970. Structured programming is considered a subset of imperative programming. A structured program is made up of simple program flow structures, which are hierarchically organized. They are sequence, selection and repetition. Sequence is an order of statements. Selection means selecting a statement from a set of statements based on the current state of the program (for e.g. using if statements) and repetition means executing a statement until a certain state is reached (for e.g. using for or while statements). ALGOL, Pascal, Ada and PL\/I are some of the structured programming languages used today.\u003C\/p\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EWhat is Object Oriented Programming?\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003EIn OOP, the focus is on thinking about the problem to be solved in terms of real-world elements and representing the problem in terms of objects and their behavior. Classes depict the abstract representations of real world objects. Classes are like blueprints or templates, which gather similar items or things that can be grouped together. Classes have properties called attributes. Attributes are implemented as global and instance variables. Methods in the classes represent or define the behavior of these classes. Methods and attributes of classes are called the members of the class. An instance of a class is called an object. Therefore, an object is a data structure that closely resembles some real-world object.\u003C\/p\u003E\u003Cp\u003EThere are several important OOP concepts such as Data abstraction, Encapsulation, Polymorphism, Messaging, Modularity and Inheritance. Typically, encapsulation is achieved by making the attributes private, while creating public methods that can be used to access those attributes. Inheritance allows the user to extend classes (called sub classes) from other classes (called super classes). Polymorphism allows the programmer to substitute an object of a class in place of an object of its super class. Typically, the nouns found in the problem definition directly become classes in the program. And similarly, verbs become methods. Some of the most popular OOP languages are Java and C#.\u003C\/p\u003E\u003Ch3 style=\"text-align: left;\"\u003E\u003Cb\u003EWhat is the difference between Structured Programming and Object Oriented Programming?\u003C\/b\u003E\u003C\/h3\u003E\u003Cp\u003EThe key difference between Structured Programming and OOP is that the focus of Structured Programming is to structure the program in to a hierarchy of subprograms while, the focus of OOP is to break down the programming task in to objects, which encapsulate data and methods. OOP is considered more flexible than structured programming, because OOP separates a program in to a network of subsystems rather than structuring the program in to a hierarchy. Even though structuring provides certain clarity, a small change to a very large structured program may cause a ripple effect of having to change multiple subprograms.\u003C\/p\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/oraclejavacertified.blogspot.com\/feeds\/3283894068127569251\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2021\/03\/structured-object-oriented-programming.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/3283894068127569251"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/9163537232404844123\/posts\/default\/3283894068127569251"},{"rel":"alternate","type":"text/html","href":"https:\/\/oraclejavacertified.blogspot.com\/2021\/03\/structured-object-oriented-programming.html","title":"Difference Between Structured Programming and Object Oriented Programming"}],"author":[{"name":{"$t":"Keturah Carol"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/17621317473280987274"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/blogger.googleusercontent.com\/img\/b\/R29vZ2xl\/AVvXsEhG7TbSLTXgLwU8If5gWezFapSpgNZZ21tByRuMXp66rl7PzJSd-vGeXzgnoMJgUu1PdMb7qcMIcQ1uCYsx53nuM1yjezBH0IMqOMEv-AJHBy4NiD57x-L7ddxTZ1qkb06LtUhkZQiM_xTT\/s72-c\/OOP+vs+Procedure.JPG","height":"72","width":"72"},"thr$total":{"$t":"0"}}]}});