Computer Applications
Write a program by using a class 'Picnic' without any data members but having only functions as per the specifications given below:
class name : Picnic
void display1( ): To print venue, place and reporting time.
void display2( ): To print number of students, name of the teacher accompanying and bus number.
Write a main class to create an object of the class 'Picnic' and call the functions display1() and display2( ) to enable the task.
Objects & Classes
483 Likes
Answer
class Picnic
{
public void display1() {
System.out.println("Venue: Botanical Garden");
System.out.println("Place: MG Road");
System.out.println("Reporting Time: 9:00 AM");
}
public void display2() {
System.out.println("Number of Students: 50");
System.out.println("Name of teacher: Mr. Nagabhushan");
System.out.println("Bus Number: KA 01 1234");
}
public static void main(String args[]) {
Picnic obj = new Picnic();
obj.display1();
obj.display2();
}
}
Answered By
311 Likes
Related Questions
Write a statement to create an object 'Keyboard' of the class 'Computer'.
Consider a real world object as 'Cricket Ball'. Now, mention two behaviours and methods each by taking the 'Cricket Ball' as a software Object.
Refer a class structure as shown below:
class MySchool { Name Address Principal's name AcceptData(); PrintData(); }With reference to the above class declaration, indicate whether the following statements are True/False:
- Acceptdata( ) is the characteristic of the class.
- Address is behaviour of the class.
- Acceptdata( ) and PrintData( ) are the common behaviour for the objects of class 'MySchool'.
- Behaviours is the medium of inter-object communication.
- Creating multiple objects of the class 'MySchool' is not possible.
You want to create a class 'Football'. Choose the elements to be used as characteristics and behavior from the list given below:
Ball, Goalkeeper, Making a goal, Defender, Forward player, passing ball, Referee, hitting corner, making fault