Write a program to print the names of students by creating a Student class. If no name is passed while creating an object of Student class, then the name should be "Unknown", otherwise the name should be equal to the String value passed while creating object of Student class.
Answers
Answered by
0
Answer:
Explanation:i am very worried about this question please help me
Answered by
5
The following is the program code to print the names of the students-
class student
{
String ss;
String name;
public student(String ss)
{
name = ss;
}
public student()
{
name = "unknown";
}
}
public class Raju
{
public static void main(String[] args)
{
student obj = new student();
obj.ss = "Ashi";
//Student ss1 = new Student();
System.out.println(obj.ss);
System.out.println(obj.name);
}
}
#SPJ2
Similar questions
Art,
2 months ago
Computer Science,
2 months ago
Math,
2 months ago
Hindi,
6 months ago
History,
11 months ago
Computer Science,
11 months ago