B.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Lab Programs
|
|
- Linda Hart
- 6 years ago
- Views:
Transcription
1 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+... _1/n class Prog1 BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the value of n for Harmonic Series"); int n=integer.parseint(br.readline()); double sum=0.0; for(int i=1;i<=n;i++) sum=sum+1.0/i; System.out.println("Total of Harmonic Series upto" +n+ "=" + sum); 2. Write a program to perform the following operations on strings through interactive input. a) Sort given strings in alphabetical order. b) Check whether one string is sub string of another string or not. c) Convert the strings to uppercase. a) class Prog2a System.out.println("Enter number of strings:"); int n=integer.parseint(br.readline()); System.out.println("Enter " + n + " String:"); String name[]=new String[n]; for(int i=0;i<n;i++) name[i]=br.readline(); System.out.println(" "); String temp=null; for(int i=0;i<name.length;i++) for(int j=i+1;j<name.length;j++) if(name[j].compareto(name[i])<0)
2 temp=name[i]; name[i]=name[j]; name[j]=temp; 2 System.out.println("Sorted Strings:"); System.out.println(" "); for(int i=0;i<name.length;i++) System.out.println(name[i]); b) class Prog2b System.out.println("Enter the Main String:"); String m=br.readline(); System.out.println("Enter the Sub String:"); String s=br.readline(); int index=m.indexof(s); if (index!= -1) System.out.println("It is a sub string"); else System.out.println("No. It is not a sub string"); c) class Prog2c System.out.println("Enter number of strings:"); int n=integer.parseint(br.readline()); System.out.println("Enter " + n + " String:"); String name[]=new String[n]; for(int i=0;i<n;i++) name[i]=br.readline(); System.out.println(" "); for(int i=0;i<n;i++) name[i]=name[i].touppercase(); System.out.println("Strings in Uppercase");
3 System.out.println(" "); 3 for(int i=0;i<name.length;i++) System.out.println(name[i]); 3. Write a program to simulate on-line shopping. class OnlineShopping public static void main(string args[]) throws Exception int i=0,n,borrow,sum=0; String con=""; int a[]=new int[10]; String name[]=new String[10]; String s[]="c Programming","Java","DBMS","Web Technologies"; int price[]=200,250,300,350; do System.out.println("Select Books from the list:\n"); System.out.println(" 1.C Programming-Rs.200"); System.out.println(" 2.Java-Rs.250"); System.out.println(" 3.DBMS-Rs.300"); System.out.println(" 4.Web Technologies-Rs.350"); System.out.println("\nSelect the book number:"); n=integer.parseint(br.readline()); n--; if(n<0 n>3) System.out.println("Invalid"); break; a[i]=n; System.out.println("Enter your name:"); name[i]=br.readline(); i++; System.out.println("Continue?(y,n):"); con=br.readline(); while(con.equals("y")); borrow=i; if(borrow>0) System.out.println("****************************************"); System.out.println("\nName \t Book Purchased"); System.out.println("****************************************"); for(i=0;i<=n;i++)
4 if(name[i]!=null) 4 if(a[i]==0) sum=sum+200; else if(a[i]==1) sum=sum+250; else if(a[i]==2) sum=sum+300; else if(a[i]==3) sum=sum+350; System.out.println(name[i]+"\t"+s[a[i]]); System.out.println("Total Price=" + sum); System.out.println("****************************************"); 4. Write a program to identify duplicate value in a vector. import java.util.vector; class Prog4 Vector v=new Vector(); System.out.println("Enter the number of values to insert into Vector"); int n=integer.parseint(br.readline()); System.out.println("Enter " + n + " values:"); for(int i=0;i<n;i++) v.addelement(br.readline()); System.out.println(" Duplicate values are "); for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) if(v.elementat(j).equals(v.elementat(i))) System.out.println(v.elementAt(j)); 5. Create two threads such that one of the thread print even no s and another prints odd no s up to a given range. class Even extends Thread int x,y; public Even(int a,int b) x=a; y=b; public void run()
5 for(int i=x; i<=y; i++) if(i%2==0) System.out.println("Even Number " + i); 5 class Odd extends Thread int x,y; public Odd(int a,int b) x=a; y=b; public void run() for(int j=x; j<=y; j++) if(j%2!=0) System.out.println("Odd number " + j); class Prog5 System.out.println("Enter Starting value"); int r1=integer.parseint(br.readline()); System.out.println("Enter Ending value"); int r2=integer.parseint(br.readline()); Even e=new Even(r1,r2); Odd o=new Odd(r1,r2); e.start(); o.start(); 6. Define an exception called MarksOutOfBound Exception that is thrown if the entered marks are greater than 100. class MarksOutOfBound extends Exception MarksOutOfBound(String s) super(s);
6 6 class Prog6 try System.out.println("Enter student name:"); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String name=br.readline(); System.out.println("Enter the marks in Java:"); int marks=integer.parseint(br.readline()); if (marks>100) throw new MarksOutOfBound("Marks should not be greater than 100."); System.out.println("Entered marks: " + marks+ " is valid"); catch (MarksOutOfBound mb) System.out.println(mb.getMessage()); 7. Write a program to shuffle the list elements using all possible permutations. import java.util.*; class Prog7 BufferedReader br = new BufferedReader(new InputStreamReader (System.in)); System.out.print("How many elements you want to add to the list: "); int n = Integer.parseInt(br.readLine()); System.out.println("Enter " + n + " numbers"); List Y = new ArrayList(n); for(int i = 0; i < n; i++) Y.add(br.readLine()); System.out.println("List:"+ Y); int fact=1; for(int j=1;j<=n;j++) fact=fact*j; int count=0; for(int i = 0; i < fact; i++) Collections.shuffle(Y); System.out.println("List:"+Y);
7 count++; System.out.println("The number of possible permutations=" + count); 7 8. Create a package called Arithmetic that contains methods to deal with all arithmetic operations. Also, write a program to use the package. package Arithmetic; public class Prog8 public int add(int a,int b) return a+b; public int sub(int a,int b) return a-b; public int mult(int a,int b) return a*b; public double div(int a,int b) return a/b; import Arithmetic.Prog8; public class Prog8a System.out.println("Enter the values of A and B:"); int a=integer.parseint(br.readline()); int b=integer.parseint(br.readline()); Prog8 p=new Prog8(); System.out.println("Addition=" + p.add(a,b)); System.out.println("Subtraction=" + p.sub(a,b)); System.out.println("Multiplication=" + p.mult(a,b)); System.out.println("nDivision=" + p.div(a,b));
8 8 9. Write an Applet program to design a simple calculator. import java.applet.*; import java.awt.*; import java.awt.event.*; public class Calc extends Applet implements ActionListener String cmd[]="+","-","*","/","=","c"; int pv=0; String op=""; Button b[]=new Button[16]; TextField t1=new TextField(10); public void init() setlayout(new BorderLayout()); add(t1,"north"); t1.settext("0"); Panel p=new Panel(); p.setlayout(new GridLayout(4,4)); for(int i=0;i<16;i++) if(i<10) b[i]=new Button(String.valueOf(i)); else b[i]=new Button(cmd[i%10]); b[i].setfont(new Font("Arial",Font.BOLD,25)); p.add(b[i]); add(p,"center"); b[i].addactionlistener(this); public void actionperformed(actionevent ae) int res=0; String cap=ae.getactioncommand(); int cv=integer.parseint(t1.gettext()); if(cap.equals("c")) t1.settext("0"); pv=0; cv=0; res=0; op=""; else if(cap.equals("=")) res=0; if(op=="+") res=pv+cv; else if(op=="-") res=pv-cv; else if(op=="*") res=pv*cv; else if(op=="/") res=pv/cv; t1.settext(string.valueof(res));
9 else if(cap.equals("+") cap.equals("-") cap.equals("*") cap.equals("/")) pv=cv; op=cap; t1.settext("0"); else int v=cv*10+integer.parseint(cap); t1.settext(string.valueof(v)); Write a program to read a text and count all the occurrences of a given word. Also, display their position. import java.lang.string; public class Prog10 public static void main(string args[]) throws IOException System.out.println("Enter the Text:"); String m=br.readline(); System.out.println("Enter the word to search:"); String s=br.readline(); int index = m.indexof(s); int len = s.length(); int count = 0; if (len > 0) while (index!= -1) count++; System.out.println("Found at position:" + index); index = m.indexof(s, index+len); if(count!=0) System.out.println("The number of occurrences of the given word is: " + count); else System.out.println( Word does not exist ); 11. Write an applet illustrating sequence of events in an applet. import java.awt.*; import java.applet.applet; public class Prog11 extends Applet String msg; public void init() setbackground(color.cyan); setforeground(color.blue);
10 msg=" Init()"; 10 public void start() msg= msg + " Start()"; public void paint(graphics g) msg= msg + " Paint()"; g.drawstring(msg, 100,100); showstatus("this is displyed in status window"); public void destroy() msg= msg + " Destroyed()"; 12.Illustrate the method overriding in Java class A int i; A(int a, int b) i = a+b; void add() System.out.println("Sum of a and b is: " + i); class B extends A int j; B(int a, int b, int c) super(a, b); j = a+b+c; void add() super.add(); System.out.println("Sum of a, b and c is: " + j); class Prog12 public static void main(string args[]) B b = new B(10, 20, 30); b.add();
11 11 13.Write a program to fill elements into a list. Also, copy them in reverse order into another list. import java.util.*; class Prog13 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("How many elements you want to add to the list: "); int n = Integer.parseInt(br.readLine()); System.out.println("Enter " + n + " elements"); List Y = new ArrayList(n); for(int i = 0; i < n; i++) Y.add(br.readLine()); System.out.println("List:"+ Y); Collections.reverse(Y); System.out.println("Reverse List:"+ Y); List revlist= new ArrayList(n); for(int i=0;i<n;i++) revlist.add(y.get(i)); System.out.println("List 2:"+ revlist); 14.Write an interactive program to accept name of a person and validate it. If the name contains any numberic value throw an exception InvalidName class invname extends Exception invname(string s) super(s); class Prog14 try System.out.println("Enter student name:"); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String name=br.readline(); for(int i=0;i<name.length();i++) if (Character.isDigit(name.charAt(i)))
12 text"); throw new invname("string contains numeric value."); System.out.println("Entered Stirng : " + name + " contains only catch (invname in) System.out.println(in.getMessage()); Write an applet program to insert the text at the specified position. import java.awt.*; import java.applet.*; import java.awt.event.*; public class Prog15 extends Applet implements ActionListener TextArea ta=new TextArea("",2,20); TextField t1=new TextField(10); TextField t2=new TextField(10); Button b1=new Button("Insert"); public void init() add(t1); add(t2); add(b1); add(ta); b1.addactionlistener(this); public void actionperformed(actionevent ae) ta.insert(t1.gettext(),1); ta.insert(t2.gettext(),6); 16.Prompt for the cost price and selling price of an article and display the profit (or) loss percentage. class Prog16 System.out.println("Enter the cost price:"); BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
13 double cost=double.parsedouble(br.readline()); System.out.println("Cost Price:" + cost); System.out.println("Enter the Selling price:"); double sell=double.parsedouble(br.readline()); System.out.println("Selling Price:" + sell); if(cost>sell) System.out.println("Loss=" + (cost-sell)); System.out.println("Loss Percentage=" + ((costsell)/cost)*100); 13 System.out.println("Profit=" + (sell-cost)); System.out.println("Profit Percentage=" + ((sellcost)/cost)*100); else 17.Create an Anonymous array in Java public class AnonymousArrayExample public static void main(string args[]) System.out.println( Length of array is + findlength(new int[]1,2,3)); public static int findlength(int[] array) for(int i=0;i<array.length;i++) System.out.println(array[i]); return array.length; 18. Create a font animation application that change the colors of text as and when prompted. import java.applet.*; import java.awt.*; import java.awt.event.*; public class Prog18 extends Applet implements ActionListener Button b1=new Button("Change Color"); int r=0,g=0,b=0; public void init() add(b1);
14 b1.addactionlistener(this); setfont(new Font("Arial",Font.BOLD,30)); 14 public void actionperformed(actionevent ae) r=(int)(math.random()*255); g=(int)(math.random()*255); b=(int)(math.random()*255); repaint(); public void paint(graphics gr) setbackground(new Color(125,34,67)); gr.setcolor(new Color(r,g,b)); gr.drawstring("bsc Students are very Good",10,100); 19. Write an interactive program to wish the user at different hours of the day. import java.util.*; class Prog19 System.out.println("Enter your name:"); String name=br.readline(); Calendar t=calendar.getinstance(); t.settimezone(timezone.gettimezone("ist")); int hourtime=t.get(calendar.hour_of_day); System.out.println("Time=" + hourtime); if(hourtime<12) System.out.println("Good Morning, " + name); else if(hourtime>=12 && hourtime<16) System.out.println("Good Afternoon " + name); else if(hourtime>=16 && hourtime<21) System.out.println("Good Evening " + name); else System.out.println("Good Night " + name); 20. Simulate the library information system i.e. maintain the list of books and borrower's details. class Library
15 public static void main(string args[]) throws Exception int i=0,n,borrow; String con=""; int a[]=new int[10]; String name[]=new String[10]; String s[]="c Programming","Java","DBMS","Web Technologies"; 15 do System.out.println("Select Books from the list:\n"); System.out.println(" 1.C Programming"); System.out.println(" 2.Java"); System.out.println(" 3.DBMS"); System.out.println(" 4.Web Technologies"); System.out.println("\nSelect the book number:"); n=integer.parseint(br.readline()); if(n<1 n>4) System.out.println("Invalid"); break; a[i]=n; System.out.println("Enter your name:"); name[i]=br.readline(); i++; System.out.println("Continue?(y,n):"); con=br.readline(); while(con.equals("y")); borrow=i; if(borrow>0) System.out.println("****************************************"); System.out.println("\nName \t Book borrowed"); System.out.println("****************************************"); for(i=0;i<n;i++) if(name[i]!=null) System.out.println(name[i]+"\t"+s[a[i]]); System.out.println("****************************************");
B.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 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 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 informatione) Implicit and Explicit Type Conversion Pg 328 j) Types of errors Pg 371
Class IX HY 2013 Revision Guidelines Page 1 Section A (Power Point) Q1.What is PowerPoint? How are PowerPoint files named? Q2. Describe the 4 different ways of creating a presentation? (2 lines each) Q3.
More informationPrasanth Kumar K(Head-Dept of Computers)
B.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Unit-II 1 1. Define operator. Explain the various operators in Java. (Mar 2010) (Oct 2011) Java supports a rich set of
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 informationB.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Lab Programs- Data Structures
B.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Lab Programs- Data Structures 1 1. Program to implement Bubble Sort. class Prog37 public static void main(string[] args)
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 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 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 information/ Download the Khateeb Classes App
Q) Write a program to read and display an array on screen. class Data public static void main(string args[ ]) throws IOException int i,n; InputStreamReader r = new InputStreamReader(System.in); BufferedReader
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 informationQuestion-2 a) No. throw throws 1) Java throw keyword is used to explicitly throw an exception. Java throws keyword is used to declare an
Question-1 a) Operator:- Symbol used to combine operands Operand: - Operands are values or variables that hold the values. b) Wrapping up of data and function into a single unit is known as encapsulation
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 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 informationCORBA Java. Java. Java. . Java CORBA. Java CORBA (RMI) CORBA ORB. . CORBA. CORBA Java
CORBA Java?? OMG CORBA IDL C, C++, SmallTalk, Ada Java COBOL, ORB C Ada Java C++ CORBA Java CORBA Java (RMI) JDK12 Java CORBA ORB CORBA,, CORBA? CORBA,,, CORBA, CORBA CORBA Java (, ) Java CORBA Java :
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 informationFIFO PAGE REPLACEMENT : import java.io.*; public class FIFO {
FIFO PAGE REPLACEMENT : import java.io.*; public class FIFO public static void main(string[] args) throws IOException BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int frames,
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 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 information1 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 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 information1)Write a program on inheritance and check weather the given object is instance of a class or not?
1)Write a program on inheritance and check weather the given object is instance of a class or not? class A class B extends A class C extends A class X A a1=new B(); if(a1 instanceof B) System.out.println(
More information//PERIMETER & AREA OF TRIANGLE
// SUBSTRING REMOVAL import java.io.*; import java.util.*; class Substr public static void main(string args[]) throws IOException char a[]=new char[100]; char b[]=new char[100]; String out=" "; System.out.println("Enter
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 informationRecursion. General Algorithm for Recursion. When to use and not use Recursion. Recursion Removal. Examples
Recursion General Algorithm for Recursion When to use and not use Recursion Recursion Removal Examples Comparison of the Iterative and Recursive Solutions Exercises Unit 19 1 General Algorithm for Recursion
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 informationPART1: Choose the correct answer and write it on the answer sheet:
PART1: Choose the correct answer and write it on the answer sheet: (15 marks 20 minutes) 1. Which of the following is included in Java SDK? a. Java interpreter c. Java disassembler b. Java debugger d.
More informationWeek -1. Try debug step by step with small program of about 10 to 15 lines which contains at least one if else condition and a for loop.
Week -1 Try debug step by step with small program of about 10 to 15 lines which contains at least one if else condition and a for loop. Java Code import java.util.scanner; public class TestPrime public
More informationAssignment2013 Please use this document only for verifying if your programs are right. Do not blindly copy paste and waste your time.
Please use this document only for verifying if your programs are right. Do not blindly copy paste and waste your time. 11/3/2013 TechSparx Computer Training Center Saravanan.G Please use this document
More informationRecursive Problem Solving
Recursive Problem Solving Objectives Students should: Be able to explain the concept of recursive definition. Be able to use recursion in Java to solve problems. 2 Recursive Problem Solving How to solve
More informationBufferedReader br = new BufferedReader(new InputStreamReader(System.in));
2.A. Design a superclass called Staff with details as StaffId, Name, Phone, Salary. Extend this class by writing three subclasses namely Teaching (domain, publications), Technical (skills), and Contract
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 information// This program has been written to show the implementation of Constructor Overloading and Parameterized Constructor.
// This program has been written to show the implementation of Constructor Overloading and Parameterized Constructor. class Program01 int a,b; public Program01() a=20; b=43; public Program01(int a,int
More informationAN IMPROTANT COLLECTION OF JAVA IO RELATED PROGRAMS
JAVALEARNINGS.COM AN IMPROTANT COLLECTION OF JAVA IO RELATED PROGRAMS Visit for more pdf downloads and interview related questions JAVALEARNINGS.COM /* Write a program to write n number of student records
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 informationWeek 2 assignment:
Week 2 assignment: Assignments: 1. Write a Java program to check whether a number is Buzz or not. 2. Write a Java program to calculate factorial of 12. 3. Write a Java program for Fibonacci series. 4.
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 informationChapter 7: Iterations
Chapter 7: Iterations Objectives Students should Be able to use Java iterative constructs, including do-while, while, and for, as well as the nested version of those constructs correctly. Be able to design
More information/ Download the Khateeb Classes App
Q) Write a program to calculate the factorial of any given integer. import java.io.*; class Data public static void main(string[] args) throws IOException int i,n,f=1; String s = new String(); InputStreamReader
More informationUSING LIBRARY CLASSES
USING LIBRARY CLASSES Simple input, output. String, static variables and static methods, packages and import statements. Q. What is the difference between byte oriented IO and character oriented IO? How
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 informationCOE 212 Engineering Programming. Welcome to Exam II Thursday April 21, Instructors: Dr. Salim Haddad Dr. Joe Tekli Dr. Wissam F.
1 COE 212 Engineering Programming Welcome to Exam II Thursday April 21, 2016 Instructors: Dr. Salim Haddad Dr. Joe Tekli Dr. Wissam F. Fawaz Name: Student ID: Instructions: 1. This exam is Closed Book.
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Subject Code: 12176 Model Answer Page No: 1 / 33 Q. 1 A) 1) (1-mark each, any four) 1. Compile & Interpreted: Java is a two staged system. It combines both approaches. First java compiler translates source
More informationAn applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a
CBOP3203 An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled
More information/ Download the Khateeb Classes App
Q) Write a program to read and display the information about a book using the following relationship. Solution: import java.io.*; class Author String name,nationality,s; InputStreamReader r = new InputStreamReader(System.in);
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 informationICSE Solved Paper, 2018
ICSE Solved Paper, 2018 Class-X Computer Applications (Maximum Marks : 100) (Time allowed : Two Hours) Answers to this Paper must be written on the paper provided separately. You will not be allowed to
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 informationM105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014
M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014 Question One: Choose the correct answer and write it on the external answer booklet. 1. Java is. a. case
More informationDecisions: Logic Java Programming 2 Lesson 7
Decisions: Logic Java Programming 2 Lesson 7 In the Java 1 course we learned about if statements, which use booleans (true or false) to make decisions. In this lesson, we'll dig a little deeper and use
More informationTutorial 8 Date: 15/04/2014
Tutorial 8 Date: 15/04/2014 1. What is wrong with the following interface? public interface SomethingIsWrong void amethod(int avalue) System.out.println("Hi Mom"); 2. Fix the interface in Question 2. 3.
More informationjava programming - lotusdomino
NOTICE: The content of this document should contain java related topics. This is the java-lotusdomino document Table of contents 1 lotusdomino... 2 1.1 addressbooks.java... 2 1.2 aveddataagent.java...2
More informationMidterm assessment - MAKEUP Fall 2010
M257 MTA Faculty of Computer Studies Information Technology and Computing Date: /1/2011 Duration: 60 minutes 1-Version 1 M 257: Putting Java to Work Midterm assessment - MAKEUP Fall 2010 Student Name:
More informationSelected Sections of Applied Informatics LABORATORY 0
SSAI 2018Z: Class 1. Basics of Java programming. Page 1 of 6 Selected Sections of Applied Informatics LABORATORY 0 INTRODUCTION TO JAVA PROGRAMMING. BASIC LANGUAGE INSTRUCTIONS. CONSOLE APPLICATION. CONDITION,
More informationCMSC 331 Second Midterm Exam
1 20/ 2 80/ 331 First Midterm Exam 11 November 2003 3 20/ 4 40/ 5 10/ CMSC 331 Second Midterm Exam 6 15/ 7 15/ Name: Student ID#: 200/ You will have seventy-five (75) minutes to complete this closed book
More informationnavlakhi.com / navlakhi.education / navlakhi.mobi / navlakhi.org 1
Example 1 public class ex1 extends JApplet public void init() Container c=getcontentpane(); c.setlayout(new GridLayout(5,2)); JButton b1=new JButton("Add"); JButton b2=new JButton("Search"); JLabel l1=new
More informationJava Certification Mock Exam
Java Certification Mock Exam John Hunt Email: john.hunt@jttc.demon.co.uk URL: //www.jttc.demon.co.uk/cert.htm As with any examination technique is an important aspect of the examination process. In most
More informationName Section. CS 21a Introduction to Computing I 1 st Semester Final Exam
CS a Introduction to Computing I st Semester 00-00 Final Exam Write your name on each sheet. I. Multiple Choice. Encircle the letter of the best answer. ( points each) Answer questions and based on the
More informationEE219 - Semester /2009 Solutions Page 1 of 10
EE219 Object Oriented Programming I (2008/2009) SEMESTER 1 SOLUTIONS Q1(a) Corrected code is: 01 02 03 04 05 06 07 08 09 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
More informationSTRUKTUR PROGRAM JAVA: //Daftar paket yang digunakan dalam program import namapaket;
STRUKTUR PROGRAM JAVA: //Daftar paket yang digunakan dalam program import namapaket; //Membuat Kelas public class namakelas //Metode Utama public static void main(string[] args) perintah-perintah;... LATIHAN
More informationByte and Character Streams. Reading and Writing Console input and output
Byte and Character Streams Reading and Writing Console input and output 1 I/O basics The io package supports Java s basic I/O (input/output) Java does provide strong, flexible support for I/O as it relates
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 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 informationProgrammierpraktikum
Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 18 17/01/13 11:46 Java Applets 2 of 18 17/01/13 11:46 Java applets embedding Java applications
More informationObject Oriented Programming 2012/13. Final Exam June 27th, 2013
Object Oriented Programming 2012/13 Final Exam June 27th, 2013 Directions (read carefully): CLEARLY print your name and ID on every page. The exam contains 8 pages divided into 4 parts. Make sure you have
More informationGracefulness of TP-Tree with Five Levels Obtained by Java Programming
International Journal of Scientific and Research Publications, Volume 2, Issue 12, December 2012 1 Gracefulness of TP-Tree with Five Levels Obtained by Java Programming A.Solairaju 1, N. Abdul Ali 2 and
More informationCOMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette
COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.
More informationMYcsvtu Notes. Experiment-1. AIM: Write a program to implement fiestal cipher structure PROGRAM: import java.io.*; class functions
Experiment-1 AIM: Write a program to implement fiestal cipher structure PROGRAM: import java.io.*; class functions String Xor(String s1,string s2) char s1array[]=s1.tochararray(); char s2array[]=s2.tochararray();
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 informationFORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2011
TED (10)-3069 (REVISION-2010) Reg. No.. Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2011 OOP THROUGH JAVA (Common to CT, CM and IF) (Maximum marks: 100) [Time: 3
More informationJava Certification Model Question & Answer
Java Certification Model Question & Answer - 4 Java Certification, Programming, JavaBean and Object Oriented Reference Books Sun Certified Programmer for the Java2 Platform Mock Exam S:- Which of the following
More informationICSE 2015 COMPUTER APPLICATIONS. Md. Zeeshan Akhtar
ICSE 2015 COMPUTER APPLICATIONS Md. Zeeshan Akhtar COMPUTER APPLICATIONS Question 1 (a) (b) What are the default values of primitive data type int and float? Name any two OOP s principles. [2] [2] (c)
More informationK E Y I CYCLIC, EXAMINATION SECTION A
Question 1: (a) 0 to 65,535 SECTION A (b) Precision (i) float 6 digits (ii) double 15 digits (c) Attributes to declare a class Data members and Member functions (d) The two types of Java programs are 1.
More informationCONTENTS S.No Topic Page. No
CONTENTS S.No Topic Page. No 1. Syllabus 3 2. Required Work 5 3. Course Objectives 6 4. Course Outcomes 6 5. Course Assessment 7 6. Program Outcomes 8 7. Program Objective / Outcome Matrix 9 8. Programs
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 informationECM1406. Answer Sheet Lists
ECM1406 Answer Sheet Lists These questions are based on those found in Chapters 3 and 4 of the core text Data Structures Using Java by Malik and Nair. The source code for the ArrayListClass, UnorderedArrayList,
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 informationURL Kullanımı Get URL
Networking 1 URL Kullanımı Get URL URL info 2 import java.io.*; import java.net.*; public class GetURL { public static void main(string[] args) { InputStream in = null; OutputStream out = null; // Check
More informationTutorial about Arrays
Q1: Write Java statements that do the following: Reviewed Tutorial about Arrays a. Declare an array alpha of 15 components of the type int int alpha[] = new int[15]; b. Print the value of the tenth component
More informationXII Informatics Practices 2013 important questions with solution
XII Informatics Practices 2013 important questions with solution 1. Why do you use import statement in java programming? Explain with example. Ans. The import statement in Java allows programmers to refer
More informationORF 201 COMPUTER METHODS FOR PROBLEM SOLVING. Lecture 7 Searching. (C) Princeton University
ORF 201 COMPUTER METHODS FOR PROBLEM SOLVING Lecture 7 Searching (C) Princeton University Hints on Java Applets Edit /u/yourname/.login and set umask to 022. Copy /u/orf201/lab1/.rhosts to /u/yourname.
More informationChapter 5 Some useful classes
Chapter 5 Some useful classes Lesson page 5-1. Numerical wrapper classes Activity 5-1-1 Wrapper-class Integer Question 1. False. A new Integer can be created, but its contents cannot be changed. Question
More informationJohn Cowell. Essential Java Fast. How to write object oriented software for the Internet. with 64 figures. Jp Springer
John Cowell Essential Java Fast How to write object oriented software for the Internet with 64 figures Jp Springer Contents 1 WHY USE JAVA? 1 Introduction 1 What is Java? 2 Is this book for you? 2 What
More information1. Download the JDK 6, from
1. Install the JDK 1. Download the JDK 6, from http://java.sun.com/javase/downloads/widget/jdk6.jsp. 2. Once the file is completed downloaded, execute it and accept the license agreement. 3. Select the
More informationModule 5 Applets About Applets Hierarchy of Applet Life Cycle of an Applet
About Applets Module 5 Applets An applet is a little application. Prior to the World Wide Web, the built-in writing and drawing programs that came with Windows were sometimes called "applets." On the Web,
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 informationGetting Started in Java. Bill Pugh Dept. of Computer Science Univ. of Maryland, College Park
Getting Started in Java Bill Pugh Dept. of Computer Science Univ. of Maryland, College Park Hello, World In HelloWorld.java public class HelloWorld { public static void main(string [] args) { System.out.println(
More informationAscending. Load. Descending. Save. Exit. Numbers
1. Create an abstract class shape. Derive three classes sphere, cone and cylinder from it. Calculate area and volume of all (use method overriding) [30] 2. Design an HTML page containing 4 option buttons
More informationJApplet. toy example extends. class Point { // public int x; public int y; } p Point 5.2. Point. Point p; p = new Point(); instance,
35 5 JApplet toy example 5.1 2 extends class Point { // public int x; public int y; Point x y, 5.2 Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 36 5 Point p = new Point();
More informationSolved PAPER Computer Science-XII. Part -I. Answer all questions
ISC Solved PAPER 2017 Computer Science-XII Fully Solved (Question-Answer) Time : 3 hrs Max. Marks : 100 General Instructions 1. Answer all questions in Part I (compulsory) and seven questions from Part
More informationPROGRAM 2: GRID LINES import javax.swing.*; import java.awt.*; import java.awt.event.*;
PROGRAM 2: GRID LINES import javax.swing.*; import java.awt.*; import java.awt.event.*; class Design extends JFrame Container cp; Design() cp=getcontentpane(); cp.setlayout(null); Adapter ad=new Adapter(this);
More informationUNIT-2: CLASSES, INHERITANCE, EXCEPTIONS, APPLETS. To define a class, use the class keyword and the name of the class:
UNIT-2: CLASSES, INHERITANCE, EXCEPTIONS, APPLETS 1. Defining Classes, Class Name To define a class, use the class keyword and the name of the class: class MyClassName {... If this class is a subclass
More informationCOMPUTER APPLICATIONS
Percentage of Candidates COMPUTER APPLICATIONS STATISTICS AT A GLANCE Total Number of students who took the examination 99,856 Highest Marks Obtained 100 Lowest Marks Obtained 27 Mean Marks Obtained 83.28
More informationCHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA
1. JIT meaning a. java in time b. just in time c. join in time d. none of above CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA 2. After the compilation of the java source code, which file is created
More informationJava Programs. System.out.println("Dollar to rupee converion,enter dollar:");
Java Programs 1.)Write a program to convert rupees to dollar. 60 rupees=1 dollar. class Demo public static void main(string[] args) System.out.println("Dollar to rupee converion,enter dollar:"); int rs
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 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 informationSome Sample AP Computer Science A Questions - Solutions
Some Sample AP Computer Science A Questions - s Note: These aren't from actual AP tests. I've created these questions based on looking at actual AP tests. Also, in cases where it's not necessary to have
More informationChapter 10: Recursive Problem Solving
2400 COMPUTER PROGRAMMING FOR INTERNATIONAL ENGINEERS Chapter 0: Recursive Problem Solving Objectives Students should Be able to explain the concept of recursive definition Be able to use recursion in
More information