Computer Science, asked by srinadh7429, 6 months ago

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 haseebrazzaq2001
0

Answer:

Explanation:i am very worried about this question please help me

Answered by sourasghotekar123
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