write a java statement to create an object study of class student
Answers
Answered by
2
class Student {
private String name;
public Student(){
name = "Unknown";
}
public void setName (String n){
name = n;
}
public String getName(){
return name;
}
}
class Cl1{
public static void main(String[] args){
Student a = new Student();
System.out.println(a.getName());
a.setName("xyz");
String b = a.getName();
System.out.println(b);
}
}
Similar questions
English,
2 months ago
English,
2 months ago
Math,
5 months ago
Political Science,
11 months ago
English,
11 months ago