• Document: OOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.
  • Size: 647.54 KB
  • Uploaded: 2019-01-12 17:48:34
  • Status: Successfully converted

Some snippets from your converted document:

OOPs Concepts 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8. Type Casting Let us discuss them in detail: 1. Data Hiding:  Every Java project has following structure. Project Package_1 Package_2 Package_n Class_1 Class_2 Class_21 Class_22 Class_n Method_1 Method_21 Method_21 Method_n1 Method_12 Method_22 Method_22 Method_n2  Data can reside in either class or methods.  We can hide data in class or method from other classes and methods of a same project or other project.  Hiding of data can be on project level, package level or class level. If package level hiding is applied, then no other package in same project or different project can access the data.  Data hiding is achieved using Access modifiers.  There are four access modifiers: private, protected, public and default.  Private: i. If we declare any member of a class as private then no one can access them outside of the class in which they are declared and defined. ii. Private members are accessible with class only. iii. We can apply private modifiers to variables, methods and constructors only. iv. Ex. (Refer above diagram) If I declare method_1as private then it will only be visible to objects of class_1.  Public: i. If we declare any member of a class as public then they will become accessible to everyone in project and outside project as well. ii. We can apply public modifiers to variables, methods, constructors and classes.  Default: i. Default members are accessible inside package only in which they are declared and defined. ii. Ex. If we make method_1 as default, then object of class_21 cannot access it as class_21 is in different package. Whereas it will be accessible to object of class_2 iii. We can apply default modifier to variables, methods, constructors and classes  Protected: i. Protected members are accessible to child and grandchildren of the current class. ii. Ex. If we make method_1 as protected and class_2 as child of class_1 then only class_2 can access method_1. iii. We can apply protected modifier to variables, methods, constructors. 2. Abstraction:  Hiding background implementation of the services is abstraction.  Let say we want to build an application for e-commerce. Then we cannot disclose our business information to everyone. We would just disclose set of services we may offer but not the procedure of how we will offer the services.  Greatest example of abstraction would be a bank ATM machine, which displays different services an ATM can offer. But it doesn’t allow you to view the background implementation of the services.  By using abstraction we can maintain security and confidentiality among our business.  We can achieve abstraction by means of Abstract classes and Interfaces. Sr. Abstract Class Interface No Abstract class is used to achieve 0 Interface is used to achieve 100% 1 to 100% abstraction abstraction Every method of abstract class Compulsorily every method in should be public and abstract. But interface should be public and 2 concrete methods are also abstract allowed We can use any modifiers for the We can use only private, protected, 3 abstract class methods static, final and synchronized modifiers for the interface methods. Abstract class variables need not Every variable inside interface are 4 be public ,static and final by default public, static and final. It is not compulsory to initialize We should compulsorily initialize 5 abstract class variables variables in interface Inside abstract class we can Inside interface we

Recently converted files (publicly available):