Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaMail sir i,have a assignment for these question plz help me sir

Have Programming Question? Ask it here!
 
 
 


parthiban
sir i,have a assignment for these question plz help me sir
2 Answer(s)      4 years ago
Posted in : JavaMail




1.Design a Java interface for ADT Stack. Develop two different classes that implement this interface, one using array and the other using linked-list. Provide necessary exception handling in both the implementations


2.Design a Vehicle class hierarchy in Java. Write a test program to demonstrate polymorphism

Advertisement
View Answers

August 7, 2010 at 11:55 AM


Hi Friend,

Try the following codes:

1)ADT Stack:

import java.lang.*;
import java.io.*;
import java.util.*;

interface MyInterface {
int n = 20;

public void pop();

public void push();

public void peek();

public void display();
}

class StackImplementation implements MyInterface {
int arr[] = new int[n];
int top = -1;

public void push() {
try {
DataInputStream dis = new DataInputStream(System.in);
System.out.println("Enter Element");
int ele = Integer.parseInt(dis.readLine());
arr[++top] = ele;
} catch (Exception e) {
System.out.println("e");
}
}

public void pop() {
int popper = arr[top];
top--;
System.out.println("popped element " + popper);
}

public void peek() {
int popper = arr[top];
System.out.println("popped element " + popper);
}

public void display() {
if (top < 0) {
System.out.println("Stack is empty");
return;
} else {
String str = " ";
for (int i = 0; i <= top; i++)
str = str + " " + arr[i];
System.out.println("Elements are " + str);
}
}
}

class StackADT {
public static void main(String arg[]) throws IOException {
DataInputStream dis = new DataInputStream(System.in);
StackImplementation stk = new StackImplementation();
int menu = 0;
do {
System.out.println("1.push \n2.pop \n3.peek \n4.display \n5.Exit");
System.out.println();
System.out.print("Enter your choice: ");
menu = Integer.parseInt(dis.readLine());
switch (menu) {
case 1:
stk.push();
break;
case 2:
stk.pop();
break;
case 3:
stk.peek();
break;
case 4:
stk.display();
break;
case 5:
System.exit(0);
}
} while (menu <= 5);
System.out.println();
}
}


August 7, 2010 at 11:56 AM


continue..

2)Polymorphism:

class Vehicle {
void test(){}
}
class Bus extends Vehicle{
void test()
{
System.out.println("I am a bus");
}
}
class Car extends Vehicle{
void test()
{
System.out.println("I am a car");
}
}
class Bike extends Vehicle{
void test()
{
System.out.println("I am a bike");
}
}
public class Polymorphism{
public static void main(String[]args){
Vehicle[] v = new Vehicle[3];
v[0]= new Bus();
v[1]=new Car();
v[2]=new Bike();
for(int i=0;i<v.length;i++){
v[i].test();
}

}
}

Thanks


Related Tutorials/Questions & Answers:
sir i,have a assignment for these question plz help me sir - JavaMail
sir i,have a assignment for these question plz help me sir  ...; } else { String str = " "; for (int i = 0; i <= top; i++) str = str + " " + arr[i]; System.out.println("Elements are " + str
sir i,have a another assignment for these question plz help me sir - JavaMail
sir i,have a another assignment for these question plz help me sir  1. Design classes for Currency, Rupee, and Dollar. Write a program... to both. plz help me sir
Advertisements
i have problem in that program to my assignment sir - JavaMail
i have problem in that program to my assignment sir   Develop a programmer's editor in Java that supports syntax-highlighting, compilation support, debugging support, etc
sir i want small project with of health care system with struts and hibernate plz help me
sir i want small project with of health care system with struts and hibernate plz help me  sir i want small project on health care system with struts and hibernate plz help me
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
i have problem in that program sir - JavaMail
i have problem in that program sir  1.Develop multi-threaded echo server and a corresponding GUI client in Java
pls help me sir its urgent
pls help me sir its urgent  thanks for reply, but i am getting this error pls help me its urgent type Exception report message description The server encountered an internal error () that prevented it from
Hello Sir I Have problem with My Java Project - Java Beginners
Hello Sir I Have problem with My Java Project  Hello Sir I want Ur Mail Id To send U details and Project Source Code, plz Give Me Ur Mail Id
Plz reply me sir Its urgent - JSP-Servlet
Plz reply me sir Its urgent  Respected Sir/madam, I am R.Ragavendran..Actuaaly,I request you to remember the code which you have provided for me using radio buttons.. You have used the following syntax for checking whether
i have a problem to do this question...pls help me..
i have a problem to do this question...pls help me..  Write a program... reversedNumber = 0; for (int i = 0; i <= num; i...; reversedNumber = reversedNumber * 10 + r; i = 0
plz help me for this question
plz help me for this question  Apply simplex procedure to solve the L.P.P. maximize z = 3x1 + 4x2 subject to 5x1 + 4x2 ? 200; 3x1 + 5x2 ? 150; 5x1 + 4x2 ? 100; 8x1 + 4x2 ?? 80, x1 ? 0, x2 ? 0
sir plz send the project on quiz system code
sir plz send the project on quiz system code  sir plz send the client server based project in core java database in my sql
Please guide me sir - EJB
Please guide me sir  Hi I am Pradeep singh ,done SCJP 5.0 and SCWCD 5.0 .Now i want to learn further .So please tell me whether should i learn EJB... next? Because both can do same work.Please advice me .At present i am jobless
swing program plz urgent sir - Java Beginners
swing program plz urgent sir   hi sir,i waan a jtable swings program table having column names "itemid","price".Initially table having single empty row.whenever we click the "enter" button automatically new row will be insert
sir plz help in design a jsp page whichis as follow username [_____] select [__>]password [_____] after selection then onlypassword text box is visible
sir plz help in design a jsp page   sir plz help in design a jsp page which is as follow username [ _ ] select [ > ] password [ _ ] after selection then only password text box is visible
interview question plz help me and thers
interview question plz help me and thers  A college is good.... 6.If it has a "B.Tech" course, atleast 30 compnies should have come for placement. (But see next condition) 7.If "Infosys" or "Wipro" have come for placement
Plz help me with this Question - Java Beginners
Plz help me with this Question  this is java code ------------------------- Consider the following code: int [ ] a = [1, 2, 3]; Object o ="123"; String t = "12"; String w = t + "3"; Boolean b = o.equals (a); Boolean b2
inheritance....please help me friends...!!!... this is important project that i have to do it..
inheritance....please help me friends...!!!... this is important project that i have to do it..   Point ................. #x : int #y : int + Point() + Point(xCoordinate:int, YCoordinate:int) + getX() : int + getY() : int
sir plz do respond to my problem immediately - Java Beginners
sir plz do respond to my problem immediately  Hello sir... for the progree bar is a separate program. sir i need to put it in my web browser.sir iam... the progress bar in my browser. I have tried and iam unbale to get it sir.plz
I really need help with this assignment question Please help me out Please
I really need help with this assignment question Please help me out Please  * Description* You are hired to develop a laptop inventory information system for Sheridan College in order to keep track of the information about
hii sir
tell me plz
Help me quickly plz??
Help me quickly plz??  Can you help me to write code quickly this code is a java code take input as double and should use command line arguments and enhanced for statement then find the combine of the numbers plz help quickly
hello sir, please give me answer - Java Beginners
hello sir, please give me answer  Write a program in Java that calculates the sum of digits of an input number, prints... ways in java? so , sir please tell me full solution of this program   Here is your complete
Plz Help Me
Plz Help Me  Write a program for traffic light tool to manage time giving between Main-Street and sub-Street. firstly, give green light for 40... traffic light on the frame. We have used java swing. It may help you. import
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
plz help me - Java Beginners
plz help me  Deepak I can write a sessioon code plz help me admin_home.jsp page is display but data is not disply plz help me what is wrong
plz help me - Java Beginners
plz help me  Hi, I want to search all field from database using name, and display in text box, then data is update and delete. i want to search name using alphabets a-z, plz reply fast. plz help me this is very urgent
hi sir - Java Beginners
hi sir  Hi,sir,i am try in netbeans for to develop the swings,plz... netbeans, and how to connect with database by using the netbeans ,plz provide the details sir, Thanks for ur coporation sir  Hi Friend
plz Help me - Java Beginners
plz Help me  Hi, I want learn struts,I dont have any idea about this plz help how can i make a framework.If u have any information then plz send my personal id plz tell me that whose software installed.and give me brief
more doubts sir. - Java Beginners
own browser.Hope you will help me out.And also sir i need the progressbar...more doubts sir.  Hello sir, Sir i have executed your code... exoplorer such as search bar and some more buttons.Sir help me out
Plz give me code for this question
Plz give me code for this question  Program to find depth of the file in a directory and list all files those are having more number of parent directories
plz help me - Java Beginners
plz help me  Thanks deepak continue response..i face some problem i... is true...but i very confuse that how it is not displayed admin page plz any one give me reponse my persinal given id  Hi ragni, i am sending
plz help me!!!!!!!! - JSP-Servlet
plz help me!!!!!!!!  i`ve set the environment varaibles for tomcat as well as jdk.. but i`m not understanding where i`ve to save my servlet..i.e.... there are compilation errors.. plz do help me.   make sure that you did
plz help me - Java Beginners
plz help me  deepak hw can i create a data grid in jsp and also how can i connect to the data base plz help me  to create data grid in jsp use html tables with borders. to connect to data base use scriptlets. ex
sir - Java Beginners
sir   hi sir,Happy ugadi,how to place the database records into jtable ,i am using the oracle database plz provide the program how to retrieve the database records and placed into a jtable,i want one more column is added to my
sir - Java Beginners
sir   hi sir,in this program there is a jtable,i am insert... sir,i am mentioning the error as <<>>>......main bug here>........ in this program,plz see and provide solution sir,database Tables
sir, how to convert excel file to csv file using java? please send me sample code.
sir, how to convert excel file to csv file using java? please send me sample code.  please send me sample code for converting excel file into csv file uisng java
plz help meto solve this question
plz help meto solve this question  for a file that exist what will be the length() method in the file class return
sir - Java Beginners
sir   when i press enter in my jtable,i want to add a row to my jtable and the database records are placed in that added row, plz provide the program in swings,how to add and place the results in added row
Intranet Website creation - plz help me
Intranet Website creation - plz help me   hi.. I have assign with the intranet website creation work..right from scratch to end..And honestly I know nothing about it.My domain is totally different .. can anybody pls help me
Help me plz in Probablity distribution of Java
Help me plz in Probablity distribution of Java  Hello, I have an issue I have connected my JDBC driver with my database.. Now I want to randomly...% is insert or update queries. Which distribution to use and how to achieve it.. Plz
 

 

 

DMCA.com