INDEX SL.NO NAME OF PROGRAMS PAGE NO REMARKS PROGRAM TO FIND FACTORIAL OF THREE

Size: px
Start display at page:

Download "INDEX SL.NO NAME OF PROGRAMS PAGE NO REMARKS PROGRAM TO FIND FACTORIAL OF THREE"

Transcription

1 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 NUMBERS 5 PROGRAM ON CONSOLE INPUT AND OUTPUT PROGRAM TO PRINT MULTIPLICATION 6 TABLE USING NESTED DO WHILE STATEMENT PROGRAM TO FIND LARGEST OF THREE 7 NUMBERS USING NESTING OF IF ELSE STATEMENT PROGRAM TO FIND AREA OF A ROOM USING 8 METHOD OVERLOADING PROGRAM TO FIND AREA AND VOLUME OF 9 A ROOM USING SINGLE INHERITANCE PROGRAM TO OBTAIN MARKS OF A 10 STUDENT IN DIFFERENT FIELDS USING INTERFACE 11 PROGRAM ON OVERRIDING METHODS 12 PROGRAM ON CONSTRUCTORS PROGRAM FOR CREATING OBJECTS AND 13 ACCESSING MEMBERS 14 PROGRAM FOR STATIC MEMBERS 15 NUMBER SORTING USING ARRAY PROGRAM ON MULTITHREADING WHICH 16 SHOWES 5,7 AND 13 TABLE 17 PROGRAM ON EXCEPTION HANDLING PROGRAM FOR DRAWING HUMAN FACE USING GRAPHICS PROGRAM TO OBTAIN SUM OF TWO NUMBERS USING APPLET PROGRAM TO SHOW CROSS LINES USING GRAPHICS APPLET

2 1) PROGRAM TO FIND FACTORIAL OF THREE NUMBERS. public class Factorial int fact(int n) if (n<=1) return 1; else return(n * fact(n-1)); public static void main (String arg[]) int fa,fb,fc; int a=4,b=5,c=6; Factorial f; f= new Factorial(); fa= f.fact(a); fb=f.fact(b); fc=f.fact(c); System.out.println("Factorial of " + a+ " is " +fa); System.out.println("Factorial of " + b+ " is " +fb); System.out.println("Factorial of " + c+ " is " +fc); Out put Factorial of 4 is 24 Factorial of 5 is 120 Factorial of 6 is 720

3 2) PROGRAM FOR SUM OF SERIES USING MATH POWER METHOD. public class Sum public static void main (String arg[]) int n=10; int i=0; int sum=0; int x=2; while(i<n) sum += Math.pow(x,i); i++; System.out.println( "Sum of the series 1 + X+X^2+X^3+...="+sum); Output Sum of the series 1 + X+X^2+X^3+...=1023

4 3) PROGRAM ON COMMAND LINE ARGUMENT. class Comline public static void main(string args[]) int count, i=0; String string; count= args.length; System.out.println(" Number of arguments = " + count); while(i<count) string = args[i]; i=i+1; System.out.println(i+ " : " + " java is " + string + "!"); Out put C:\J2SDK1~1.0\bin>javac Comline.java C:\J2SDK1~1.0\bin>java Comline Simple Robust secure Portable Number of arguments = 4 1 : java is Simple! 2 : java is Robust! 3 : java is secure! 4 : java is Portable!

5 4) PROGRAM TO PRINT THE FIBONACI SERIES. import java.io.*; public class Fibo /** Prompt user for a value of n, then print n Fibonacci numbers */ public static void main(string[] args) throws IOException BufferedReader rd = new BufferedReader (new InputStreamReader(System.in)); System.out.print("Enter value of n: "); String ns = rd.readline(); int n = Integer.parseInt(ns); int p = 0, c = 1, a; while (n-- > 0) System.out.println(c); a = p + c; p = c; c = a; Out put Enter value of n:

6 5) PROGRAM ON CONSOLE INPUT AND OUTPUT import java.io.*; public class Helloi public static void main(string[] args) throws IOException String name; BufferedReader kb = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Please enter your name: "); name = kb.readline(); System.out.println("Hello " + name + "!"); System.out.println("Well come to the world of JAVA!"); System.exit(0); Out put Please enter your name: Shivani Hello Shivani! Well come to the world of JAVA

7 6) PROGRAM TO PRINT MULTIPLICATION TABLE USING NESTED DO WHILE STATEMENT class DowhileTest public static void main(string args[]) int row,column,y; System.out.println("Multiplication table\n"); row=1; do column=1; do y=row*column; System.out.print(""+y); column= column+1; while(column<=3); System.out.println("\n"); row=row+1; while(row<=3); Output Multiplication table

8 7) PROGRAM TO FIND LARGEST OF THREE NUMBERS USING NESTING OF IF ELSE STATEMENT class IfElseNesting public static void main(string args[]) int a=325,b=712,c=478; System.out.print("Largest value is :"); if(a>b) if (a>c) System.out.print(a); else System.out.print(c); else if(c>b) System.out.print(c); else System.out.print(b); Out put Largest value is: 712

9 8) PROGRAM TO FIND AREA OF A ROOM USING METHOD OVERLOADING class Room float length, breadth; Room(float x, float y) length=x; breadth=y; Room(float x) length=breadth=x; float area() return( length * breadth); class moverload public static void main(string args[]) Room room1= new Room(25.0f,15.0f); float roomarea=room1.area(); System.out.println("RoomArea = " +roomarea); Output Room Area = 375.0

10 9) PROGRAM TO FIND AREA AND VOLUME OF A ROOM USING SINGLE INHERITANCE class Room int length,breadth; Room(int x, int y) length=x; breadth=y; int area() return( length * breadth); class BedRoom extends Room int height; BedRoom(int x, int y, int z) super(x,y); height=z; int volume() return(length *breadth * height); class SingleInher public static void main(string args[]) BedRoom room1= new BedRoom(14,12,10); int area1 = room1.area(); int volume1= room1.volume(); System.out.println("Area1 = " +area1);

11 System.out.println("Volume1= " +volume1); Output Area1 = 168 Volume1= 1680

12 10) PROGRAM TO OBTAIN MARKS OF A STUDENT IN DIFFERENT FIELDS USING INTERFACE class Student int rollnumber; void getnumber(int n) rollnumber=n; void putnumber() System.out.println(" Roll No :" + rollnumber); class Test extends Student float part1,part2; void getmarks(float m1, float m2) part1=m1; part2=m2; void putmarks() System.out.println("Marks obtained"); System.out.println("part1=" + part1); System.out.println("part2=" + part2); interface Sports float sportwt = 6.0F; void putwt();

13 class Results extends Test implements Sports float total; public void putwt() System.out.println("Sports Wt= " +sportwt); void display() total=part1+part2+sportwt; putnumber(); putmarks(); putwt(); System.out.println("Total score = " + total); class Hybrid public static void main(string args[]) Results student1 = new Results(); student1.getnumber(1234); student1.getmarks(27.5f, 33.0F); student1.display(); Output Roll No :1234 Marks obtained part1=27.5 part2=33.0 Sports Wt= 6.0 Total score = 66.5

14 11) PROGRAM ON OVERRIDING METHODS class Super int x; Super(int x) this.x=x; void display() System.out.println("Super X = " +x); class Sub extends Super int y; Sub(int x, int y) super(x); this.y=y; void display() System.out.println("Super X = " +x); System.out.println("Super Y = " +y); class OverrideTest public static void main(string args[]) Sub s1= new Sub(100,200); s1.display(); Out Put Super X = 100 Super Y = 200

15 12 PROGRAM ON CONSTRUCTORS class Rectangle int length,width; Rectangle(int x, int y) length=x; width=y; int rectarea() return( length*width); class RectangleArea public static void main(string args[]) Rectangle rect1=new Rectangle(15,10); int area1=rect1.rectarea(); System.out.println("Area1 = " +area1); Output Area1 = 150

16 13) PROGRAM FOR CREATING OBJECTS AND ACCESSING MEMBERS class Rectangle int length,width; void getdata(int x, int y) length=x; width=y; int rectarea() int area= length*width; return(area); class RectArea public static void main(string args[]) int area1,area2; Rectangle rect1=new Rectangle(); Rectangle rect2= new Rectangle(); rect1.length=15; rect1.width=10; area1=rect1.length*rect1.width; rect2.getdata(20,12); area2=rect2.rectarea(); System.out.println("Area1 = " +area1); System.out.println("Area2 = " +area2); OutPut Area1 = 150 Area2 = 240

17 14) PROGRAM FOR STATIC MEMBERS class MathOperation static float multi (float x,float y) return x*y; static float divide (float x, float y) return x/y; class MathApplication public static void main(string args[]) float a =MathOperation.multi(4.0f, 5.0f); float b = MathOperation.divide(a, 2.0f); System.out.println("b= " +b); Output b= 10.0

18 15) PROGRAM FOR NUMBER RSORTING USING ARRAY class NumberSorting public static void main(static void main(string args[]) int number[]=55,40,80,65,71; int n = number.length; System.out.println("Given List: ); for(int i=0;i<n;i++) System.out.print(" "+numbe[i]); System.out.println("\n"); for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) if(number[i]<number[j]) int temp=number[i]; number[i]=number[j]; number[j]=temp; System.out.println("Sorted List:"); for(int i=0;i<n;i++) System.out.println(" " + number[i]); System.out.println(" ");

19 OutPut Given List: Sorted List:

20 16) PROGRAM ON MULTITHREADING WHICH SHOWES 5,7 AND 13 TABLE class FiveTable extends Thread public void run() for(int i=1;i<=5;i++) System.out.println(i+ " Fives are " +(i*5)); class SevenTable extends Thread public void run() for(int i=1;i<=5;i++) System.out.println(i+ " Sevens are " +(i*7)); class ThirteenTable extends Thread public void run() for(int i=1;i<=5;i++) System.out.println(i+ " Thirteens are " +(i*13)); class MultiThreading public static void main(string args[]) FiveTable five; SevenTable seven; ThirteenTable thirteen; five= new FiveTable(); seven = new SevenTable(); thirteen = new ThirteenTable();

21 five.start(); seven.start(); thirteen.start(); Output 1 Fives are 5 1 Sevens are 7 1 Thirteens are 13 2 Fives are 10 2 Sevens are 14 2 Thirteens are 26 3 Fives are 15 3 Sevens are 21 3 Thirteens are 39 4 Fives are 20 4 Sevens are 28 4 Thirteens are 52 5 Fives are 25 5 Sevens are 35 5 Thirteens are 65

22 17) PROGRAM ON EXCEPTION HANDLING class error public static void main (String args[]) int a[]=5,10; int b=5; try int x= a[2]/b-a[1]; catch(arithmeticexception e) System.out.println("Division by zero"); catch(arrayindexoutofboundsexception e) System.out.println("Array index error"); catch(arraystoreexception e) System.out.println("Wrong Data type"); int y=a[1]/a[0]; System.out.println("y="+y); Out put Array index error y=2

23 18) PROGRAM FOR DRAWING HUMAN FACE USING GRAPHICS import java.awt.*; import java.applet.*; /*<APPLET CODE=Face.class WIDTH=250 HEIGHT=200> </APPLET>*/ public class Face extends Applet public void paint(graphics g) g.drawoval(40,40,120,150); g.drawoval(57,75,30,20); g.drawoval(110,75,30,20); g.filloval(68,81,10,10); g.filloval(121,81,10,10); g.drawoval(85,100,30,30); g.fillarc(60,125,80,40,180,180); g.drawoval(25,92,15,30); g.drawoval(160,92,15,30); Output

24 19) PROGRAM TO OBTAIN SUM OF TWO NUMBERS USING APPLET import java.awt.*; import java.applet.*; /*<APPLET CODE=UserIn.class WIDTH=250 HEIGHT=200> </APPLET>*/ public class UserIn extends Applet TextField text1,text2; public void init() text1 = new TextField(8); text2 = new TextField(8); add(text1); add(text2); text1.settext("0"); text2.settext("0"); public void paint (Graphics g) int x=0, y=0,z=0; String s1,s2,s; g.drawstring("input a number in each box ",10,50); try s1 = text1.gettext(); x=integer.parseint(s1); s2=text2.gettext(); y=integer.parseint(s2); catch(exception ex) z=x+y; s= String.valueOf(z); g.drawstring(" THE SUM IS: ", 10,75); g.drawstring(s,100,75);

25 public boolean action( Event event, Object obj) repaint(); return true; OUT PUT

26 20) PROGRAM TO SHOW CROSS LINES USING GRAPHICS APPLET import java.applet.*; import java.awt.*; /*<APPLET CODE = "Crossed.class" WIDTH = 600 HEIGHT = 600> </APPLET>*/ public class Crossed extends Applet public boolean handleevent( Event e) if(e.id == Event.WINDOW_DESTROY) System.exit(0); return(super.handleevent(e)); public void paint(graphics g) for(int i=0;i<400;i+= 10) g.drawline(0,i,i,0); g.drawline(i,400,400,i); for(int j=0,k=400;j<400;j+= 10,k -=10) g.drawline(0,k,400,j); g.drawline(0,j,k,400);

27 Out put of Crossed lines

UNIT - V. Inheritance Interfaces and inner classes Exception handling Threads Streams and I/O

UNIT - V. Inheritance Interfaces and inner classes Exception handling Threads Streams and I/O UNIT - V Inheritance Interfaces and inner classes Exception handling Threads Streams and I/O 1 INHERITANCE 2 INHERITANCE What is Inheritance? Inheritance is the mechanism which allows a class B to inherit

More information

Practical 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: 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

B.Sc (Computer Science) Programming in Java Lab Programs

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 information

Prasanth Kumar K(Head-Dept of Computers)

Prasanth 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 information

/* Program that accepts a shopping list of five items from the command line and stores them in a vector */

/* Program that accepts a shopping list of five items from the command line and stores them in a vector */ /* Program that accepts a shopping list of five items from the command line and stores them in a vector */ import java.util.*; // load Vector class class ShoppingList public static void main(string args[

More information

d. If a is false and b is false then the output is "ELSE" Answer?

d. 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 information

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

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 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

Recursive Problem Solving

Recursive 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 information

Exp 6: Develop Java programs to implement Interfaces and Packages. Apply Exception handling and implement multithreaded programs.

Exp 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 information

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018 Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment

More information

AN IMPROTANT COLLECTION OF JAVA IO RELATED PROGRAMS

AN 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 information

Some Practice Midterm Problems

Some Practice Midterm Problems Some Practice Midterm Problems September 29, 2017 1. 1 point word count is a legal identifier in Java A. True B. False 2. 1 point k2 is a legal identifier in Java A. True B. False 3. 1 point Krazy1 is

More information

1)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? 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

MYcsvtu Notes. Java Programming Lab Manual

MYcsvtu 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 information

JAVA PROGRAM EXAMPLE WITH OUTPUT PDF

JAVA 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 information

AP COMPUTER SCIENCE A

AP COMPUTER SCIENCE A AP COMPUTER SCIENCE A CONTROL FLOW Aug 28 2017 Week 2 http://apcs.cold.rocks 1 More operators! not!= not equals to % remainder! Goes ahead of boolean!= is used just like == % is used just like / http://apcs.cold.rocks

More information

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade; Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The

More information

Assignment2013 Please use this document only for verifying if your programs are right. Do not blindly copy paste and waste your time.

Assignment2013 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 information

Chapter 7: Iterations

Chapter 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

Mobile Application Development ( IT 100 ) Assignment - I

Mobile Application Development ( IT 100 ) Assignment - I 1. a) Explain various control structures available in Java. (6M ) Various control structures available in Java language are: 1. if else 2. switch 3. while 4. do while 5. for 6. break 7. continue 8. return

More information

Tutorial 8 Date: 15/04/2014

Tutorial 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 information

Vidyalankar. T.Y. Diploma : Sem. V [CO/CM/IF] Java Programming Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 100

Vidyalankar. T.Y. Diploma : Sem. V [CO/CM/IF] Java Programming Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 100 T.Y. Diploma : Sem. V [CO/CM/IF] Java Programming Time : 3 Hrs.] Prelim Question Paper Solution [Marks : 100 1. (a) (i) FEATURES OF JAVA 1) Compiled and interpreted 2) Platform independent and portable

More information

Loops. CSE 114, Computer Science 1 Stony Brook University

Loops. 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 information

ICSE Class 10 Computer Applications ( Java ) 2012 Solved Question...

ICSE Class 10 Computer Applications ( Java ) 2012 Solved Question... 1 of 1 05-11-015 16: ICSE J Java for Class X Computer Applications ICSE Class 10 Computer Applications ( Java ) 01 Solved Question Paper COMPUTER APPLICATIONS (Theory) (Two Hours) Answers to this Paper

More information

Developed By Strawberry

Developed By Strawberry Experiment No. 8 PART A (PART A: TO BE REFFERED BY STUDENTS) A.1 Aim: To understand the below concept of Inheritance (Part II) P1: Consider the class hierarchy in the figure below. The class master derives

More information

CMSC 331 Second Midterm Exam

CMSC 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 information

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class. Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone

More information

Week 9. Abstract Classes

Week 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 information

1. Java is a... language. A. moderate typed B. strogly typed C. weakly typed D. none of these. Answer: B

1. Java is a... language. A. moderate typed B. strogly typed C. weakly typed D. none of these. Answer: B 1. Java is a... language. A. moderate typed B. strogly typed C. weakly typed D. none of these 2. How many primitive data types are there in Java? A. 5 B. 6 C. 7 D. 8 3. In Java byte, short, int and long

More information

1. Download the JDK 6, from

1. 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 information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

MAHARASHTRA 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 information

(2½ hours) Total Marks: 75

(2½ hours) Total Marks: 75 (2½ hours) Total Marks: 75 N. B.: (1) All questions are compulsory. (2) Makesuitable assumptions wherever necessary and state the assumptions mad (3) Answers to the same question must be written together.

More information

Program 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.*; Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*; /* */ public

More information

OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES. Inheritance

OBJECT ORIENTED PROGRAMMING AND DATA STRUCTURES. Inheritance Inheritance Definition : Inheritance is the process by which objects of one class acquired the properties of objects of another classes. Inheritance is a property by which the new classes are created using

More information

Chapter 10: Recursive Problem Solving

Chapter 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

F I N A L E X A M I N A T I O N

F I N A L E X A M I N A T I O N Faculty Of Computer Studies M257 Putting Java to Work F I N A L E X A M I N A T I O N Number of Exam Pages: (including this cover sheet( Spring 2011 April 4, 2011 ( 5 ) Time Allowed: ( 1.5 ) Hours Student

More information

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE PART A UNIT I 1. Differentiate object oriented programming from procedure oriented programming. 2. Define abstraction and encapsulation. 3. Differentiate

More information

e) Implicit and Explicit Type Conversion Pg 328 j) Types of errors Pg 371

e) 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 information

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION

CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1. Name SOLUTION CIS 1068 Program Design and Abstraction Spring2016 Midterm Exam 1 Name SOLUTION Page Points Score 2 15 3 8 4 18 5 10 6 7 7 7 8 14 9 11 10 10 Total 100 1 P age 1. Program Traces (41 points, 50 minutes)

More information

1. Find the output of following java program. class MainClass { public static void main (String arg[])

1. Find the output of following java program. class MainClass { public static void main (String arg[]) 1. Find the output of following java program. public static void main(string arg[]) int arr[][]=4,3,2,1; int i,j; for(i=1;i>-1;i--) for(j=1;j>-1;j--) System.out.print(arr[i][j]); 1234 The above java program

More information

Decisions: Logic Java Programming 2 Lesson 7

Decisions: 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 information

Java Applet Basics. Life cycle of an applet:

Java 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 information

CSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name

CSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name CSC 1051 Algorithms and Data Structures I Final Examination May 12, 2017 Name Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the spaces provided.

More information

Java for Interfaces and Networks (DT3010, HT11)

Java for Interfaces and Networks (DT3010, HT11) Java for Interfaces and Networks (DT3010, HT11) Introduction Federico Pecora School of Science and Technology Örebro University federico.pecora@oru.se Federico Pecora Java for Interfaces and Networks Lecture

More information

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char Review Primitive Data Types & Variables int, long float, double boolean char String Mathematical operators: + - * / % Comparison: < > = == 1 1.3 Conditionals and Loops Introduction to Programming in

More information

University of Palestine. Mid Exam Total Grade: 100

University of Palestine. Mid Exam Total Grade: 100 First Question No. of Branches (5) A) Choose the correct answer: 1. If we type: system.out.println( a ); in the main() method, what will be the result? int a=12; //in the global space... void f() { int

More information

Lara Technologies Special-Six Test

Lara Technologies Special-Six Test Flow control Part-1 Q: 01 Given: 10. public class Bar 11. static void foo( int... x ) 12. // insert code here 13. 14. Which two code fragments, inserted independently at line 12, will allow the class to

More information

Methods (Deitel chapter 6)

Methods (Deitel chapter 6) Methods (Deitel chapter 6) 1 Plan 2 Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods

More information

Methods (Deitel chapter 6)

Methods (Deitel chapter 6) 1 Plan 2 Methods (Deitel chapter ) Introduction Program Modules in Java Math-Class Methods Method Declarations Argument Promotion Java API Packages Random-Number Generation Scope of Declarations Methods

More information

Full file at Chapter 2 - Inheritance and Exception Handling

Full file at   Chapter 2 - Inheritance and Exception Handling Chapter 2 - Inheritance and Exception Handling TRUE/FALSE 1. The superclass inherits all its properties from the subclass. ANS: F PTS: 1 REF: 76 2. Private members of a superclass can be accessed by a

More information

UNIT -IV INHERITANCE, PACKAGES AND INTERFACES

UNIT -IV INHERITANCE, PACKAGES AND INTERFACES UNIT -IV INHERITANCE, PACKAGES AND INTERFACES TOPIC TO BE COVERED.. 4.1Basics of Inheritance: Types of inheritance concepts of method overriding, extending class, super class, subclass, dynamic method

More information

WINTER 12 EXAMINATION Subject Code : Model Answer Page No : 01/31

WINTER 12 EXAMINATION Subject Code : Model Answer Page No : 01/31 Subject Code : 12176 Model Answer Page No : 01/31 Q.1(a)i) (1-mark for each feature) OOP IS SIMPLE: Java is easy to write and understand. Java programmer doesn't have to work with pointers and doesn t

More information

B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA

B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE

More information

B.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 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 information

/ Download the Khateeb Classes App

/ 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 information

Special Exercise Unit: Introduction to Java

Special 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 information

Introduction to Java

Introduction to Java Introduction to Java Module 1: Getting started, Java Basics 22/01/2010 Prepared by Chris Panayiotou for EPL 233 1 Lab Objectives o Objective: Learn how to write, compile and execute HelloWorld.java Learn

More information

Recursion. 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 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 information

COMPUTER APPLICATIONS

COMPUTER APPLICATIONS COMPUTER APPLICATIONS (Theory) (Two hours) Answers to this Paper must be written on the paper provided separately. You will not be allowed to write during the first 15 minutes. This time is to be spent

More information

Tools : The Java Compiler. The Java Interpreter. The Java Debugger

Tools : The Java Compiler. The Java Interpreter. The Java Debugger Tools : The Java Compiler javac [ options ] filename.java... -depend: Causes recompilation of class files on which the source files given as command line arguments recursively depend. -O: Optimizes code,

More information

Java Applet & its life Cycle. By Iqtidar Ali

Java 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

Exercise 4: Loops, Arrays and Files

Exercise 4: Loops, Arrays and Files Exercise 4: Loops, Arrays and Files worth 24% of the final mark November 4, 2004 Instructions Submit your programs in a floppy disk. Deliver the disk to Michele Zito at the 12noon lecture on Tuesday November

More information

Road Map. Introduction to Java Applets Review applets that ship with JDK Make our own simple applets

Road Map. Introduction to Java Applets Review applets that ship with JDK Make our own simple applets Java Applets Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets Introduce inheritance Introduce the applet environment html needed for applets Reading:

More information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

Java for Interfaces and Networks (DT3029)

Java for Interfaces and Networks (DT3029) Java for Interfaces and Networks (DT3029) Lecture 1 Introduction and Basics Federico Pecora federico.pecora@oru.se Center for Applied Autonomous Sensor Systems (AASS) Örebro University, Sweden Image source:

More information

4. Finding & Displaying Record of Salesman with minimum net income. 5. Finding & Displaying Record of Salesman with maximum net income.

4. 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 information

Full download all chapters instantly please go to Solutions Manual, Test Bank site: testbanklive.com

Full download all chapters instantly please go to Solutions Manual, Test Bank site: testbanklive.com Introduction to Java Programming Comprehensive Version 10th Edition Liang Test Bank Full Download: http://testbanklive.com/download/introduction-to-java-programming-comprehensive-version-10th-edition-liang-tes

More information

Course overview: Introduction to programming concepts

Course overview: Introduction to programming concepts Course overview: Introduction to programming concepts What is a program? The Java programming language First steps in programming Program statements and data Designing programs. This part will give an

More information

CSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name: KEY. Question Value Score

CSC 1051 Algorithms and Data Structures I. Final Examination May 12, Name: KEY. Question Value Score CSC 1051 Algorithms and Data Structures I Final Examination May 12, 2017 Name: KEY Question Value Score 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 10 10 10 TOTAL 100 Please answer questions in the spaces

More information

CSE 114 Computer Science I

CSE 114 Computer Science I CSE 114 Computer Science I Iteration Cape Breton, Nova Scotia What is Iteration? Repeating a set of instructions a specified number of times or until a specific result is achieved How do we repeat steps?

More information

Third Year Diploma Courses in Computer Science & Engineering, Computer Engineering, Computer Technology & Information Technology Branch.

Third Year Diploma Courses in Computer Science & Engineering, Computer Engineering, Computer Technology & Information Technology Branch. Third Year Diploma Courses in Computer Science & Engineering, Computer Engineering, Computer Technology & Information Technology Branch. Java Programming Specific Objectives: Contents: As per MSBTE G Scheme

More information

PART A. input as command line argument. 1. Write a program to find factorial of list of number reading

PART A. input as command line argument. 1. Write a program to find factorial of list of number reading PART A 1. Write a program to find factorial of list of number reading input as command line argument class factorial public static void main(string args[]) int[]arr=new int[10]; int fact; if(args.length==0)

More information

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application Last Time v We created our first Java application v What are the components of a basic Java application? v What GUI component did we use in the examples? v How do we write to the standard output? v An

More information

Getting 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 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 information

Prashanth Kumar K(Head-Dept of Computers)

Prashanth Kumar K(Head-Dept of Computers) B.Sc (Computer Science) Object Oriented Programming with Java and Data Structures Unit-IV 1 1. What is Thread? Thread is a task or flow of execution that can be made to run using time-sharing principle.

More information

UNIT - II Object Oriented Programming - Inheritance

UNIT - II Object Oriented Programming - Inheritance UNIT - II Object Oriented Programming - Inheritance Topics to be Covered: 1. Inheritance 2. Class Hierarchy 3. Polymorphism 4. Dynamic Binding 5. Final Keyword 6. Abstract Classes 7. Object Class 8. Reflection

More information

CSIS 10A Practice Final Exam Solutions

CSIS 10A Practice Final Exam Solutions CSIS 10A Practice Final Exam Solutions 1) (5 points) What would be the output when the following code block executes? int a=3, b=8, c=2; if (a < b && b < c) b = b + 2; if ( b > 5 a < 3) a = a 1; if ( c!=

More information

EE219 - Semester /2009 Solutions Page 1 of 10

EE219 - 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 information

15CS45 : OBJECT ORIENTED CONCEPTS

15CS45 : OBJECT ORIENTED CONCEPTS 15CS45 : OBJECT ORIENTED CONCEPTS QUESTION BANK: What do you know about Java? What are the supported platforms by Java Programming Language? List any five features of Java? Why is Java Architectural Neutral?

More information

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003 1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to

More information

6 COMPUTER PROGRAMMING

6 COMPUTER PROGRAMMING 6 COMPUTER PROGRAMMING ITERATION STATEMENT CONTENTS WHILE DO~WHILE FOR statement 2 Iteration Statement provides While / do-while / For statements for supporting an iteration logic function that the logic

More information

Recitation: Loop Jul 7, 2008

Recitation: 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 information

A sample print out is: is is -11 key entered was: w

A 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 information

CORBA Java. Java. Java. . Java CORBA. Java CORBA (RMI) CORBA ORB. . CORBA. CORBA Java

CORBA 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 information

1. What is the difference between a compiler and an interpreter? Also, discuss Java s method.

1. What is the difference between a compiler and an interpreter? Also, discuss Java s method. Name: Write all of your responses on these exam pages. 1 Short Answer (5 Points Each) 1. What is the difference between a compiler and an interpreter? Also, discuss Java s method. 2. Java is a platform-independent

More information

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)

CS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question) CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 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

AP CS Unit 8: Inheritance Exercises

AP CS Unit 8: Inheritance Exercises AP CS Unit 8: Inheritance Exercises public class Animal{ System.out.print("A"); public void m2(){ System.out.print("B"); public class Dog extends Animal{ System.out.print("C"); public void m3(){ System.out.print("D");

More information

package import public class public static void int out new for break else out else out

package 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 information

The Java programming environment. The Java programming environment. Java: A tiny intro. Java features

The Java programming environment. The Java programming environment. Java: A tiny intro. Java features The Java programming environment Cleaned up version of C++: no header files, macros, pointers and references, unions, structures, operator overloading, virtual base classes, templates, etc. Object-orientation:

More information

CLASSES AND OBJECTS. BASIC PRINCIPLES OF OOP 1. Data Encapsulation 2. Data Hiding 3. Inheritance 4. Polymorphism DEFINING A CLASS

CLASSES AND OBJECTS. BASIC PRINCIPLES OF OOP 1. Data Encapsulation 2. Data Hiding 3. Inheritance 4. Polymorphism DEFINING A CLASS CLASSES AND OBJECTS 1 BASIC PRINCIPLES OF OOP 1. Data Encapsulation 2. Data Hiding 3. Inheritance 4. Polymorphism DEFINING A CLASS class classname [variable declaration;] [methods declaration;] class classname

More information

Chapter 3. Selections

Chapter 3. Selections Chapter 3 Selections 1 Outline 1. Flow of Control 2. Conditional Statements 3. The if Statement 4. The if-else Statement 5. The Conditional operator 6. The Switch Statement 7. Useful Hints 2 1. Flow of

More information

WOSO Source Code (Java)

WOSO Source Code (Java) WOSO 2017 - Source Code (Java) Q 1 - Which of the following is false about String? A. String is immutable. B. String can be created using new operator. C. String is a primary data type. D. None of the

More information

CT 229 Arrays in Java

CT 229 Arrays in Java CT 229 Arrays in Java 27/10/2006 CT229 Next Weeks Lecture Cancelled Lectures on Friday 3 rd of Nov Cancelled Lab and Tutorials go ahead as normal Lectures will resume on Friday the 10 th of Nov 27/10/2006

More information

S.E. Sem. III [CMPN] Object Oriented Programming Methodology

S.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 information

COMPUTER SCIENCE PAPER 1

COMPUTER SCIENCE PAPER 1 COMPUTER SCIENCE PAPER 1 (THEORY) (Maximum Marks: 70) (Time allowed: Three hours) (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time.)

More information

AP CS Unit 3: Control Structures Notes

AP CS Unit 3: Control Structures Notes AP CS Unit 3: Control Structures Notes The if and if-else Statements. These statements are called control statements because they control whether a particular block of code is executed or not. Some texts

More information

Exception class Hierarchy

Exception class Hierarchy EXCEPTIONS IN JAVA What s Exception An exception is an abnormal condition that occurs at run time. For example divide by 0. During execution of a statement within any method if any exceptional condition

More information

1.Which four options describe the correct default values for array elements of the types indicated?

1.Which four options describe the correct default values for array elements of the types indicated? 1.Which four options describe the correct default values for array elements of the types indicated? 1. int -> 0 2. String -> "null" 3. Dog -> null 4. char -> '\u0000' 5. float -> 0.0f 6. boolean -> true

More information

CS Computers & Programming I Review_01 Dr. H. Assadipour

CS Computers & Programming I Review_01 Dr. H. Assadipour CS 101 - Computers & Programming I Review_01 Dr. H. Assadipour 1. What is the output of this program? public class Q_01 public static void main(string [] args) int x=8; int y=5; double z=12; System.out.println(y/x);

More information

Java - Applets. public class Buttons extends Applet implements ActionListener

Java - 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 information