1. I/P two matrix & multiplication in third matrix (MatrixMul.

java) Solution://""""""""""""""""""""""""""Practical No :- 1 """"""""""""""""""""""""" //Object:- I/P two matrix & multiplication in third matrix import java.io.*; class MatrixMul { static int r[]=new int[2]; static int c[]=new int[2]; int m1[][];//=new int[r[0]][c[0]]; int m2[][];//=new int[r[1]][c[1]]; int m3[][];//=new int[r[0]][c[1]]; MatrixMul(BufferedReader br) { for(int i=0;i<2;i++) { int sr=1; System.out.print("enter row and colmn for matrix"+sr); try { r[i]=Integer.parseInt(br.readLine()); c[i]=Integer.parseInt(br.readLine()); } catch(IOException e) {} sr++; } m1=new int[r[0]][c[0]]; m2=new int[r[1]][c[1]]; m3=new int[r[0]][c[1]]; } void InputMatrix(BufferedReader br) { System.out.print("enter first matrix"+r[0]+","+c[0]); for(int i=0;i<r[0];i++) { for(int j=0;j<c[0];j++) { try { m1[i][j]=Integer.parseInt(br.readLine()); } catch(IOException e) {}

out.k<c[0]. } .length.i<r[1].j<c[1].i<r[0]. } catch(IOException e) {} } } } void multiplication() { for(int i=0. } } } } void showmatrix( ) { for(int i=0.j++) { for(int k=0.i<m3.i++) { for(int j=0."+c[1]).j<c[1].out.j++) { try { m2[i][j]=Integer.k++) { m3[i][j]=m1[i][k]*m2[k][j]+m3[i][j].} } System.print(" "+m3[i][j]).j<m3[i].out.j++) { System.parseInt(br. for(int i=0.i++) { for(int j=0.length.i++) { for(int j=0. } System.print("enter second matrix"+r[1]+".println().readLine()).

showmatrix().21 1 1 1 enter second matrix2.emp contains additional features .multiplication(). matrix.address phone no .InputMatrix(br). matrix.in)).42 2 2 2 2 2 2 2 4444 4444 */ 2.} public static void main(String args[]) { BufferedReader br. } } /* output:E:\sourabh\java program>javac MatrixMul. MatrixMul matrix=new MatrixMul(br). br=new BufferedReader(new InputStreamReader(System.A person class contains its name . matrix. Drive a person class &inherit employee & student classes from it .java E:\sourabh\java program>java MatrixMul enter row and colmn for matrix12 2 enter row and colmn for matrix12 4 enter first matrix2.

branch= JOptionPane.out.showInputDialog(null. } } class Student extends Person { Student() { //constructor } String roll_no. salary & student contains roll no.sem."BRANCH").showInputDialog(null.showInputDialog(null.A person class contains its name .").information also ."COLLEGE NAME").emp contains additional features like emp id .showInputDialog(null.out. branch .out.").phone_no.information also .(Person.address.*."PHONE NO.address phone no .showInputDialog(null.college_name.define getter setter method in class . void inputstu() { roll_no= JOptionPane.define getter setter method in class . } ."SEMISTER").like emp id .java)*/ import javax. System. salary & student contains roll no.swing.branch."ROLL NO.print("\n PHONE N :"+phone_no).*Drive a person class &inherit employee & student classes from it .java) Solution: //""""""""""""""""""""""""practical no 2"""""""""""""""" /* OBject:.sem . sem= JOptionPane. } void show() { System. phone_no=JOptionPane. class PersonClass { String name.showInputDialog(null. System. PersonClass() { } void input() { name=JOptionPane.print("\n NAME :"+name).(Person."NAME"). address=JOptionPane.print("\n ADDRESS :"+address). branch . college_name= JOptionPane.showInputDialog(null.sem ."ADDRESS").

show(). Employee e1=new Employee().out.input()."SALARY"). } } class Employee extends Person { String e_id. s1."COMPANY NAME").Salary.print("\n COLLEGE NAME :"+college_name). } } class Person_info { public static void main(String args[]) { Student s1=new Student().showstu().showInputDialog(null. System.out.print("\n SALARY :"+Salary). company_name= JOptionPane.out. System. s1.out. e1.void showstu() { System.print("\n SEMESTER :"+sem).print("\n EMPLOYEE ID :"+e_id).out.company_name. System.print("\n ROLL NO :"+roll_no). s1.print("\n BRANCH :"+branch). Employee() { //constructor } void inputemp() { e_id= JOptionPane. Salary= JOptionPane. s1.print("\n COMPANY NAME :"+company_name). } void showemp() { System. . System."EMPLOYEE ID").showInputDialog(null. System.input().showInputDialog(null.out.out.inputstu().

} } class Scooter implements Vehicle { public void drive() { System.out. void start(). } public void start() { System.showemp().inputemp().out. e1. Solution:interface Vehicle { void drive(). e1.println("start a car").show().println("driving a car").println("start a scooter").out.out. } } 3.println("driving a scooter"). } . } class Car implements Vehicle { public void drive() { System.start().out. } public void stop() { System.e1.stop() and in bike and scooter classes with additional features . } public void start() { System. } public void stop() { System. void stop().out. Declare a vehical interface that contain abstract method like drive().println("stop a car").println("stop a scooter").

stop(). Develop a program to i/p and print following format also handle expression if raised in program (StringFormat. v. v.stop().out.java) INDIA .println("driving a bike"). b.start().} class Bike implements Vehicle { public void drive() { System.stop(). Bike b=new Bike(). b.drive().println("stop a bike").start(). v=b.println("start a bike"). b. s. v=s. } } 4. } } class Implements { public static void main(String args[]) { Vehicle v. Scooter s=new Scooter(). } public void start() { System. v=c.out. s. v. Car c=new Car(). s.drive().drive().start().out. } public void stop() { System.

fout=new FileOutputStream(args[1]).INDI IND IN I Solution://''''''''''''''''practical 4''''''''''' /*object:-4.i--) System.io.*. class CopiesFile { public static void main(String[] args) { FileInputStream fin=null.i)). FileOutputStream fout=null.and copy the contents of sourse file into target file . .write(fin.println(s. develop an application that take 2 file name frome cmd line arg. do { fout.java) solution:import java. } catch(Exception e) {} } } 5.substring(0. Develop a program to i/p and print following format also handle expression if raised in program INDIA INDI IND IN I */ class StringFormat { public static void main(String args[]) { String s="india". try { for(int i=5.i<=5.out.read()).( CopiesFile. try { fin=new FileInputStream(args[0]).

7.225. int y[]={325. fin. } public void paint(Graphics g) { g.385. public class Car1 extends Applet { int x[]={45. import java.275.setColor(Color.y[10]. . g.318.307. g. g.println("file copied successfully").*.20).45.drawOval(x[11].240. g.392.blue).378.awt.available()>0).190.white).225.140.173.307}. g.close(). } } } 6.white).*.setColor(Color.20.close().318.307.175.black). Then executes two method concurrently. fout.50.out.325.fillOval(x[10].80.158. Solution:/*<applet code="CarApp.print(""+e).50).485.158.black).applet. develop a thread based app. g.setColor(Color.240.fillOval(x[12].50.}while(fin.out.175. g.design an applet to draw a car object and move it horizontly. System.307.class" width=800 height=800></applet> */import java.378}.setColor(Color.setColor(Color.350. public void init() { setBackground(Color.y[12].50).black).y[11]. } catch(Exception e) { System.485.

g.drawOval(x[9].fillArc(x[14]. g.y[14].red). g.20.setColor(Color.setColor(Color.y[9]. } } .black).50.50.0.50.9). g.180).180).0. try{ Thread.sleep(200).fillPolygon(x.fillArc(x[13]. g.i++) x[i]=x[i]+2.50.y. } catch(Exception e) {} repaint().20). g.y[13].length. for(int i=0.i<x.