×
The question isn’t who is going to let me; it’s who is going to stop me.
--Your friends at LectureNotes
Close

Lab Manual for Java Programming - JAVA by JNTU Heroes

  • Java Programming - JAVA
  • Practical
  • Jawaharlal Nehru Technological University Anantapur (JNTU) College of Engineering (CEP), Pulivendula, Pulivendula, Andhra Pradesh, India - JNTUACEP
  • 2 Experiments
  • 1154 Views
  • 54 Offline Downloads
  • Uploaded 1 year ago
Jntu Heroes
Jntu Heroes
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

JAVA PROGRAMMING LAB 2011-2012 JAVA PROGRAMMING LABORATORY MANUAL 1

Text from page-2

JAVA PROGRAMMING LAB 2011-2012 PROGRAM 1 /* Write a Java Program to define a class, describe its constructor, overload the Constructors and instantiate its object */ import java.lang.*; class student { String name; int regno; int marks1,marks2,marks3; // null constructor student() { name="raju"; regno=12345; marks1=56; marks2=47; marks3=78; } // parameterized constructor student(String n,int r,int m1,int m2,int m3) { name=n; regno=r; marks1=m1; marks2=m2; marks3=m3; } // copy constructor student(student s) { name=s.name; regno=s.regno; marks1=s.marks1; marks2=s.marks2; marks3=s.marks3; } void display() { System.out.println(name + "\t" +regno+ "\t" +marks1+ "\t" +marks2+ "\t" + marks3); } } class studentdemo { public static void main(String arg[]) { student s1=new student(); 2

Text from page-3

JAVA PROGRAMMING LAB 2011-2012 student s2=new student("john",34266,58,96,84); student s3=new student(s1); s1.display(); s2.display(); s3.display(); } } ****************************OUTPUT************************************* c:\jdk1.6.0_26\bin>javac studentdemo.java c:\jdk1.6.0_26\bin>java studentdemo raju john raju 12345 56 34266 58 12345 56 47 96 47 78 84 78 3

Text from page-4

JAVA PROGRAMMING LAB 2011-2012 PROGRAM 2 /* Write a Java Program to define a class, define instance methods for setting and Retrieving values of instance variables and instantiate its object.*/ import java.lang.*; class emp { String name; int id; String address; void getdata(String name,int id,String address) { this.name=name; this.id=id; this.address=address; } void putdata() { System.out.println("Employee details are :"); System.out.println("Name :" +name); System.out.println("ID :" +id); System.out.println("Address :" +address); } } class empdemo { public static void main(String arg[]) { emp e=new emp(); e.getdata("smith",76859,"gulbarga"); e.putdata(); } } **************************************OUTPUT***************************** c:\jdk1.6.0_26\bin>javac empdemo.java c:\jdk1.6.0_26\bin>java empdemo Employee details are : Name :smith ID :76859 Address :Gulbarga 4

Lecture Notes