18. An example of method overloading is –

class Room {                 float length;                 float width;                 Room(float x,float y)                 {                                 length=x;                                 width=y;                 }                 Room(float x)                 {                                 length=width=x;                 }                 float area()                 {                                 return (length*width);                 } } class Test {                 public static void main(String args[])                 {                                 Room area=new... Continue Reading →

Advertisements

Array: –

Array: - An array is a group of contiguous or related data items that share a common name. for instance, we can define an array name salary to represent a set of salaries of a group of employees. A particular value is indicated by writing a number called index number or subscript in a square... Continue Reading →

17. An example of constructor –

class Rectangle {                 int length,width;                 Rectangle(int x,int y)                 {                                 length=x;                                 width=y;                 }                 int rectArea()                 {                                 return(length*width);                 } } class RectangleArea {                 public static void main(String args[])                 {                                 Rectangle rect=new Rectangle(10,20);                                 int area=rect.rectArea();                                 System.out.println("Area = "+area);                 } }

Multiple classes in inheritance: –

Multiple classes in inheritance: - Reusability is yet another aspect of object oriented programming paradigm. It is always nice if we could reuse something that is already exists rather than creating the same all over again. Java support this concept. Java classes can be reused in several ways. This is basically done by creating new... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: