OVERRIDING whenever method of parent class is implemented by its child classes used same type and argument that method called us overriden method and that process called overriding example class Parent { public void display() { System.out.println("display method is called"); } } class Child { // overriden method public void display() { System.out.println("display method is called"); } NOTE 1)modifier will change with which have higher priorty in overriden method like class Parent { protected void display() { System.out.println("display method is called"); } } class Child { // overriden method public void display() { System.out.println("display method is called"); } public> protected>default...
Posts
Showing posts from March, 2018
- Get link
- X
- Other Apps
OVERLOADING IN JAVA 2 type of overloading 1. method overriding Providing multiple implemention of any method inside the same class is called as overloading. 2. constructor overloading Providing multiple implemention of any constructor inside the same class is called as constructor overloading. NOTE overloading can be performed by only change the number of argu,data type and number of order method overloading is implementing polymorphysm in java. example // overloaded methhod class sum { int a; int b; sum() { } sum(int a,int b) { this.a=a; this.b=b; } public void add(int a,int b) { System.out.println("sum of "+a+" and "+b+" : "+(a+b)); } // overloaded methhod public void add(float a,float b) { ...
- Get link
- X
- Other Apps
NON STATIC INNER CLASS whenever class is define without static keyword that is class non static inner class. following characteristics 1)It's object cannot created independently thats means object of outer class is require for instantiate inner class Object OuterClass ref = new OuterClass(); OuterClass.InnerClass ref2 = ref.new InnerClass(); 2) It can access private static and non static datamember of its Outerclass inside the inner class. ex class Outer { private int x; \\ non static datamember private static y;\\ static datamember Outer(int a) \\ constructor { x=a; } static\\ static block for instantiate { } class Inner { int z; Inner(int z) { this.z=z; } public void display() { ...