18.INHERITANCE 19.OVERRIDING 20.INTERFACES 21.ABSTRACT CLASSESS 22.SUPER 23.ACCESS SPECIFIERS
INHERITANCE: ************ It is a process of extending some of the properties of existing class and adds some more feature,by the create a new class. the existing class is called super class or base class or parent class. the new class is called derived class or sub class or child class it introduces the concept of re usability,with out modifying the existing properties. types of inheritance: 1.Single Inheritance A--->B 2.multiple Inheritance A,b,c.. ---> c 3.multilevel Inheritance A--->B--->C OVERRIDING: *********** In inheritance,if both parent class and child class having same method signatures,then child class methods will not allow the parent class methods to be executed.This is called member overriding. ->this is used to execute its own behavior by hiding the implementations of parent class. ->But in some cases,there is a need to call parent class methods through child class,then we have to use the 'super' key word' before the parent class member method. ->It refers to the parent class up to 1 level back because java provides single level inheritance only. ->super keyword cannot be applied to static members. INTERFACES: *********** Interface is a mechanism to provide the security to the server side application by hiding some of the services and gives only those services which are required to the end users. ->Interface is nothing but a collection of final variables and public abstract methods. ->Interface itself is an abstract and all the methods in interface are public abstract by default. if user didnt give then automatically taken by jvm as public. ->Interface variables are final and static variables. ->we cannot create instance to the interfaces ->We have to implement the methods of the interface by using a class.The class which implements interface must implements all the methods in the interface otherwise we have to make the class is abstract. ->Interface is used to provide multiple inhertance type of mechanism so that we can implement more than one interfaces by using a class. ->One interfaces may be extended from more than one interface. ->Interface does not have the concrete methods. ->interface only contains constants. //->super keyword cannot be applied to interface methods. ->syntax: interface interface-name { // final variables //abstract methods } class class-name implements interface-name { //definations of methods in the interfaces //definations of its own methods. } ABSTRACT CLASSES: ***************** ->In some of the cases,it is not possible to give definations to the some of the methods. ->Even though you are trying to give definations to the methods, it is meaningless.such types of methods are called abstract methods ->The class,which contains these abstract methods,will be treated as abstract class. ->The abstract methods only specify the what to do,but not how to do.abstract class may or may not have the concrete methods. ->we cannot create instance to the abstract class. ->So abstract classes are always treated as parent classes. ->we have to use 'abstract' keyword to make the class or method as abstract. any method with out definition in a class has to be declared as abstract. any class that has one or more abstract methods should be declared as abstract without abstract method ,a class can be declared as abstract to declare a class as abstract simply declare the abstract key word before the class name. user cant create reference of object for abstract class because it hasnt complete functionality. //do not apply abstract for constructors no modifier method can be as protected and public protected method can be as protected and public public method can be public method. ---abstract methodname()---- ---abstract class class-name---- SUPER KEYWORD: ************** super is a keyword it has to main applications 1.calling superclass methods 2.calling superclass constructors it denotes super class object. ACCESS SPECIFIERS: ****************** Access specifiers are used to give the permissions to use the another class functionalities in our class. It provides and increase the security concept with the help of access specifiers. Access specifiers are four types 1.private 2.protected 3.public 4.no modifiers ->private members are not inheritable and not accesessble members scope is with in the class. ->protected members are inheritable but these are only accesses by sub class only.These members can be accessed with in the class and its child class. ->no modifier: in java,if donot specify any access specifier it will not be treated as private.the scope of these variables is with in the package. ->public members are fully accessable with all.these members can be accessed any where.
No comments:
Post a Comment