Thursday 4 June 2015

Overloading in Java

Static members (eg main()) can't access non sttic members (any instance variable) directly i.e. without an object.
The default access specifier in Java is equivalent public and not exactly public i.e it is public for a package, across package access will not be allowed.

int a=sc.nextInt("Enter a number\n")

float is a raw data type
float is a user defined data type [wrapper class]

Overloading:
Method overloading is also known as static overloading
1) same method names
2) NO. of arguments:
if same:
check data types:
if same:
then not overloaded
else:
overloaded
else:
overloaded

3) return type of a method does not effect whether methods are overloaded or not

Example: the method to find the areas of different polygons can be implemented using the overloading concept.

No comments:

Post a Comment