Question 1:
// Create an object of class Student
// Call 'print()' method of class Student
// Create an object of class School
// Call 'print()' method of class School
Student obj = new Student();
obj.print();
School obj_1 = new School();
obj_1.print();
Question 2:
// Create an object of class Printer
// Call 'print()' methods for desired output
Printer obj = new Printer();
obj.print("Hi! I am class STUDENT");
obj.print();
Question 3:
// Define a method named 'studentMethod()' in class Question
// Call the method named 'print()' in class Question
void studentMethod(){
Question23 obj = new Question23();
print(obj);
}
Question 4:
class Answer{
Answer(){
System.out.println("You got nothing.");
}
Answer(int marks, String type){
this();
System.out.print("You got "+marks+" for an "+type);
}
}
Question 5:
//Declare variable with name 'nptel', 'space' and 'java' and proper datatype.
//Initialize the variables with proper input
String nptel = "NPTEL", space = " ", java = "JAVA";
You didn't come up with Assignment 5 of C and C++
ReplyDelete