Sei sulla pagina 1di 10

EX.

NO: DATE: STACK CLASSES


AIM:

30608205014

To develop a java package with simple stack classes using JavaDoc classes for documentation. ALGORITHM: Step 1: Start the program Step 2: Stack is like a bucket in which you can put elements one-by-one in sequence and retrieve elements from the bucket according to the sequence of the last entered element. Step 3: Stack is a collection of data and follows the LIFO rule that mean you can insert the elements one-by-one in sequence and the last inserted element can be retrieved at once from the bucket. Step 4: Element are inserted and retrieved to/from the stack through the push() and pop() method. Step 5: Stack<integer>() Constructor of the stack class creates a empty stack which holds the integer type value which is mention with the creation stack. The stack class extends the vector class and both classes are implemented from the java.util.*;package. Step 6: Stack.push(object obj): Above method is used to insert to push the data or element in the stack. It takes an object like: data or elements and push its onto the top of the stack. Step 7: Stack.pop(): This is the method to removes the objects like: data or elements at the top positions of the stack. Step 8: End the program

RESULT: Thus the program for developing java package with simple stack classes using JavaDoc classes is written and expected output is achieved.

EX.NO: DATE: DYNAMIC POLYMORPHISM AIM:

30608205014

To design a simple test application to demonstrate dynamic polymorphism. ALGORITHM: Step 1: Start the program Step 2: Dynamic polymorphism is a class overrides a superclass method or implements an interface. Step 3: Any class may override the Object.toString() method and provide its own implementation, and this is known as compile time. Step 4: Simple java program that instantiates a series of objects and calls their toString() method, the compiles does not consider the object references differently. Step 5: Any differences in the objects toString() implementations are only seen at runtime, so they are considered dynamic. Step 6: End the program

RESULT: Thus the program to demonstrate dynamic polymorphism using java was written and output is achieved.

EX.NO: DATE: STACK ADT AIM:


To design a java interface for stack ADT.

30608205014

ALGORITHM: Step 1: Start the program Step 2: create :: Stack acreate an empty stack Step 3: push :: a->Stack a->Stack apush an element on the stack Step 4: pop :: Stack a->(a.,Stack a)pop an element off the stack Step 5: empty :: Stack a->Booltells whether stack is empty Step 6: pop(push x s)=(x,s) Step 7: pop(create)error Step 8: The interface to the stack ADT is defined as follows(file=MyStack.java); Step 9: A simple stack testing class(file=StackTest.java) Step 10:End the program

RESULT: Thus the program for stack ADT using java interface was written and expected output is achieved.

EX.NO: DATE: SCIENTIFIC CALCULATOR

30608205014

AIM: To write a program to implement scientific calculator using even-driven programming. ALGORITHM: Step 1: Start the program Step 2: Import the required packages Step 3: Create class that extends frame Step 4: Create text field and buttons Step 5: Add buttons to panel Step 6: Add mouse listener and perform necessary operation Step 7: Exit the application

RESULT: Thus the program to develop scientific calculator using even-driven programming was written and executed successfully.

EX.NO: DATE:

30608205014 VEHICLE CLASS HIERARCHY-POLYMORPHISM

AIM: To write a program for polymorphism using vehicle class and execute it in java. ALGORITHM: Step 1: Start the program Step 2: Define class vehicle and declare main function inside it. Step 3: Use vehicle class passing values to the function. Step 4: Define the class automobile and use it to declare integer variables Step 5: Declare and define functions to get rollnumber, number of wheels, capacity and Cost to get the integers. Step 6: Define class imported and national as the subclasses for automobile class. Step 7: Exit the application.

RESULT: Thus the program for polymorphism using vehicle classes was written and executed successfully in java.

Potrebbero piacerti anche