Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Class Comparison 2-Java Network Programming-Lab Manual, Exercises of Java Programming

This lab manual is designed by Sarah Jane at Indraprastha Institute of Information Technology for subject Java Network Programming. It includes Attributes, String, Method, Instances, Enhance, Display, Circle, Program, Prints

Typology: Exercises

2011/2012

Uploaded on 07/03/2012

netu
netu 🇮🇳

4.5

(4)

55 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1. Create a class Student with following attributes
i. String name;
ii. int rollno;
iii. int age;
iv. String address;
v. String email;
b. Make these attributes public by writing keyword “public” before them
c. Write main method
d. Create two instances of Student class as
Student std1=new Student();
Student std2=new Student();
e. Initialize the data members of std1 students as
std1.name=”Jhone”;
std1.rollno=911;
std1.age=
std1.address=”Street 123 Block 4 City X Country Y”;
std1.email=someone@someserver.com;
Initialize the data members of std2 in the same way
f. Try printing these values;
2. Write code to compare the two students and print the name of the elder student
3. Enhance Student class and add the following method
public void bioData(){
System.out.println(“Name = “+name);
System.out.println(“Roll no = “+rollno);
System.out.println(“Age = “+age);
System.out.println(“Address = “+address);
}
4. Display the bio data of two students by calling the function bioData()
5. Enhance student class and add a function showMarks() that will print the marks obtained
in various subject
6. Write a class Circle define attributes and add the following methods
a. showRadius() //displays the radius of the circle
b. showArea() //displays area of the circle
c. showCenter() //displays x and y co-ordinates of the center of the circle
7. Write a program that
a. creates three circles
b. initializes them with suitable values
c. prints them in ascending order according to their areas.
Java Programming Day-01
Lab-session-02
Docsity.com

Partial preview of the text

Download Class Comparison 2-Java Network Programming-Lab Manual and more Exercises Java Programming in PDF only on Docsity!

  1. Create a class Student with following attributes i. String name; ii. int rollno; iii. int age; iv. String address; v. String email; b. Make these attributes public by writing keyword “ public” before them c. Write main method d. Create two instances of Student class as Student std1=new Student(); Student std2=new Student(); e. Initialize the data members of std1 students as std1.name=”Jhone”; std1.rollno=911; std1.age= std1.address=”Street 123 Block 4 City X Country Y”; std1.email=someone@someserver.com; Initialize the data members of std2 in the same way f. Try printing these values;
  2. Write code to compare the two students and print the name of the elder student
  3. Enhance Student class and add the following method public void bioData(){ System.out.println(“Name = “+name); System.out.println(“Roll no = “+rollno); System.out.println(“Age = “+age); System.out.println(“Address = “+address); }
  4. Display the bio data of two students by calling the function bioData()
  5. Enhance student class and add a function showMarks() that will print the marks obtained in various subject
  6. Write a class Circle define attributes and add the following methods a. showRadius() //displays the radius of the circle b. showArea() //displays area of the circle c. showCenter() //displays x and y co-ordinates of the center of the circle
  7. Write a program that a. creates three circles b. initializes them with suitable values c. prints them in ascending order according to their areas.

Java Programming Day- 01

Lab-session- 02

Docsity.com