Java Blue

By admin. Filed in Travel In USA  |  
TOP del.icio.us digg

Java Blue

Legacy Concepts in Java

Legacy

  • One of the strengths OOPS "is the legacy. Legacy allows the creation of hierarchical classifications "of Classes.
  • Inheritance means, you can create a general category that defines certain properties common to a set of related components, and then this class can be inherited by other classes, each addition of these properties.
  • Super class: in Java, a class that is inherited is called super class.
  • Sub class: Java class that the inheritance is called a subclass. In other words, a subclass is a specialized version of a super class. It inherits all the instance variables methods authorized and permitted members, defined by the super class and adds its own unique elements.
  • The superclass can also be used to create an object in main () also a sub-class can be a superclass for another subclass.
  • To inherit a class, just use extends keyword
  • The general form of a class declaration that inherits from super

class subclass of super-extended name (name

/ / Body of class.

)

  • Remember

ü You can specify a single super class for the entire sub-class. (Java does not support multiple inheritance of classes, one class in which differs from C + +, in which you can inherit multiple base classes, one derived class). For example, Java does not support multiple inheritance, but only supports multi-level inheritance.

ü No class can be a super class of this home.

/ *

This program illustrates the power of heredity. Box class is a superclass and inherits classBoxWeight in the Box class, using the keyword extends

*

class Box (

double width, height, depth;

/ / Constructor used when none of specified dimensions.

Box () (

Height = width = -1;

)

/ / Constructor used at all specified dimensions.

Box (w double, double h, double d) (

hw = width, height =, D = depth;

)

/ / Constructor used when cube is created.

Box (double sided) (

Height side width = = =;

)

/ / Construct clone of an object

Box (Box obj) (

obj.width width =;

obj.height height =;

depth obj.depth =;

)

/ / Calculate the volume of return

double volume () (

return depth * height * depth;

)

)

/ / Here, safety is extended to weights

BoxWeight class extends Box (

double weight; / / Weight box

/ / Constructor for the class BoxWeight

BoxWeight (w double, double h, double d, double m) (

width = w;

h = height;

depth = D;

m = weight;

)

)

Class BoxWeightDemo (

public static void main (String args []) (

BoxWeight MyBox1 BoxWeight = new (23.33,33.33,43.33,50);

BoxWeight MyBox2 BoxWeight = new (33.33,43.33,53.33,150);

vol = twofold MyBox1.volume ();

System.out.println ("MyBox1 volume is:" + Flight);

System.out.println ("weight of MyBox1 is: "+ + MyBox1.weight" kgs ");

vol = MyBox2.volume ();

System.out.println ("MyBox2 volume is: "+ Vol);

System.out.println ("weight MyBox2 is:" + + MyBox2.weight "kgs");

)

)

Explanation: A key advantage of legacy is that once a class is created, it can be used as a super class to create any number of subclasses and each subclass can precisely tailor its own classification. Now consider this example, which again makes use of the Box class.

/ * A class inherits Box and adds color attribute * /

/ * This program illustrates the power of inheritance * /

class Box (

double width, height, depth;

/ / Constructor used when no specified dimensions.

Box () (

Height = width = -1;

)

/ / Constructor used when all dimensions specified.

Box (w double, double h, double d) (

w = width;

h = height;

depth = D;

)

/ / Constructor used when cube is created.

Box (double sided) (

Height Width = = = Depth later;

)

/ / Construct an object clone

Box (Box obj) (

obj.width width =;

obj.height = height;

obj.depth = depth;

)

/ / Calculate the volume of return

double volume () (

return depth * depth * height;

)

)

/ / Here, safety is extended to include color

BoxColor class extends Box (

string color / / color of box

/ / Constructor for the class BoxColor

BoxColor (w double, double h, double d, String str) (

w = width;

h = height;

depth = D;

color = str;

)

)

Class BoxColorDemo (

public static void main (String args []) (

BoxColor MyBox1 = BoxColor new (23.33,33.33,43.33, "red");

BoxColor MyBox2 BoxColor = new (33.33,43.33,53.33, "Blue");

vol = twofold MyBox1.volume ();

System.out.println ("MyBox1 volume is:" + Flight);

System.out.println ("Color MyBox1 is: "MyBox1.color +);

vol = MyBox2.volume ();

System.out.println ("MyBox2 volume is:" + vol);

System.out.println ("Color MyBox2 is:" MyBox2.color +);

)

)

Explanation: Compare this subclass ColorBox and BoxWeight. Each subclass adds its own unique characteristics. The strength of inheritance.

A variable can refer Super-sub-class of objects

  • A reference variable of a superclass can be assigned a reference a sub-group derived from that of the superclass.
  • This aspect of inheritance is very useful in a variety of situations.

/ * Consider the following example in which a buffer super class variable of a subclass object .* /

Box class (

Double width, length, height

Box ()

(

Width = Height =- length = 1;

)

Box (double side)

(

WIDTH = Length = height = side;

)

Box (double width, double length, double height)

(

this.LENGTH LENGTH =;

this.width = width;

this.Height = height;

)

Box (Box obj)

(

WIDTH = Obj.WIDTH;

LENGTH = obj.LENGTH;

HEIGHT = obj.WIDTH;

)

double volume () (

return (Length * width * height);

)

)

BoxWeight class extends Box

(

double weight;

BoxWeight ()

(

super ();

WEIGHT =- 1;

)

BoxWeight (double sided, double weight)

(

super (side);

this.WEIGHT = weight;

)

BoxWeight (double width, double length, double height, double weight) (

super (width, length, height);

this.WEIGHT = weight;

)

BoxWeight (BoxWeight obj) (

super (obj);

this.WEIGHT = obj.WEIGHT;

)

)

RefDemo class

(

public static void main (String args [])

(

weightbox BoxWeight BoxWeight = new (3,5,7,8.37);

Box Plainbox = new Box ();

System.out.println ("The volume of the box" weightbox.volume + ());

System.out.println ("The weight of zone "weightbox.WEIGHT +);

/ / Now assign reference to the Framework BoxWeight

Plainbox = Weightbox;

/ / The following statement is valid because the box set volume () method

System.out.println ("The volume box "+ plainbox.volume ());

/ / The following statement is invalid because Box doesnot define the weight members

/ / System.out.println ("The weight of the box" plainbox.WEIGHT +);

)

)

Explanation: the type of reference variable, which determines what members can be consulted. When there is a reference to a subclass object is assigned to a reference variable of the superclass, we have access to those parts of the object defined by the superclass. This makes sense because no superclass not aware of what a subclass adds to it.This is why the family code in the above program is illegal and therefore is commented.

Members access and inheritance

  • Even if a subclass includes all members of its super class, it can not access these members of the superclass that have been declared as private.
  • Java provides a solution for this problem, using a keyword super.

Possible use

  • When u say member variables of a class using access specifiers, private, and if you use this class in the super class, then there would be no way for a sub-class or go directly to the initialization of these variables on its own initiative (because the primary attribute of OOP, the encapsulation is implemented).
  • Java provides a solution for this problem, using a super keyword.
  • Whenever a subclass needs to refer to its super class, it can do so by using super.
  • super has two general types of uses:
  1. The first use is, call the manufacturer of the Super.
    1. The second use is to access a member of the superclass that has been hidden by a member of a subclass. The member can be either a member variable or member of a class method
  • Lets examine the use great, in detail
  1. First use of super:

Possible use call the super class constructors.

A subclass can call a super class constructor method, using the following form of super

super (parameter-list)

Here parameter-list specifies the parameters needed, if any, by the manufacturer in the super class.

  • Remember super () must always be the first statement, to be run in the side of subclasses

manufacturer.

/ *

can return to the example and save BoxWeigthDemo.java as BoxWeigthDemo1.java.

This program illustrates the power of ecapsulation and use the keyword super in inheritance

process

*

/ / A full implementation of BoxWeight

/ *

This program illustrates the power of heredity

*

Class Box

(

private double width;

private double height;

private double depth;

/ / Constructor used when none of the specified dimensions.

Box ()

(

Height = Width = -1;

)

/ / Constructor used when cube is created.

Box (double sided)

(

Height side width = = =;

)

/ / Constructor used when all dimensions specified.

Box (w double double h, double d)

(

w = width;

H = height;

depth = D;

)

/ / Construction of clone an object

Box (Box obj)

(

obj.width width =;

obj.height height =;

obj.depth = depth;

)

/ / Calculate the volume of return

double volume ()

(

depth back * Height *;

)

)

/ / Here, the box is extended to weights

BoxWeight class extends Box

(

double weight; / / Weight of box

/ / Constructor for the class without values initialized BoxWeight

BoxWeight ()

(

super ();

weight =- 1;

)

/ / Constructor for the class BoxWeight to create a cube object

BoxWeight (len double, m)

(

super (len);

weight = m;

)

/ / Constructor for the class BoxWeight, accepting four arguments (three sides and one of weight)

BoxWeight (double w, h double, d, double m)

(

super (W, H, D);

m = weight;

)

/ / Constructor for the class BoxWeight

BoxWeight (Box obj, double m)

(

super (obj);

m = weight;

)

)

/ / Implementation of class BoxWeight

BoxWeightDemo1 class

(

public static void main (String args [])

(

BoxWeight MyBox1 BoxWeight = new (23.33,33.33,43.33,50);

BoxWeight MyBox2 BoxWeight = new (33.33,43.33,53.33,150);

BoxWeight mybox3 BoxWeight = new (MyBox1, 150);

vol = twofold MyBox1.volume ();

System.out.println ("MyBox1 volume is:" + Vol);

System.out.println ("weight MyBox1 is:" + + MyBox1.weight "kgs");

vol = MyBox2.volume ();

System.out.println ("MyBox2 volume is:" + Flight);

System.out.println ("weight MyBox2 is:" + + MyBox2.weight "kgs");

vol = MyBox3.volume ();

System.out.println ("mybox3 volume is:" + vol);

System.out.println ("weight of mybox3 is: "+ + MyBox3.weight" kgs ");

)

)

Explanation: Super is called with an object BoxWeight not type box. This invokes the constructor (Box obj) Box.

lets consider another example, consider now BoxColorDemo class again

/ / Implementation complete BoxColor

/ * This program illustrates the power of inheritance * /

class Box

(

private double width, height, depth;

/ / Constructor used in the absence of specified dimensions.

Box ()

(

width = height = depth = -1;

)

/ / Constructor used when all specified dimensions.

Box (w double, double h, double d)

(

w = width;

h = height;

depth = D;

)

/ / Constructor used when cube is created.

Box (double sided)

(

Height side width = = =;

)

/ / Construct an object clone

Box (Box obj)

(

obj.width width =;

obj.height height =;

obj.depth = depth;

)

/ / Calculate the volume of return

double volume ()

(

return depth * depth * height;

)

)

/ / Here the box is extended to include color

class Box extends BoxColor

(

string color / / color of box

/ / Constructor BoxColor for, for a cube, the class

BoxColor (double len, String str)

(

super (len);

color = str;

)

/ / Constructor for the class BoxColor

BoxColor (w double, double h, double d, String str)

(

super (W, H, D);

color = str;

)

/ / Constructor for the class accept BoxColor class object as a parameter of type

BoxColor (obj Box, String str)

(

super (obj);

color = str;

)

)

/ / Implementation BoxColor

BoxColorDemo1 class

(

public static void main (String args [])

(

BoxColor MyBox1 BoxColor = new (23.33,33.33,43.33, "red");

BoxColor MyBox2 BoxColor = new (33.33,43.33,53.33, "blue");

BoxColor mybox3 BoxColor = new (MyBox1, "blue");

vol = twofold MyBox1.volume ();

System.out.println ("Volume of MyBox1 is: "+ vol);

System.out.println ("Color MyBox1 is:" MyBox1.color +);

vol = MyBox2.volume ();

System.out.println ("MyBox2 volume is:" + vol);

System.out.println ("Color MyBox2 is:" MyBox2.color +);

vol = MyBox3.volume ();

System.out.println ("mybox3 volume is:" + vol);

System.out.println ("Color mybox3 is: "MyBox3.color +);

)

)

Explanation: Super is called with an object and not BoxColor type box. This invokes yet the manufacturer (obj box) Box.

  • Remember

ü When a class under calls super () it is to call the constructor of its immediate super class.

Super U () always returns the superclass immediately above the class of Appeal.

ü In addition, super () must always be the first instruction to execute within a subclass constructor.

1.1 Lets look great in the hierarchy at different levels, the program below which shows the use

/ *

In this program the box is used as a class of super BoxWeight and (sub-class) Box weight

used as super class shipping

*

Class Box

(

private double width;

private double height;

private double depth;

/ / Constructor used when none of the specified dimensions.

Box ()

(

Height = width = -1;

)

/ / Constructor used when cube is created.

Box (double side)

(

Height side width = = =;

)

/ / Constructor used when all dimensions specified.

Box (w double, double h, double d)

(

w = width;

H = height;

depth = D;

)

/ / Construct an object clone

Box (Box obj)

(

obj.width width =;

obj.height height =;

obj.depth = depth;

)

/ / Calculate the volume of return

double volume ()

(

return depth * height *;

)

)

/ / Here, Box class is extended to include the weight

BoxWeight class extends Box

(

double weight; / / Weight of box

/ / Constructor used when the dimensions are not specified, for class BoxWeight

BoxWeight ()

(

super ();

weight = -1;

)

/ / Build a cube BoxWeight class

BoxWeight (len double, m)

(

super (len);

weight = m;

)

/ / Constructor for the class BoxWeight when all dimensions are specified.

BoxWeight (w double, double h, double d, double m)

(

super (W, H, D);

m = weight;

)

/ / Build a clone for class BoxWeight

BoxWeight (Obj BoxWeight)

(

super (obj);

Obj.weight = weight;

)

)

/ / Here BoxWeight class is extended to include the cost

Ship class extends BoxWeight

(

double cost;

/ / Construction in the absence of values are provided

Shipping ()

(

super ();

cost = -1;

)

/ / Construct the cube when creating

Shipping (double sided, double m, double c)

(

super (side, m)

Cost = c;

)

/ / Build where all the values provided

Expedition (w double, h double d, m double, c)

(

super (w, h, d, m);

Cost = C;

)

/ / Construction clone object

Shipping (dispatching)

(

super (obj);

cost obj.cost =;

)

)

ShipMentDemo class

(

public static void main (String args [])

(

Expedition MyBox1 = new Shipment (23.33,33.33,43.33,50,153.89);

Shipping MyBox2 = new Shipment (33.33,150,304.78);

Shipping mybox3 = New Shipment (MyBox1);

vol = twofold MyBox1.volume ();

System.out.println ("MyBox1 volume is:" + vol);

System.out.println ("weight MyBox1 is:" + + MyBox1.weight "kgs");

System.out.println ("weight MyBox1 is:" + MyBox1.cost +"/-");

vol = MyBox2.volume ();

System.out.println ("MyBox2 volume is:" + vol);

System.out.println ("weight MyBox2 is:" + + MyBox2.weight "kgs");

System.out.println ("weight MyBox2 is:" + MyBox2.cost +"/-");

vol = MyBox3.volume ();

System.out.println ("mybox3 volume is:" + vol);

System.out.println ("weight mybox3 is:" + + MyBox3.weight "kgs");

System.out.println ("weight mybox3 is: "+ MyBox3.cost +"/-");

)

)

Explanation

1.2 What order, manufacturers are called?

  • In a class hierarchy, constructors are called in the order of derviation, which is super class to sub class,
  • In addition, since the super () must be the first instruction to be executed in a constructor subclass. This order is the same than not, super () is used. If super () is not used, then the default (lower setting) for each class will run the super constructor.

Lets understand the above said with a example below

/ *

A demonstration program to call, builders

*

Class A

(

int i, j;

A ()

(

System.out.println ("Hi The manufacturer of a class is called");

)

)

class B extends A

(

int k, l;

B ()

(

System.out.println ("Hi The constructor of the class B is called ");

)

)

C extends class B

(

int m, n;

C ()

(

System.out.println ("Hi The constructor of the class C is called");

)

C (int x, int y)

(

m = x;

n = y;

System.out.println ("Hi The constructor of the class C is called value of m and n "+ m + n +);

)

)

OrderOfConsDemo class

(

public static void main (String args [])

(

C = C obj1 new ();

Obj2 = new C C (1,2);

)

)

Explanation: Observe put both objects obj1 and obj2.

  1. second use of super:

For access members of the class super hidden by members of the subclass. The member may

either a variable or method of a class. The general form is

super. Member

2.1 super used to access hidden member variables a super class

/ * Can better illustrate the use of super with an example, shown below * /

/ / Using super to come over hidingf name

Class

(

int i;

)

class B extends A

(

int i, j, / / this hides the i in Class

B (int x, int y)

(

i = x;

Y = super.i;

j = Super.i;

)

Void Display ()

(

System.out.println ("value of i in a class" + + Super.i "value of j" + j);

)

)

UseSuper class

(

public static void main (String args [])

(

B obj = new B (10,20);

System.out.println ("value of i in B is" + obj.i);

System.out.println ("value of i in a class is" + obj.j);

obj.show ();

)

)

Let ensure polymorhism memories again

We had the discussion session on the polymorphism (DetailedLookAtMethodsAndClasses-2). We had discussed in length, about one form of polymorphism: overloading method.

In this session we discuss the redefining the method in detail.

2.2 Method riding lessons to a class hierarchy where a method in a subclass and super class has the same name and type signature (parameters), then the method of the subclass is said to over ride the method in super class.

  • Remember

ü When an overloaded method is called from within a call subclass.The always refer to the version of the method defined by the version subclass.The defined by the class super will always be hidden.

allows to understand with an example shown below.

/ *

Method overriding

*

/ / Redefine Method demonstration

Class A

(

int i, j;

A (int x, int y)

(

i = x;

= jy;

)

void display ()

(

System.out.println ("Display Method Class A is called with the values of i and j "+ i +" "+ j);

)

)

class B extends A

(

int K, L;

B (int x, int y)

(

super (10 x, y +10);

k = x;

L y =;

/ * Possible to assign values to i and j in the class constructor B

i = x + 10;

j = y + 10;

*

)

void display ()

(

System.out.println ("Display Method of the class B is called with the values of K and L "+ k + L +);

)

)

MethodOverRideDemo class

(

public static void main (String args [])

(

B obj = new B (20.23);

obj.display ();// call the display () Class B

)

)

  • Remember

ü More methods allow mounted Java to support dynamic polymorphism execution.

ü method over riding only occurs when the name and signature of type Both methods are identical, if they are not then the methods are simply overloaded.

ü The polymorphism is essential for programming Object-oriented for some reason, it is possible to specify the methods of a general class that will be common to all, subclasss "(derivatives), while to define the subclasses specific application of some or all of these methods.

2.2.1 Application the method of loading More examines the benefits of the method in horse riding lessons with the help of examples below

/ *

This program creates a class called super figure that the dimensions of different stores, two

objects.It size also defines a method named area () that calculates the size of a

object, the program stems from two sub-classes figure.The is the first and the second rectangle

is Triangle.Each these subclasses overrides area () to return the area of a

rectangle and a triangle, respectively.

*

Figure class

(

Double Dim1;

Double Dim2;

Figure (double x, double y)

(

Dim1 = x;

Dim2 = y;

)

Dual Zone ()

(

System.out.println ("area Figure of undefined ");

return 0;

)

)

Class Rectangle extends Figure

(

Rectangle (double x, double y)

(

super (x, y);

)

Dual Zone ()

(

return Dim1 Dim2 *;

)

)

class Triangle extends Figure

(

Triangle (double x, double y)

(

super (x, y);

)

a double space ()

(

return (float) 1 / 2 * * Dim1 Dim2;

)

)

FindArea class

(

public static void main (String args [])

(

Figure fig = new Figure (10,10);

Rectangle rec = new Rectangle (9,5);

Triangle tri = new Triangle (10.8);

System.out.println ("area of the figure is" + fig.area ());

System.out.println ("area of the rectangle is" + rec.area ());

System.out.println ("area of the triangle is" + tri.area ());

)

)

Introducing the last three keyword

The keyword final three uses.

ü First, it can be used to create the equivalent of a named constant.

ü The other two uses of final demand to inheritance.

Both are considered here

3.1 End use with variable

  • Declaring a variable as final, preventing the contents of the variable to be modified.

Syntax:

Final value type variable = name;

For example

final int file_open = 1;

FILE_CLOSE final int = 2;

Final FILE_SAVEAS int = 3;

final int FILE_ SaveAs = 4;

FILE_ final int QUIT = 5;

  • The variable declared as final can be used directly in the program, file_open, FILE_NEW, etc. as if FILE_SAVEAS they were constant, for fear that a value has been changed).
  • Remember

ü You must initialize a variable declared as final, while the statement (final is like const in C, C + +).

ü There is a coding convention to choose all uppercase to indentify variables final.

3.2 Using final with inheritance

i) The end use to prevent more constituency:

Although the method is more characteristic of conduct the most powerful Java, there will be times when you want to prevent him from achieving this goal occurring.To simply specify a modifier at the beginning of final his statement, the code fragment

/ / Code fragment showing the implementation wrong over riding

Class

(

final void meth ()

(

System.out.println ("This is a definitive method");

)

)

class B extends A

(

void meth () / / Error can not run because meth () is already declared as final class A

(

System.out.println ("This custom method to be printed");

)

)

/ *

This program shows almost exclusively on loading docks of the methods are not

affected by methods declared final.

*

Class A

(

final void meth ()

(

System.out.println ("It the final method ");

)

)

class B extends A

(

void meth () / / No OK, error because of this meth () is declared final in Class A

(

System.out.println ("illegal and this habit work ");

)

void meth (int x) (/ / This is ok because the charged form of methamphetamine (int x)

System.out.println ("u are in B and x =" + x) / / not declared final in Class A

)

)

UseFinalMethod class

(

public static void main (String args [])

(

B obj1 = new B ();

obj1.meth (2);

)

)

Explanation

  • Remember

ü Only methods with the same name and signature settings, said that the final can not be more rided but they can be more responsible. as shown in the example above.

ü If the final method tried to be more fitted, compilation error occurs.

ii) Using Final to prevent inheritance

Although the legacy the most powerful Java, there will be times when you want a class, to be prevented, to be inherited. To do this simply specify a modifier before the final class declaration.

Thus, to avoid a class from being inherited yet, follow the general syntax below

Final class class name

(

/ / Statements;

)

consider the code fragment,

Final Class

(

/ / Statements;

)

class B extends A / / Error! class can not under

(

/ / Statements;

)

2. Abstract classes

Sometimes we want to create a super class that defines only a generalized form, which will be common all its sub-classes "(derivatives), leaving each class to fill in the details.

You can have some methods to be mounted over an under-class, so the class has in a sense. In such a case, there should be a way to ensure that a sub-class does, Indeed, more than install all necessary methods. The solution to this problem is javas the abstract method.

Declaring an abstract method using the following general form:

Abstract method return-type-name (ParameterList);

  • Remember

ü abstract method, does not define a method body defined.

Any class that contains one or more abstract methods must also be declared abstract. To declare

Abstract class simply use the abstract word key before the keyword class in early

the class declaration, as shown below

abstract class classname

(

summary Method1 (ParameterList);

Abstract method2 (ParameterList);

/ /

/ /

methodN abstract (ParameterList);

)

Restrictions with abstract classes

  • It is illegal to declare a class as both final and abstract, because an abstract class is incomplete in itself and is up on a sub-class for implementation.
  • An abstract class can not be directly instantiated with the new operator, because these objects would be useless as an abstract class is not fully defined.
  • An abstract class can not declare abstract constructors.
  • An abstract class can not declare static abstract methods.
  • Any subclass of an abstract class must either implement all the abstract methods of the super class or that it be declared abstract itself.

Lets illustrate this with the help of an example.

/ *

A simple demonstration of the abstract class

*

An abstract class

(

abstract void CallMe ();

/ / Specific methods are still allowed in the abstract class

CallMeToo void ()

(

System.out.println ("It is a well defined method of abstract class ");

)

)

class B extends A

(

/ / For calling me is an abstract class IC method A, it is no longer mounted below

void CallMe ()

(

System.out.println ("Implementation of B CallMe is a summary" +

"Class A Method");

)

)

AbstractClassDemo class

(

public static void main (String args [])

(

Obj1 B = new B ();

Obj1.CallMe ();

Obj1.CallMeToo ();

)

)

  • Remember

ü Although abstract classes can not be used to instantiate objects, they can be used to create object references.

ü Practical arrangements that define the body, are still allowed in the abstract class.

Although the abstract classes can not be used to instantiate objects, they can be used to create object references.

As we aware Java runtime polymorphism is implemented through the use of references.Thus superclass must be possible to create a reference to an abstract class so it can be used to point to a subclass object. This is illustrated by the example below

/ *

using abstract methods and classes and creating a reference to an abstract class to it

can be used to point to a sub-object. This fact is illustrated by the example below

*

class Abstract Figure

(

Double Dim1, Dim2;

Figure (double x, double y)

(

Dim1 = x;

Dim2 = y;

)

Abstract double area ();

)

class Rectangle extends Figure

(

Rectangle (double x, double y)

(

super (x, y);

)

Dual Zone ()

(

return * Dim1 Dim2;

)

)

class Triangle extends Figure

(

Triangle (double x, double y)

(

super (x, y);

)

a double space ()

(

return ((float) 1 / 2) * (* Dim1 Dim2);

)

)

AbstractClassImplementation class

(

public static void main (String args [])

(

/ / Figure F = new Figure (10,10) / / illegal, because abstract classes can not be

/ / Instantiation

Rectangle r = new rectangle (9,5);

Triangle t = new Triangle (10.8);

Figure figref / / variable instance the creation of the figure with NULL value stored.

figref = r;

System.out.println ("area of the rectangle is" + figref.area ());

figref = t;

System.out.println ("area of the triangle is" + figref.area ());

)

)

About the Author

I am a trainer and developer in java and oracle technoliogies.

you can reach me on raju.allu@yahoo.co.in

Recreation of NatNeagle’s Java Blue look

eBay Logo  

NWT authentic Vera Bradley Small Duffel in Java Blue made in USA 10138-010 rare!


NWT authentic Vera Bradley Small Duffel in Java Blue made in USA 10138-010 rare!


$69.99


NWT Vera Bradley Large Duffel & Large Cosmetic Java Blue rare Made in the USA!


NWT Vera Bradley Large Duffel & Large Cosmetic Java Blue rare Made in the USA!


$99.99


NWT authentic Vera Bradley Large Duffel in Java Blue made in USA


NWT authentic Vera Bradley Large Duffel in Java Blue made in USA


$89.99


Vera Bradley Java Blue 17


Vera Bradley Java Blue 17″ Rolling Travel Tote Luggage Carry On Suitcase Retired


$99.99


VERA BRADLEY JAVA BLUE LUGGAGE 21


VERA BRADLEY JAVA BLUE LUGGAGE 21″ TWO-COMPARTMENT WHEELABOARD


$149.00


VERA BRADLEY JAVA BLUE 17


VERA BRADLEY JAVA BLUE 17″ ROLLING TRAVEL TOTE


$99.00


VERA BRADLEY JAVA BLUE 48


VERA BRADLEY JAVA BLUE 48″ GARMENT BAG


$99.00


VERA BRADLEY JAVA BLUE LARGE VERA BAG NWT


VERA BRADLEY JAVA BLUE LARGE VERA BAG NWT


$89.99


Fiesta 12-Ounce Java Mug


Fiesta 12-Ounce Java Mug




Noritake Java Graphite Swirl Covered Butter


Noritake Java Graphite Swirl Covered Butter


$39.90


Brighten up your kitchen with the Java Graphite Swirl tableware collection from Noritake. The contemporary, casual dinnerware is beautiful white porcelain with cool blue, yellow and heather gray banding. Since 1904, Noritake has prided itself on distinctive designs, innovative new technologies and unsurpassed quality in the manufacture of fine dinnerware. The Java Graphite Swirl collection is no e…

Noritake Java Blue Swirl 4-Piece Place Setting


Noritake Java Blue Swirl 4-Piece Place Setting


$39.95


Brighten up your kitchen with the Java Blue Swirl tableware collection from Noritake. The contemporary, casual dinnerware is cool white porcelain with colorful blue, yellow and green banding. Since 1904, Noritake has prided itself on distinctive designs, innovative new technologies and unsurpassed quality in the manufacture of fine dinnerware. The Java Blue Swirl collection is no exception to Nori…


Tags: , , , , , , , , ,

Leave a Reply