Vinayaka Missions University
|
|
- Antony Haynes
- 6 years ago
- Views:
Transcription
1 Vinayaka Missions University VMKV Engineering College Salem Department of Computer Science & Software Engineering [CSSE] LAB MANUAL JAVA PROGRAMMING (V Semester) Prepared by A.RAMESH KUMAR
2 List of Lab Exercises Sl. No. Exercise 1 Largest Number Finding of N Values Page No. 2 Sorting of Name (String) 3 String Manipulation 4 Overloading & Constructor Implementation 5 Bank Operation using Class & Object 6 User Defined Package Creation 7 Multiple Inheritance using Interface 8 Simple AWT to Design Simple Calculator 9 Biodata Generation using Frame 10 Drawing 2D Shapes using Menubar Java Programming Lab Manual CSSE /VMKVEC. 2
3 JAVA PROGRAMMING Java Programming Lab Manual CSSE /VMKVEC. 1
4 Ex. No: 1 Date : Largest Number Finding of N Values AIM ALGORITHM: PROGRAM: import java.io.*; public class biggest public static void main(string srgs[])throws Exception int i[]=new int[100]; DataInputStream d=new DataInputStream(System.in); System.out.print("Enter howmany values : "); int n=integer.parseint(d.readline()); for(int j=0;j<n;j++) System.out.print("Enter the value "+(j+1)+" :"); i[j]=integer.parseint(d.readline()); int big=0; for(int j=0;j<n;j++) if(i[j]>big) big=i[j]; System.out.println("The biggest number is : "+big); Java Programming Lab Manual CSSE /VMKVEC. 2
5 OUTPUT: D:\Programs\java\VMKV\LAB>JAVAC biggest.java D:\Programs\java\VMKV\LAB>JAVA biggest Enter how many values : 5 Enter the value 1 :7 Enter the value 2 :2 Enter the value 3 :5 Enter the value 4 :8 Enter the value 5 :1 The biggest number is : 8 Java Programming Lab Manual CSSE /VMKVEC. 3
6 Ex. No: 2 Date : Sorting of Name (String) AIM ALGORITHM: PROGRAM: import java.io.*; public class sorting public static void main(string args[])throws Exception DataInputStream d=new DataInputStream(System.in); String s[]=new String[100]; System.out.print("Enter how many names : "); int n=integer.parseint(d.readline()); for(int j=0;j<n;j++) System.out.print("Enter Name "+(j+1) + ":" ); s[j]=d.readline(); String name; for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) if(s[j].compareto(s[k])>0) name=s[j]; s[j]=s[k]; s[k]=name; System.out.println("SORTED NAME LIST:"); for(int j=0;j<n;j++) System.out.println(s[j]); Java Programming Lab Manual CSSE /VMKVEC. 4
7 OUTPUT: D:\Programs\java\VMKV\LAB>JAVAC sorting.java D:\Programs\java\VMKV\LAB>JAVA sorting Enter how many names : 5 Enter Name 1:Zenith Enter Name 2:Wipro Enter Name 3:HP Enter Name 4:Alpha Enter Name 5:Infosys SORTED NAME LIST: Aalpha HP Infosys Wipro Zenith Java Programming Lab Manual CSSE /VMKVEC. 5
8 Ex. No: 3 Date : String Manipulation AIM ALGORITHM: PROGRAM: import java.io.*; public class string public static void main(string args[])throws Exception DataInputStream d=new DataInputStream(System.in); System.out.print("Enter String 1 :"); String s1=d.readline(); System.out.print("Enter String 2 :"); String s2=d.readline(); System.out.println("FEW STRING MANIPULATION"); System.out.println("String Concatenation : "+s1.concat(s2)); System.out.println("Length of String 2 : "+s2.length()); System.out.println("Compare two Strings : "+s1.equalsignorecase("cse")); System.out.println("Spliting the String into substring : "+s2.substring(6)); System.out.println("Convert to Lowercase : "+s1.tolowercase()); System.out.println("Convert to Uppercase : "+s2.touppercase()); OUTPUT: D:\Programs\java\VMKV\LAB>JAVAC string.java D:\Programs\java\VMKV\LAB>JAVA string Enter String 1 :CSSE Enter String 2 :Department FEW STRING MANIPULATION String Concatenation : CSSEDepartment Length of String 2 : 10 Compare two Strings : false Spliting the String into substring : ment Convert to Lowercase : csse Convert to Uppercase : DEPARTMENT Java Programming Lab Manual CSSE /VMKVEC. 6
9 Ex. No: 4 Date : Overloading & Constructor Implementation AIM ALGORITHM: PROGRAM: import java.io.*; class over int a,b; over(string s) a=50; b=30; System.out.println("Welcome : "+s); over() a=5; b=10; System.out.print("Enter your Name : "); void add() System.out.println("RESULT:\nA Value : "+a+"\nb Value : "+b+"\ntotal :"+(a+b)); void add(int x,int y,int z) System.out.println("RESULT:\nA Value : "+x+"\nb Value : "+y+"\nc Value : "+z+"\ntotal :"+(x+y+z)); public class over4 public static void main(string arg[])throws Exception DataInputStream d=new DataInputStream(System.in); over o=new over(); String st=d.readline(); over o1=new over(st); o.add(); o1.add(); Java Programming Lab Manual CSSE /VMKVEC. 7
10 System.out.println("Enter 3 Numbers"); int a=integer.parseint(d.readline()); int b=integer.parseint(d.readline()); int c=integer.parseint(d.readline()); o.add(a,b,c); OUTPUT: D:\Programs\java\VMKV\LAB>javac over4.java D:\Programs\java\VMKV\LAB>java over4 Enter your Name : CSSE Department Welcome : CSSE Department RESULT: A Value : 5 B Value : 10 Total :15 RESULT: A Value : 50 B Value : 30 Total :80 Enter 3 Numbers RESULT: A Value : 12 B Value : 30 C Value : 41 Total :83 Java Programming Lab Manual CSSE /VMKVEC. 8
11 Ex. No: 5 Date : Bank Operation using Class & Object AIM ALGORITHM: PROGRAM: import java.util.*; import java.io.*; public class bank String name, actype; int accno, bal, amt; bank(string name, int accno, String actype, int bal) this.name = name; this.accno = accno; this.actype = actype; this.bal = bal; int deposit(int amt) if (amt < 0) System.out.println("Invalid Amount"); return 1; bal = bal + amt; return 0; int withdraw(int amt) if (bal < amt) System.out.println("Not sufficient balance."); return 1; if (amt < 0) System.out.println("Invalid Amount"); return 1; bal = bal - amt; return 0; void display() Java Programming Lab Manual CSSE /VMKVEC. 9
12 System.out.println("Name:" + name); System.out.println("Account No:" + accno); System.out.println("Balance:" + bal); public static void main(string args[]) throws Exception DataInputStream d=new DataInputStream(System.in); System.out.print("Enter your Name : "); String nn = d.readline(); System.out.print("Enter Account Number : "); int num = Integer.parseInt(d.readLine()); System.out.print("Enter Account Type: "); String type = d.readline(); System.out.print("Enter Initial Balance: "); int bal = Integer.parseInt(d.readLine()); bank b1 = new bank(nn, num, type, bal); int menu; boolean quit = false; do System.out.println(" Menu"); System.out.println("1. Deposit Amount"); System.out.println("2. Withdraw Amount"); System.out.println("3. Display Information"); System.out.println("4. Exit"); System.out.print("Please enter your choice: "); menu = Integer.parseInt(d.readLine()); switch (menu) case 1: System.out.print("Enter amount to deposit:"); int am = Integer.parseInt(d.readLine()); b1.deposit(am); break; case 2: System.out.println("Your Balance=" + b1.bal); System.out.print("Enter amount to withdraw:"); am =Integer.parseInt(d.readLine()); b1.withdraw(am); break; case 3: b1.display(); break; case 4: quit = true; break; while (!quit); Java Programming Lab Manual CSSE /VMKVEC. 10
13 OUTPUT: D:\Programs\java\VMKV\LAB>javac bank.java D:\Programs\java\VMKV\LAB>java bank Enter your Name : RAJESH Enter Account Number : 3339 Enter Account Type: SAVINGS Enter Initial Balance: Menu 1. Deposit Amount 2. Withdraw Amount 3. Display Information 4. Exit Please enter your choice: 1 Enter amount to deposit:500 Menu 1. Deposit Amount 2. Withdraw Amount 3. Display Information 4. Exit Please enter your choice: 3 Name:RAJESH Account No:3339 Balance:10500 Menu 1. Deposit Amount 2. Withdraw Amount 3. Display Information 4. Exit Please enter your choice: 2 Your Balance=10500 Enter amount to withdraw:2500 Menu 1. Deposit Amount 2. Withdraw Amount 3. Display Information 4. Exit Please enter your choice: 3 Name:RAJESH Account No:3339 Balance:8000 Menu 1. Deposit Amount 2. Withdraw Amount 3. Display Information 4. Exit Please enter your choice: 4 Java Programming Lab Manual CSSE /VMKVEC. 11
14 Ex. No: 6 Date : User Defined Package Creation AIM ALGORITHM: PROGRAM: // Mypack Program package mypack; public class mypack public void disp() System.out.println("My First Package"); // import mypack.*; public class pack public static void main(string[] args) mypack d=new mypack(); d.disp(); OUTPUT: D:\Programs\java\VMKV>javac pack.java D:\Programs\java\VMKV>java pack My First Package Java Programming Lab Manual CSSE /VMKVEC. 12
15 Ex. No: 7 Date : Multiple Inheritance using Interface AIM ALGORITHM: PROGRAM: OUTPUT: Java Programming Lab Manual CSSE /VMKVEC. 13
16 Ex. No: 8 Date : Simple AWT to Design Simple Calculator AIM ALGORITHM: import java.applet.*; import java.awt.*; import java.awt.event.*; import java.awt.choice.*; //<applet code=calc width=500 height=555></applet> public class calc extends Applet implements TextListener,ActionListener int a,b,c; String s; TextField f1,f2,f3; Label l1,l2,l3; Button Add,Sub,Mul,Div; public void init() //setbackground(color.green); setforeground(color.red); l1=new Label("First number"); l2=new Label("Second number"); l3=new Label("Result"); f1=new TextField(10); f2=new TextField(20); f3=new TextField(20); //f3=new TextField(20); //f2.setechochar("*"); add(l1); add(f1); add(l2); add(f2); add(l3); add(f3); Add=new Button("Add"); Sub=new Button("Sub"); Mul=new Button("Mult"); Div=new Button("Div"); add(add); add(sub); add(mul); add(div); f1.addtextlistener(this); f2.addtextlistener(this); f3.addtextlistener(this); Java Programming Lab Manual CSSE /VMKVEC. 14
17 Add.addActionListener(this); Sub.addActionListener(this); Mul.addActionListener(this); Div.addActionListener(this); public void actionperformed(actionevent ae) a=integer.parseint(f1.gettext()); b=integer.parseint(f2.gettext()); if(ae.getactioncommand().equals("add")) c=a+b; else if(ae.getactioncommand().equals("sub")) c=a-b; else if(ae.getactioncommand().equals("mult")) c=a*b; else c=a/b; s=string.valueof(c); repaint(); public void paint(graphics g) f3.settext(s); //g.drawstring(string.valueof(c),355,355); PROGRAM: OUTPUT: Java Programming Lab Manual CSSE /VMKVEC. 15
18 Ex. No: 9 Date : Bio-data Generation using Frame AIM ALGORITHM: PROGRAM: import java.awt.*; import java.awt.event.*; public class biodata extends Frame public static void main(string[] args) Frame f = new Frame("Biodata - Entry"); f.setlayout(null); Label l1 = new Label("Biodata"); Label l2 = new Label("Name"); Label l3 = new Label("Gender"); Label l4 = new Label("Address"); Label l5 = new Label("Country"); Label l6 = new Label("Languages Known"); Label l7 = new Label("Hobies"); Checkbox cb1 = new Checkbox("Watch TV",false); Checkbox cb2 = new Checkbox("Play Cricket",false); Button b=new Button("Submit") ; CheckboxGroup rb = new CheckboxGroup(); Checkbox rb1=new Checkbox("Male",rb,false); Checkbox rb2=new Checkbox("Female",rb,false); TextArea ta= new TextArea(); TextField t=new TextField(15); Choice ch=new Choice(); ch.additem("india"); ch.additem("china"); ch.additem("america"); ch.additem("rusia"); ch.additem("japan"); ch.additem("uk"); Java Programming Lab Manual CSSE /VMKVEC. 16
19 List l = new List(5, true); l.additem("hindi"); l.additem("tamil"); l.additem("english"); l.additem("french"); l.additem("chinese"); l.additem("telegu"); l.additem("malayalam"); l.additem("kanada"); t.seteditable(true); l2.setbounds(60, 50, 100, 30); l3.setbounds(60, 80, 100, 30); l4.setbounds(60,110, 100, 30); l5.setbounds(60,190, 100, 30); l6.setbounds(60, 220, 150, 30); l7.setbounds(60, 300, 150, 30); cb1.setbounds(250,300, 70, 25); cb2.setbounds(350, 300, 180, 25); rb1.setbounds(250, 80, 80, 25); rb2.setbounds(350, 80, 80, 25); b.setbounds(100, 450, 200, 25); ch.setbounds(250, 190, 100, 25); l.setbounds(250, 220, 100, 50); t.setbounds(250, 50, 200, 25); ta.setbounds(250, 120, 200, 60); f.add(l1); f.add(l2); f.add(l3); f.add(l4); f.add(l5); f.add(l6); f.add(l7); f.add(b); f.add(cb1); f.add(cb2); f.add(rb1); f.add(rb2); f.add(ta); f.add(t); f.add(ch); Java Programming Lab Manual CSSE /VMKVEC. 17
20 f.add(l); f.setsize(600,700); f.setvisible(true); f.setlocation(200,0); b.addactionlistener(new ActionListener() public void actionperformed(actionevent e) //Execute when button is pressed System.out.println("You Record Saved"); ); System.exit(0); OUTPUT: Java Programming Lab Manual CSSE /VMKVEC. 18
21 Ex. No: 10 Date : AIM Drawing 2D Shapes using Menu bar ALGORITHM: PROGRAM: import java.awt.*; import java.awt.event.*; public class menushape extends Frame public menushape() super("2d Shapes - Menus"); setsize(400, 600); FileMenu filemenu = new FileMenu(this); MenuBar mb = new MenuBar(); mb.add(filemenu); setmenubar(mb); addwindowlistener(new WindowAdapter() public void windowclosing(windowevent e) exit(); ); public void exit() setvisible(false); dispose(); System.exit(0); public void rec() Graphics g=getgraphics(); g.drawrect(250,50,100,50); Java Programming Lab Manual CSSE /VMKVEC. 19
22 public void cir() Graphics g=getgraphics(); g.drawoval(250,250,100,100); public void lin() Graphics g=getgraphics(); g.drawline(50,250,200,250); public static void main(string args[]) menushape w = new menushape(); w.setvisible(true); class FileMenu extends Menu implements ActionListener menushape mw; public FileMenu(menushape m) super("shape"); mw = m; MenuItem mi; add(mi = new MenuItem("Circle")); mi.addactionlistener(this); add(mi = new MenuItem("Rectangle")); mi.addactionlistener(this); add(mi = new MenuItem("Line")); mi.addactionlistener(this); add(mi = new MenuItem("Exit")); mi.addactionlistener(this); public void actionperformed(actionevent e) String item = e.getactioncommand(); if (item.equals("exit")) mw.exit(); else if (item.equals("circle")) mw.cir(); Java Programming Lab Manual CSSE /VMKVEC. 20
23 else if (item.equals("rectangle")) mw.rec(); else if (item.equals("line")) mw.lin(); OUTPUT Java Programming Lab Manual CSSE /VMKVEC. 21
1 GUI GUI GUI GUI GUI. GUI(Graphical User Interface) JDK java.awt. ? Component
99 6 1999.10.13 0 GUI GUI JDK 1.1 GUI 1 GUI GUI GUI(Graphical User Interface) GUI (GUI ) / ( GUI ) Java GUI JDK 1.1 1.2 1.2 Swing 1.1 java.awt GUI? Component setbounds(int, int, int, int) (x,y) setforeground(color)
More informationIII/IV B.Tech (Regular/Supplementary) DEGREE EXAMINATION. Electronics & Instrumentation Engineering Object Oriented Programming with JAVA
Hall Ticket Number: 14EI605 April, 2018 Sixth Semester Time: Three Hours Answer Question No.1 compulsorily. Answer ONE question from each unit. III/IV B.Tech (Regular/Supplementary) DEGREE EXAMINATION
More information) / Java ( )
2002 3 2003.1.29 1 3 ( ) ( ) / Java ( ) 1 ( )? ( ) 2 (3 ) 3 Java Java Java (dynamic dispatch) ( ) import java.awt.*; import java.awt.event.*; public class Sample30 extends Frame { boolean go; double time;
More informationJava Applet & its life Cycle. By Iqtidar Ali
Java Applet & its life Cycle By Iqtidar Ali Java Applet Basic An applet is a java program that runs in a Web browser. An applet can be said as a fully functional java application. When browsing the Web,
More information/* Write a Program implementing GUI based Calculator using Swing */
/* Write a Program implementing GUI based Calculator using Swing */ import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.*; public class Calculator extends JFrame
More informationASSIGNMENT NO 14. Objectives: To learn and demonstrated use of applet and swing components
Create an applet with three text Fields and four buttons add, subtract, multiply and divide. User will enter two values in the Text Fields. When any button is pressed, the corresponding operation is performed
More informationJava - Applets. C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1,
Java - Applets C&G criteria: 1.2.2, 1.2.3, 1.2.4, 1.3.4, 1.2.4, 1.3.4, 1.3.5, 2.2.5, 2.4.5, 5.1.2, 5.2.1, 5.3.2. Java is not confined to a DOS environment. It can run with buttons and boxes in a Windows
More informationCaesar Cipher program in java (SS)
Caesar Cipher program in java (SS) In cryptography Caesar cipher is one of the simple and most widely used Encryption algorithm.caesar cipher is special case of shift cipher.caesar cipher is substitution
More informationJava - Applets. public class Buttons extends Applet implements ActionListener
Java - Applets Java code here will not use swing but will support the 1.1 event model. Legacy code from the 1.0 event model will not be used. This code sets up a button to be pushed: import java.applet.*;
More informationChapter #1. Program to demonstrate applet life cycle
Chapter #1. Program to demonstrate applet life cycle import java.applet.applet; import java.awt.*; public class LifeCycle extends Applet{ public void init(){ System.out.println(" init()"); public void
More informationB.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Lab Programs
B.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Lab Programs 1 1. Write a java program to determine the sum of the following harmonic series for a given value of n. 1+1/2+1/3+...
More informationNRI INSTITUTE OF TECHNOLOGY
NRI INSTITUTE OF TECHNOLOGY KOTHUR, NEAR GUDUR GATE, HYDERABAD, A.P Java Programming Lab Manual B. Tech, CSE, II Year II Sem. 2014-2015 DEPARTMENT OF COMPUTER SCIENCE &ENGINEERING DEPARTMENT OF COMPUTER
More informationJAVA PROGRAM EXAMPLE WITH OUTPUT PDF
JAVA PROGRAM EXAMPLE WITH OUTPUT PDF Created By: Umar Farooque Khan 1 How to compile and run java programs Compile: - javac JavaFileName Run Java: - java JavaClassName Let s take an example of java program:
More informationJava Applet Basics. Life cycle of an applet:
Java Applet Basics Applet is a Java program that can be embedded into a web page. It runs inside the web browser and works at client side. Applet is embedded in a HTML page using the APPLET or OBJECT tag
More informationWeek 9. Abstract Classes
Week 9 Abstract Classes Interfaces Arrays (Assigning, Passing, Returning) Multi-dimensional Arrays Abstract Classes Suppose we have derived Square and Circle subclasses from the superclass Shape. We may
More informationGUI. interface. CUI Character-Based User Interface Command-Based User Interface GUI. Graphical User Interface GUI. Frame Frame.
JavaGUI I interface ] CUI Character-Based User Interface Command-Based User Interface GUI Graphical User Interface GUI GUI 1. ( ) 2. Frame Frame Frameextends ::= [public] class {[ ] [ ] ::= [extends ]
More informationB.Sc (Computer Science) Programming in Java Lab Programs
B.Sc (Computer Science) Programming in Java Lab Programs 1 1. Write java programs to find the following. a) Largest of given Three Numbers b) Reverses the digits of a number c) Given number is prime or
More informationWrite a program which converts all lowercase letter in a sentence to uppercase.
Write a program which converts all lowercase letter in a sentence to uppercase. For Example: 1) Consider a sentence "welcome to Java Programming!" its uppercase conversion is " WELCOME TO JAVA PROGRAMMING!"
More informationProgram 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*;
Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*; /* */ public
More informationExample: CharCheck. That s It??! What do you imagine happens after main() finishes?
Event-Driven Software Paradigm Today Finish Programming Unit: Discuss Graphics In the old days, computers did exactly what the programmer said Once started, it would run automagically until done Then you
More informationQueens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide
Topics for Exam 2: Queens College, CUNY Department of Computer Science CS 212 Object-Oriented Programming in Java Practice Exam 2 CS 212 Exam 2 Study Guide Linked Lists define a list node define a singly-linked
More informationLoops. CSE 114, Computer Science 1 Stony Brook University
Loops CSE 114, Computer Science 1 Stony Brook University http://www.cs.stonybrook.edu/~cse114 1 Motivation Suppose that you need to print a string (e.g., "Welcome to Java!") a user-defined times N: N?
More informationISO-2022-JP (JIS ) 1 2. (Windows95/98 MacOS ) Java UNICODE UNICODE. Java. .java.java.txt native2ascii. .java
2000 8 2000.1.24-27 0 4 1 ( (1 8 ) ASCII 1 8 1 1 8 2 ISO-2022-JP (JIS ) 1 2 EUC ( EUC) 8 Unix SJIS (MS ) EUC 8 ( (Windows95/98 MacOS Java UNICODE UNICODE ( Java.java.java.txt native2ascii.java native2ascii
More informationDEMONSTRATION OF AWT CONTROLS
Ex.No: 1(A) DATE: 02.07.11 DEMONSTRATION OF AWT CONTROLS Aim: To write a java program for demonstrating the following AWT controls 1. Button 2.Checkbox 3.Choice 4.List 5.TextField 6.Scrollbar Hardware
More informationThe most striking feature of Java is Platform neutralness. Java is the first language that is not tied to any particular hardware or O.S.
HISTORY Java is the general purpose, true object oriented programming language and is highly suitable for modeling the real world and solving the real world problems. In the company Sun Microsystem, James
More information4. Finding & Displaying Record of Salesman with minimum net income. 5. Finding & Displaying Record of Salesman with maximum net income.
Solution of problem#55 of Lab Assignment Problem Statement: Design & Implement a java program that can handle salesmen records of ABC Company. Each salesman has unique 4 digit id #, name, salary, monthly
More informationJava - Applications. The following code sets up an application with a drop down menu, as yet the menu does not do anything.
Java - Applications C&G Criteria: 5.3.2, 5.5.2, 5.5.3 Java applets require a web browser to run independently of the Java IDE. The Dos based console applications will run outside the IDE but have no access
More informationChapter 1 GUI Applications
Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations
More informationThe AWT Component Library 10
The AWT Component Library 10 Course Map The JDK offers many components from which GUIs an be built. This module examines these AWT Components, and covers noncomponent AWT classes such as Color and Font,
More informationString is one of mostly used Object in Java. And this is the reason why String has unique handling in Java(String Pool). The String class represents
String is one of mostly used Object in Java. And this is the reason why String has unique handling in Java(String Pool). The String class represents character strings. All string literals in Java programs,
More informationBSc. (Hons.) Software Engineering. Examinations for / Semester 2
BSc. (Hons.) Software Engineering Cohort: BSE/04/PT Examinations for 2005-2006 / Semester 2 MODULE: OBJECT ORIENTED PROGRAMMING MODULE CODE: BISE050 Duration: 2 Hours Reading Time: 5 Minutes Instructions
More informationCSC 1051 Data Structures and Algorithms I
Repetition CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides in this
More informationA sample print out is: is is -11 key entered was: w
Lab 9 Lesson 9-2: Exercise 1, 2 and 3: Note: when you run this you may need to maximize the window. The modified buttonhandler is: private static class ButtonListener implements ActionListener public void
More informationLaborator 2 Aplicatii Java
Laborator 2 Aplicatii Java Introducere in programarea vizuala - Pachetul AWT Scrieti, compilati si rulati toate exemplele din acest laborator: 1. import java.awt.*; class First extends Frame First() Button
More informationS.E. Sem. III [CMPN] Object Oriented Programming Methodology
S.E. Sem. III [CMPN] Object Oriented Programming Methodology Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 80 Q.1(a) Write a program to calculate GCD of two numbers in java. [5] (A) import java.util.*;
More informationimport javax.swing.*; public class Sample { JFrame f; Sample(){ f=new JFrame(); JButton b=new JButton("click"); b.setbounds(130,100,100, 40); f.add(b); f.setsize(400,500); f.setlayout(null); f.setvisible(true);
More informationGraphical Interfaces
Weeks 11&12 Graphical Interfaces All the programs that you have created until now used a simple command line interface, which is not user friendly, so a Graphical User Interface (GUI) should be used. The
More informationJava Applets / Flash
Java Applets / Flash Java Applet vs. Flash political problems with Microsoft highly portable more difficult development not a problem less so excellent visual development tool Applet / Flash good for:
More informationGraphical Interfaces
Weeks 9&11 Graphical Interfaces All the programs that you have created until now used a simple command line interface, which is not user friendly, so a Graphical User Interface (GUI) should be used. The
More informationRecitation: Loop Jul 7, 2008
Nested Loop Recitation: Loop Jul 7, 2008 1. What is the output of the following program? Use pen and paper only. The output is: ****** ***** **** *** ** * 2. Test this program in your computer 3. Use "for
More informationMYcsvtu Notes. Java Programming Lab Manual
Java Programming Lab Manual LIST OF EXPERIMENTS 1. Write a Program to add two numbers using Command Line Arguments. 2. Write a Program to find the factorial of a given number using while statement. 3.
More informationprotected void printserial() { System.out.println("> NO." + this.serialno); this.serialno++; }
NumberedTicketGenerator.java package j2.exam.ex01; public abstract class NumberedTicketGenerator { protected int serialno; public NumberedTicketGenerator() { super(); this.serialno = 1000; public void
More informationEE219 Object Oriented Programming I (2005/2006) SEMESTER 1 SOLUTIONS
Q1(a) Corrected code is: EE219 Object Oriented Programming I (2005/2006) SEMESTER 1 SOLUTIONS 01 #include 02 using namespace std; 03 04 class Question1 05 06 int a,b,*p; 07 08 public: 09 Question1(int
More informationMidterm Examination (MTA)
M105: Introduction to Programming with Java Midterm Examination (MTA) Spring 2013 / 2014 Question One: [6 marks] Choose the correct answer and write it on the external answer booklet. 1. Compilers and
More informationMLR Institute of Technology Dundigal, Quthbullapur (M), Hyderabad
MLR Institute of Technology Dundigal, Quthbullapur (M), Hyderabad 500 043 INFORMATION TECHNOLOGY TUTORIAL QUESTION BANK Name Code Class : JAVA PROGRAMMING : A40503 : II B. Tech II Semester Branch : Information
More informationVarious useful classes
Various useful classes String manipulation Mathematical functions Standard input / output File input / output Various system features Hashtable Useful graphical classes String manipulation a string is
More informationJava. GUI building with the AWT
Java GUI building with the AWT AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many applications Uses the controls defined by your OS therefore
More informationIST 297D Introduction to Application Programming Chapter 4 Problem Set. Name:
IST 297D Introduction to Application Programming Chapter 4 Problem Set Name: 1. Write a Java program to compute the value of an investment over a number of years. Prompt the user to enter the amount of
More informationThe AWT Package, Placing Components in Containers, CardLayout. Preface. Introduction
Richard G Baldwin (512) 223-4758, baldwin@austin.cc.tx.us, http://www2.austin.cc.tx.us/baldwin/ The AWT Package, Placing Components in Containers, CardLayout Java Programming, Lecture Notes # 120, Revised
More informationDay before tests of Java Final test. IDM institution of Bandarawela. Project for department of education
Day before tests of Java Final test. IDM institution of Bandarawela Project for department of education import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Doenets extends JApplet
More informationPackages: Putting Classes Together
Packages: Putting Classes Together 1 Introduction 2 The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance) Extending interfaces The features in basic
More informationAim: Write a java program to demonstrate the use of following layouts. 1.FlowLayout 2.BorderLayout 3.GridLayout 4.GridBagLayout 5.
DEMONSTRATION OF LAYOUT MANAGERS DATE:09.07.11 Aim: Write a java program to demonstrate the use of following layouts. 1.FlowLayout 2.BorderLayout 3.GridLayout 4.GridBagLayout 5.CardLayout Hardware requirements:
More informationDate: AIM. Write a Java program to demo simple inheritance PROCEDURE
Ex.No 7 Date: AIM INHERITANCE Write a Java program to demo simple inheritance PROCEDURE 1. Create a class stud which includes student name,major,year, rollno. 2. Create a class mark which extends the stud
More information( &% class MyClass { }
Recall! $! "" # ' ' )' %&! ( &% class MyClass { $ Individual things that differentiate one object from another Determine the appearance, state or qualities of objects Represents any variables needed for
More informationCSC 1051 Data Structures and Algorithms I
Repetition CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides in this
More informationPractical 1 Date : Statement: Write a program to find a factorial of given number by user. Program:
Practical 1 Date : Statement: Write a program to find a factorial of given number by user. Program: class Pract1 public static void main(string s[]) int n,a1; n=integer.parseint(s[0]); A a = new A(); a1
More informationBuilding Strings and Exploring String Class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Lecture Notes K.Yellaswamy Assistant Professor CMR College of Engineering & Technology Building Strings and Exploring
More informationDataInputStream dis=new DataInputStream(System.in);
SET 2 Answer Key 1.a. import java.util.*; import java.io.*; class sorting public static void main(string as[])throws Exception DataInputStream dis=new DataInputStream(System.in); System.out.println("Enter
More informationd. If a is false and b is false then the output is "ELSE" Answer?
Intermediate Level 1) Predict the output for the below code: public void foo( boolean a, boolean b) if( a ) System.out.println("A"); if(a && b) System.out.println( "A && B"); if (!b ) System.out.println(
More informationJava Arrays and Collections
Java Arrays and Collections Java has a number of ways of putting data into sets. Some of these are remarkably similar. This is because Java has evolved with new features leaving older features still valid.
More informationGUI in Java TalentHome Solutions
GUI in Java TalentHome Solutions AWT Stands for Abstract Window Toolkit API to develop GUI in java Has some predefined components Platform Dependent Heavy weight To use AWT, import java.awt.* Calculator
More informationCS 617 Object Oriented Systems Lecture 5 Classes, Classless World:Prototypes, Instance Variables, Class Variables, This/Self 3:30-5:00 pm Thu, Jan 17
Objects, Interfaces and CS 617 Object Oriented Systems Lecture 5, Classless World:Prototypes, Instance Variables, Class Variables, This/Self 3:30-5:00 pm Thu, Jan 17 Rushikesh K Joshi Department of Computer
More informationAWT DIALOG CLASS. Dialog control represents a top-level window with a title and a border used to take some form of input from the user.
http://www.tutorialspoint.com/awt/awt_dialog.htm AWT DIALOG CLASS Copyright tutorialspoint.com Introduction Dialog control represents a top-level window with a title and a border used to take some form
More informationProgramming Mobile Devices J2SE GUI
Programming Mobile Devices J2SE GUI University of Innsbruck WS 2009/2010 thomas.strang@sti2.at Graphical User Interface (GUI) Why is there more than one Java GUI toolkit? AWT write once, test everywhere
More informationINDEX SL.NO NAME OF PROGRAMS PAGE NO REMARKS PROGRAM TO FIND FACTORIAL OF THREE
INDEX SL.NO NAME OF PROGRAMS PAGE NO REMARKS PROGRAM TO FIND FACTORIAL OF THREE 1 NUMBERS PROGRAM FOR SUM OF SERIES USING 2 MATHPOWER METHOD 3 PROGRAM ON COMMAND LINE ARGUMENT 4 PROGRAM TO PRINT FIBONACI
More informationQuarter 1 Practice Exam
University of Chicago Laboratory Schools Advanced Placement Computer Science Quarter 1 Practice Exam Baker Franke 2005 APCS - 12/10/08 :: 1 of 8 1.) (10 percent) Write a segment of code that will produce
More informationThe Final One. Case Study: Adding a GUI to the Student Data Base. Graphical Use Interfaces: the student database example. Assignments.
The Final One Graphical Use Interfaces: the student database example. Assignments. Module questionnaire. Looking back... 1 2-1 Case Study: Adding a GUI to the Student Data Base Problem. We want to add
More information7. Program Frameworks
7. Program Frameworks Overview: 7.1 Introduction to program frameworks 7.2 Program frameworks for User Interfaces: - Architectural properties of GUIs - Abstract Window Toolkit of Java Many software systems
More informationExp 6: Develop Java programs to implement Interfaces and Packages. Apply Exception handling and implement multithreaded programs.
CO504.3 CO504.4 Develop Java programs to implement Interfaces and Packages. Apply Exception handling and implement multithreaded programs. CO504.5 CO504.6 Implement Graphics programs using Applet. Develop
More informationClass 09 Slides: Polymorphism Preconditions. Table of Contents. Postconditions
Class 09 Slides: Polymorphism Preconditions Students are familiar with inheritance and arrays. Students have worked with a poorly written program in A08 that could benefit from polymorphism. Students have
More informationJava Foundations Certified Junior Associate
Java Foundations Certified Junior Associate 习题 1. When the program runs normally (when not in debug mode), which statement is true about breakpoints? Breakpoints will stop program execution at the last
More informationThe first version of the bank will look like this:
Lecture 16 The Bank The first version of the bank will look like this: The user will be able to make a deposit, and the result will be reflected in several fields. In addition if the user makes a second
More informationWindow Interfaces Using Swing Objects
Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs
More informationAdvanced Internet Programming CSY3020
Advanced Internet Programming CSY3020 Java Applets The three Java Applet examples produce a very rudimentary drawing applet. An Applet is compiled Java which is normally run within a browser. Java applets
More informationChapter 10 Input Output Streams
Chapter 10 Input Output Streams ICT Academy of Tamil Nadu ELCOT Complex, 2-7 Developed Plots, Industrial Estate, Perungudi, Chennai 600 096. Website : www.ictact.in, Email : contact@ictact.in, Phone :
More informationSpecial Exercise Unit: Introduction to Java
Special Exercise Unit: Introduction to Java Introduction First Program / Applet : Hello World Java Virtual Machine Java Basics (types, operators, statements, etc.) Object Orientation Standard Libraries
More informationLaborator 3 Aplicatii Java
Laborator 3 Aplicatii Java 1. Programarea vizuala Scrieti, compilati si rulati toate exemplele din acest laborator: 1. Fisierul se numeste testschimbareculori.java: import java.awt.*; import java.awt.event.*;
More informationLab Exercise 1. Objectives: Part 1. Introduction
Objectives: king Saud University College of Computer &Information Science CSC111 Lab Object II All Sections - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Page 1 of 18 Q1. A. Attempt any three of the following. a. (Half mark for each data type and its size) Type Size byte One byte short Two bytes int Four bytes long Eight bytes float Four Bytes double Eight
More informationH212 Introduction to Software Systems Honors
Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,
More informationUnit 1- Java Applets. Applet Programming. Local Applet and Remote Applet ** Applet and Application
Applet Programming Applets are small Java applications that can be accessed on an Internet server, transported over Internet, and can be automatically installed and run as a part of a web document. An
More informationLecture Notes K.Yellaswamy Assistant Professor K L University
Lecture Notes K.Yellaswamy Assistant Professor K L University Building Strings and Exploring String Class: -------------------------------------------- The String class ------------------- String: A String
More informationpackage import public class public static void int out new for break else out else out
//1) WAP in JAVA to check whether no is prime or not. package finalpracs; import java.util.scanner; public class Prime public static void main(string args[]) int a, i, flag=0; System.out.println("Enter
More informationK.Yellaswamy Asst.Professor K L University
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 Packages ================ Information regarding packages:- 1) The package contains group of
More informationFinal Examination Semester 3 / Year 2008
Southern College Kolej Selatan 南方学院 Final Examination Semester 3 / Year 2008 COURSE : JAVA PROGRAMMING COURSE CODE : PROG1114 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE CLASS : CS08-A + CS08-B LECTURER
More informationCS171:Introduction to Computer Science II
CS171:Introduction to Computer Science II Department of Mathematics and Computer Science Li Xiong 9/7/2012 1 Announcement Introductory/Eclipse Lab, Friday, Sep 7, 2-3pm (today) Hw1 to be assigned Monday,
More informationOct Decision Structures cont d
Oct. 29 - Decision Structures cont d Programming Style and the if Statement Even though an if statement usually spans more than one line, it is really one statement. For instance, the following if statements
More informationUNIVERSITI SAINS MALAYSIA. CIT502 Object-Oriented Programming and Software Engineering
UNIVERSITI SAINS MALAYSIA First Semester Examination Academic Session 2003/2004 September/October 2003 CIT502 Object-Oriented Programming and Software Engineering Duration : 3 hours INSTRUCTION TO CANDIDATE:
More informationFollowing is the general form of a typical decision making structure found in most of the programming languages:
Decision Making Decision making structures have one or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined
More informationChapter 1 Introduction to Java
Chapter 1 Introduction to Java Lesson page 0-1. Introduction to Livetexts Question 1. A livetext is a text that relies not only on the printed word but also on graphics, animation, audio, the computer,
More informationExample: Monte Carlo Simulation 1
Example: Monte Carlo Simulation 1 Write a program which conducts a Monte Carlo simulation to estimate π. 1 See https://en.wikipedia.org/wiki/monte_carlo_method. Zheng-Liang Lu Java Programming 133 / 149
More informationSAZ4A/SAE4A/BPC41 PROGRAMMING IN JAVA Unit : I - V
SAZ4A/SAE4A/BPC41 PROGRAMMING IN JAVA Unit : I - V UNIT I -- Introduction to Java -- Features of Java -- Basic Concepts of Object Oriented Programming -- Java Tokens -- Java Statements -- Constants --
More informationChapter 4: Control Structures I
Chapter 4: Control Structures I Java Programming: From Problem Analysis to Program Design, Second Edition Chapter Objectives Learn about control structures. Examine relational and logical operators. Explore
More informationCS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70
CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 2012 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers
More information- Thus there is a String class (a large class)
Strings - Strings in Java are objects - Thus there is a String class (a large class) - In a statement like this: System.out.println( Hello World ); the Java compiler creates a String object from the quoted
More informationEE219 Object Oriented Programming I Repeat Solutions for 2005/2006
EE219 Object Oriented Programming I Repeat Solutions for 2005/2006 Q1(a) Corrected Code: #include using namespace std; class Question1 int a,b; public: Question1(); Question1(int, int); virtual
More informationJAVA NOTES GRAPHICAL USER INTERFACES
1 JAVA NOTES GRAPHICAL USER INTERFACES Terry Marris 24 June 2001 5 TEXT AREAS 5.1 LEARNING OUTCOMES By the end of this lesson the student should be able to understand how to get multi-line input from the
More informationAWT QUADCURVE2D CLASS
AWT QUADCURVE2D CLASS http://www.tutorialspoint.com/awt/awt_quadcurve2d_class.htm Copyright tutorialspoint.com Introduction The QuadCurve2D class states a quadratic parametric curve segment in x, y coordinate
More informationAURORA S PG COLLEGE MOOSARAMBAGH MCA DEPARTMENT JAVA LAB MANUAL
AURORA S PG COLLEGE MOOSARAMBAGH MCA DEPARTMENT JAVA LAB MANUAL Introduction to JAVA: JAVA was developed by Sun Microsystems Inc in 1991, later acquired by Oracle Corporation. It was developed by James
More informationCMP 326 Midterm Fall 2015
CMP 326 Midterm Fall 2015 Name: 1) (30 points; 5 points each) Write the output of each piece of code. If the code gives an error, write any output that would happen before the error, and then write ERROR.
More information