Pages
- Home
- About
- 1.Java - Language Fundamental
- 2.Java - Operator & Assignments
- 3.Java - Flow Control
- 4.Java - Access Modifiers
- 5.Java - OOPs Concept
- 6.Java - Exception Handling
- 7.Java - Multithreading
- 8.Java - Garbage Collection
- 9.Java - java.lang Package
- 10.Java - java.io package
- 11.Java - Collection Framework
- 12.Java - Enum
- 13.Java - Generics
- 14.Java - Assertions
- Java Programming Questions
- Today's Laptops & Mobiles Hot Deals
- Install java(jdk) & Set path & Run program
Flipkart add sale
Java-Method Overloading / Chapter - 6 / OOP's Concept
Two methods are said to be overloaded method if and only if, both methods having the same name but different arguments types.
Java- Overloading / Chapter - 6 / OOP's Concept
Overloading:-
- Two methods are said to be overloaded method if and only if ,both methods having same name but different arguments types.
- In old language like C method overloading concept is not available hence ,we can't declare multiple methods with same name but different arguments types.
- But in Java , we can declare multiple methods with same name but different arguments types.Such type of methods are called overloaded method. This overloading feature of java reduces the complexity of programming. example:class Test{public void m1( ){System.out.println( "no - arguments m1() method");}public void m1( int x){System.out.println( "integer - arguments m1() method");}public void m1( double y){System.out.println( "double - arguments m1() method");}public static void main( String [ ] args){Test t = new Test( );t.m1( );t.m1(20 );t.m1(20.5);}}Output is:
Java- Method Signature / Chapter -5 / OOP's Concept
1. In Java method signature consists of, methods names followed by arguments types.
2. Return Type is not part of the method signature in java.
3.The compiler will use method signature to resolve method calls.
example:-
3.The compiler will use method signature to resolve method calls.
example:-
Java- Method Signature / Chapter -5 / OOP's Concept
1. In Java method signature consists of, methods names followed by arguments types.
2. Return Type is not part of method signature in java.
3.Compiler will use method signature to resolve method calls.
example:-
class Test
{
public void m1(int i)
{
System.out.println(int type arguments");
}
public void m1(String s)
{
System.out.println(String type arguments");
}
2. Return Type is not part of method signature in java.
3.Compiler will use method signature to resolve method calls.
example:-
class Test
{
public void m1(int i)
{
System.out.println(int type arguments");
}
public void m1(String s)
{
System.out.println(String type arguments");
}
public static void main(String [ ] args )
{
Test t =new Test( );
t.m1(10);
t.m1("javabychetan");
}
}
Output
Java Inheritence / Chapter -4 / OOP's Concept
Inheritance
- It is also known as Is-A relationship.
- The main advantage of inheritance is code reuse-ability.
- By using extends keyword we can implement Is-A relationship.
example:-
class P
{
public void m1()
{
System.out.println("Parent");
}
}
class C extends P
{
public void m2( )
{
System.out.println("Child");
}
Class Test
{
public static void main(String [ ] args)
{
C c =new C ( );
c.m1( );
c.m2( );
}
}
Output is:
Java- Inheritence / Chapter -4 / OOP's Concept
Inheritance:-
- It is also known as Is-A relationship.
- The main advantage of inheritance is code reuse-ability.
- By using extends keyword we can implement Is-A relationship.
example:-
class P
{
public void m1()
{
System.out.println("Parent");
}
}
class C extends P
{
public void m2( )
{
System.out.println("Child");
}
Class Test
{
public static void main(String [ ] args)
{
C c =new C ( );
c.m1( );
c.m2( );
}
}
Output is: Parent
Child
Conclusion:-
- Whatever method parent class has by default available to the child class and hence on the child reference we can call Both Parent & Child class methods.
Java- Encapsulation / Chapter -3 / OOP's Concept
Java- Abstraction / Chapter -2 / OOP's Concept
Abstraction:-
Hiding internal implementation and just highlighting the set of services what we are offering, is known as "Abstraction".
example:-
Through Bank ATM GUI screen bank people are highlighting the set of services what they are offering without highlighting internal implementation.
The main advantage of Abstraction are:-
Java- Abstraction / Chapter -2 / OOP's Concept
Abstraction:-
Hiding internal implementation and just highlighting the set of services what we are offering , is known as "Abstraction".example:-
Through Bank ATM GUI screen bank people are highlighting the set of services what they are offering without highlighting internal implementation.
The main advantage of Abstraction are:-
Subscribe to:
Posts (Atom)
© Copyright 2017 Javabychetan.blogspot.com |







