Create a Student class and initialize it with name and roll number. Create methods
i) Display - It should display all information of the student.
ii) setAge - It should assign age to student
iii) setMarks - It should assign marks to the student.
Write the main program to access these methods.
Answers
Answered by
1
public class Student{
private string name{ get; set; }
private string Age{get ; set;}
public void Display(){
Console.WriteLine(+name+" "+Age);
}
public void SetAge(int age){
Age=age;
}
public void SetName(string name){
Name=name;
}
}
static class Main(){
Student student=new Student();
student. SetAge(20);
student. SetName("John");
student.Display();
}
Answered by
8
Answer:
class Student():
def __init__(self,name,roll):
print ("self.name")
print ("self.roll")
def display(self):
print ("self.name")
print ("self.roll")
def setAge(self,age):
print ("self.age")
def setMarks(self,marks):
print ("self.marks")
Explanation:
Similar questions