You can get 50 if you can solve it.
In java programming, Write a class specifier (along with its constructor) that creates a class 'student' having two private data members: roll no and grade and two public functions init() and display().
(Do not write full definitions of member functions except for constructor).
Answers
Answered by
21
Answer:
import java.io.*;
import java.util.*;
class student{
private int rollno,grade;
public student(){
}
public void init(){
Scanner sc = new Scanner(System.in);
System.out.println("Enter Student Roll number");
rollno = sc.nextInt();
System.out.println("Enter Student's grade");
grade = sc.nextInt();
}
public void display(){
System.out.println("Roll number :"+rollno+"\nGrade : "+grade);
}
}
public class Main{
public static void main(String args[]){
student st = new student();
st.init();
st.display();
}
}
Similar questions