Java Practical No.20.pdf

  • Uploaded by: Meer Kukreja
  • 0
  • 0
  • June 2020
  • PDF

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


Overview

Download & View Java Practical No.20.pdf as PDF for free.

More details

  • Words: 168
  • Pages: 4
➢ Define a package named myInstitute include class named as department with one method to display the staff of that department. Develop a program to import this package in a java application and call the method defined in the package.

package myInstitute; public class department { public void display() { System.out.print("Name of Staff is \n 1. Rajesh \n 2. Ram \n 3. Ramesha \n 4. Rahul "); } } import myInstitute.*; class mydep { public static void main(String args[]) { department d=new department(); d.display(); } }

➢ Develop a program which consist of the package named let_me_calculate with a class named calculator and a method named add to add two integer number. Import let_me_calculate package in another program (class named Demo) to add two numbers.

package let_me_calculate; public class calculator { int x,y,z; public void add(int a,int b) { x=a; y=b; z=x+y; System.out.print("Addition of "+x+" and "+y+" : "+z); } }

import let_me_calculate.*; class demo { public static void main(String args[]) { calculator c=new calculator(); c.add(10,20); } }

Related Documents


More Documents from "Meer Kukreja"