Computer Science, asked by sharanya1018, 3 months ago

Design a class Student with the following description
• Instance variables/data members:
String name, int roll no, int age, int class, intphno, String address.
• Methods:
Void input(): to take input for name, roll no, age, class, phno and address from user.
Void display (): to display all details of a student
Write a main ( ) method to create an object of the class and call the above methods. help me with this please ​

Answers

Answered by heyParam
6

Answer:

class Student

{

String name, address;

int  rollno, age, class, phno;

void input( )

{

Scanner sc = new Scanner(System.in);

name = sc.nextLine();

rollno = sc.nextInt();

age = sc.nextInt();

class = sc.nextInt();

phno = sc.nextInt();

address = sc.nextLine();

}​

void display( ){

System. out. println(name);

System. out. println(rollno);

System. out. println(age);

System. out. println(class);

System. out. println(phno);

System. out. println(address);

}

public static void main (String[] args)

{

Student ob = new Student();

ob.input();

ob.display();

}

}

Similar questions