Method overloading.
In this article,Method overloading is explained in detail with examples.
Two or more methods in a single class with same name and atleast one difference in the signature is known as method loading.
Signature means a number of arguments, the order of arguments and data type of arguments.
Ex
class A
{
---Data members---;
---Constructors----;
void m1(int,int){---}
void m1(float,float){---}
void m1(int,float){---}
void m1(float,int){---}
Two or more methods in a single class with same name and atleast one difference in the signature is known as method loading.
Signature means a number of arguments, the order of arguments and data type of arguments.
Ex
class A
{
---Data members---;
---Constructors----;
void m1(int,int){---}
void m1(float,float){---}
void m1(int,float){---}
void m1(float,int){---}
Method Overriding and Object as a class Member.
In this article,Method Overriding and Object as a class Member are explained in detail with example.
Method overriding is related to inheritance, Here we re-define method of a base class in a subclass with the same name and same signature i.e, the number of arguments, the order of arguments, the data type of arguments, all should be same.
Method overriding is related to inheritance, Here we re-define method of a base class in a subclass with the same name and same signature i.e, the number of arguments, the order of arguments, the data type of arguments, all should be same.
Ex
//program related to Method Overriding and Object as a class Member--method overriding
class ParentClass
{
void parentMethod() //over ridden method---
{
System.out.println("Parent class Method");
}
Method Calling Mechanisms in Java.
In this article,Method Calling Mechanisms in Java is explained in detail with an example.
Based on nature of arguments used to call a user defined method in java, we have two types of method calling mechanisms.They are
Based on nature of arguments used to call a user defined method in java, we have two types of method calling mechanisms.They are
- Call by value.
- Call by reference.
Call by Value
In this mechanism, we pass a copy of actual arguments to call a user-defined method and formal parameters are also of same data type.
Any changes done with formal parameters are NOT reflected to actual arguments.
Ex
//program related to Method Calling Mechanisms in Java--call by value.
Access Modifiers in Java.
In this article,Access Modifiers in Java is explained in detail with examples.
This concept represents scope/visibility/accessibility of different members of a class for usage.
Java supports four access modifiers:
a.Public
b.Protected
c.Default
d.Private
* If no modifier is used then it is default we use default in the switch case.
Using: D=direct access.
obj=object access.
This concept represents scope/visibility/accessibility of different members of a class for usage.
Java supports four access modifiers:
a.Public
b.Protected
c.Default
d.Private
* If no modifier is used then it is default we use default in the switch case.
Using: D=direct access.
obj=object access.
Subscribe to:
Posts (Atom)