Cse Lab Manuals Java

  • Uploaded by: shyam rana
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Cse Lab Manuals Java as PDF for free.

More details

  • Words: 961
  • Pages: 11
Haryana Engineering College JAGADHRI

Experiment Instructions

Issue : 01 Page 1 of 1

INDEX(Advanced Technology+CODE) Sr. Numbe r

Name of Experiment

Document No.

1

Learn basics of java language and its HEC/CE/CSE development tools/libraries.

2

Write a program in java using command line HEC/CE/CSE arguments.

3

Create an editor screen containing menus, HEC/CE/CSE dialogue boxes using java .

4

Write a program in java showing exception HEC/CE/CSE handling. Create an applet with a text field and three HEC/CE/CSE buttons when you press each button make some different text appear in the text field.

5

Add a check box to the applet created,capture the event and insert different text into the text field

6

Write a program to find the volume of a box

7

Write a multithreaded program to print HEC/CE/CSE “Hello Thread” ten times.

Originated /Reviewed By: Ashna Sharma Priya Aggarwal Shefali Garg

Approved by:

Revision No

HEC/CE/CSE

Revision Date:

Effective Date

Haryana Engineering College JAGADHRI

Experiment Instructions AIM :

Issue : 01 Page 2 of 1

Learn basics of java language and its development tools/libraries

SCOPE PROCEDURE: JAVA is first and foremost an object oriented programming language.Many programmers were surprised when they discovered how easy it is to follow sound object oriented design practices with java.The following sections give you a better understanding of what java offers .

Characteristics of java Characteristics of java are very easy to understand. Java has advanced object oriented capabilities are they are very powerful. Some of the characteristics are: Architecture-neutral Distributed Interpreted and compiled Multithreaded Network-ready and compatible Object-oriented Portable Robust Secure Viewing

Originated /Reviewed By: Ashna Sharma Priya Aggarwal Shefali Garg

Approved by:

Revision No

Revision Date:

Effective Date

Haryana Engineering College JAGADHRI

Experiment Instructions

Issue : 01 Page 3 of 1

AIM:Program to calculate the volume of the box.

class box { double width; double height; double depth; box(box ob) { width=ob.width; height=ob.height; depth=ob.depth; } box(double w,double h,double d) { width=w; height=h; depth=d; } box() { width=-1; height=-1; depth=-1; } Originated /Reviewed By: Ashna Sharma Priya Aggarwal Shefali Garg

Approved by:

Revision No

Revision Date:

Effective Date

Haryana Engineering College JAGADHRI

Experiment Instructions

Issue : 01 Page 4 of 1

box(double len) { width=height=depth=len; } double volume() { return width*height*depth; } } class boxweight extends box { double weight; boxweight(double w,double h,double d,doublew m) { width=w; height=h; depth=d; weight=m; } } class demoboxweight{ public static void main(String args[]) { boxweight mybox1=new boxweight(10,20,15,34.3); boxweight mybox2=new boxweight(2,3,4,0.076); double vol1; Originated /Reviewed By: Ashna Sharma Priya Aggarwal Shefali Garg

Approved by:

Revision No

Revision Date:

Effective Date

Haryana Engineering College JAGADHRI

Experiment Instructions

Issue : 01 Page 5 of 1

vol1=mybox1.volume(); System.out.println("volume of mybox1 is"+vol1); System.out.println("volume of mybox1 is"+mybox.weight); System.out.println(); vol1=mybox2.volume(); System.out.println("volume of mybox2 is"+vol1); System.out.println("volume of mybox2 is"+mybox2.weight); } }

Originated /Reviewed By: Ashna Sharma Priya Aggarwal Shefali Garg

Approved by:

Revision No

Revision Date:

Effective Date

Haryana Engineering College JAGADHRI

Experiment Instructions

Issue : 01 Page 6 of 1

AIM: Program to create an applet with a textfield and three buttons.When you press each button, make some text appear in the textfield . Add a check box to applet created ,capture the event and insert different text in textfield. CODING: import java.awt.*; import java.awt.event.*; import java.applet.*; public class MyApplet extends Applet implements ActionListener,ItemListener { TextField t; Button b1,b2; checkbox c; public void init() { t=new TextField(20); b1=new Button("one"); b2=new Button("two"); c=new Checkbox("Check"); add(t); add(b1); add(b2); add(c); b1.addActionListener(this); b2.addActionListener(this); Originated /Reviewed By: Ashna Sharma Priya Aggarwal Shefali Garg

Approved by:

Revision No

Revision Date:

Effective Date

Haryana Engineering College JAGADHRI

Experiment Instructions

Issue : 01 Page 7 of 1

c.addItemListener(this); } public void actionPerformed(ActionEvent ae) { if(ae.getActionCommand()=="one") t.setText("pressed button one"); else if(ae.getActionCommand()=="two") t.setText("pressed button two"); } public void itemStateChanged(ItemEvent ie) { if(c.getState()==true) t.setText("u pressed chechbox"); } }

Originated /Reviewed By: Ashna Sharma Priya Aggarwal Shefali Garg

Approved by:

Revision No

Revision Date:

Effective Date

Haryana Engineering College JAGADHRI

Experiment Instructions

Issue : 01 Page 8 of 1

AIM: Write a program in Java using COMMAND LINE ARGUMENTS SCOPE CODING: class text { public static void main(String args[ ]) { int count,I=0; String str; count=args.length; System.out.println(“No. of arguments= “+count); while(I
INPUT java test One Two Three

OUTPUT No. of arguments=3 1 argument is One 2 argument is Two 3 argument is Three

Originated /Reviewed By: Ashna Sharma Priya Aggarwal Shefali Garg

Approved by:

Revision No

Revision Date:

Effective Date

Haryana Engineering College JAGADHRI

Experiment Instructions

Issue : 01 Page 9 of 1

AIM: Write a program in Java using COMMAND LINE ARGUMENTS SCOPE CODING: public class Example2 { public static void main(String args[ ]) { int i=1,j=0,k; try { k=i/j; } catch (ArithmeticException ae) { System.out.println(“Division by zero,illegal operator); } System.out.println(“Hello World”); } }

INPUT OUTPUT Division by Zero,illegal operation Hello World

Originated /Reviewed By: Ashna Sharma Priya Aggarwal Shefali Garg

Approved by:

Revision No

Revision Date:

Effective Date

Haryana Engineering College JAGADHRI

Experiment Instructions

Issue : 01 Page 10 of 1

AIM: Write a multithreaded program in Java to print “Hello Thread2” ten times. SCOPE CODING: class ExampleThread1 extends Thread { public void run() { for (int i=0;i<10;i++) { System.out.println(“Hello Thread1”); } } class ExampleThread2 extends Thread { public void run() { for(int i=0;i<10;i++) { System.out.println(“Hello Thread2”); } } } public class Example1 { public Static void main(String args[ ]) { ExampleThread1 t1=new ExampleThread1(); ExampleThread2 t2=new ExampleThread2(); T1.start(); T2.start(); } } Originated /Reviewed Approved by: Revision No By: Ashna Sharma Priya Aggarwal Shefali Garg

Revision Date:

Effective Date

Haryana Engineering College JAGADHRI

Experiment Instructions

Issue : 01 Page 11 of 1

INPUT OUTPUT HelloThread1 HelloThread2 HelloThread2 HelloThread2 HelloThread2 HelloThread1 HelloThread1 HelloThread1 HelloThread1 HelloThread2 HelloThread2 HelloThread2 HelloThread1

Originated /Reviewed By: Ashna Sharma Priya Aggarwal Shefali Garg

Approved by:

Revision No

Revision Date:

Effective Date

Related Documents

Cse Lab Manuals Java
June 2020 8
Cse
June 2020 9
Cse
July 2020 15
Cse
November 2019 27
Cse
July 2020 6

More Documents from ""