Write the syntax for creating the class and object for the following
1)class name fruit object mango
2)class name school object student
3)class name vehicle object bus
4)class name flower object rose
5)class name animal object dog
PLEASE I REQUEST U TO GIVE CORRECT ANSWER
Answers
Answer:
galaxy is a huge collection of gas, dust, and billions of stars and their solar systems. A galaxy is held together by gravity. Our galaxy, the Milky Way, also has a supermassive black hole in the middle. ... This is the picture taken by the Hubble Space Telescope showing thousands of galaxies.
Objects are also termed as class tags or entities.
Question 8
Different objects of a class have common behaviour.
Answer the following questions
Question 1
Define Object with an example.
Answer
An object is an entity having a specific identity, specific characteristics and specific behavior. Taking a car as an example of an object, it has characteristics like colour, model, version, registration number, etc. It has behaviours like start the engine, stop the engine, accelerate the car, apply the brakes, etc.
Question 2
Mention five states (characteristics) and two methods for the following Classes:
(a) Class Employee
Answer
Characteristics Methods
Name computeSalary()
Employee Number computeTax()
Pan Number
Salary
Income Tax
(b) Class Bank
Answer
Characteristics Methods
Bank Name openAccount()
Bank Address depositMoney()
IFSC Code
MICR Code
Accounts
(c) Class School
Answer
Characteristics Methods
School Name admitStudent()
School Address conductExams()
Classes
Students
Teachers
(d) Class Book
Answer
Characteristics Methods
Book Name buyBook()
ISBN Number readBook()
Price
Author
Publisher
(e) Class Park
Answer
Characteristics Methods
Park Name openPark()
Park Address closePark()
Ticket Price
Opening Time
Closing Time
(f) Class Medicine
Answer
Characteristics Methods
Name buyMedicine()
Quantity sellMedicine()
Manufacturing Date
Expiry Date
Price
(g) Class Computer
Answer
Characteristics Methods
Model startComputer()
Serial Number shutdownComputer()
Processor
RAM
Hard Disk
(h) Class Camera
Answer
Characteristics Methods
Model takePicture()
Serial Number adjustZoom()
Colour
Price
Resolution
Question 3
What is an Object? Give five examples of real world objects.
Answer
An object is an entity having a specific identity, specific characteristics and specific behavior. Examples — car, bottle, mobile phone, computer, student.
Question 4
How will you define a software object?
Answer
A software object replaces the characteristics and behaviours of a real world object with data members and member methods, respectively.
Question 5
Class and Objects are inter-related. Explain.
Answer
A Class is used to create various Objects that have different characteristics and common behaviours. Each object follows all the features defined within a class. That is why class is also referred to as a blue print or prototype of an object. This way we can say that they are inter-related.
Question 6
A class is also referred as 'Object Factory'. Comment.
Answer
A class has the complete description of the data elements the object will contain, the methods the object can do, the way these data elements and methods can be accessed. A class can create objects of itself with different characteristics and common behaviour just like a factory can produce similar items based on a particular design. Hence, class is also referred to as 'Object Factory'.
Question 7
What does the following statement mean?
Employee staff = new Employee ( );
Answer
This statement creates a new object of class Employee. The newly created object is assigned to a variable named staff which is of Employee type. The object can be accessed using staff variable.
Question 8
Why is an Object called an 'Instance' of a class? Explain.
Answer
A class can create objects of itself with different characteristics and common behaviour. So, we can say that an Object represents a specific state of the class. For these reasons, an Object is called an Instance of a Class.
Question 9
Why is a class known as composite data type?
Answer
A class can contain data members of various primitive and reference data types. Hence, class is known as composite data type.
Question 10
Write a statement to create an object 'Keyboard' of the class 'Computer'.
Answer
Computer Keyboard = new Computer();
Question 11
Consider a real world object as 'Cricket Ball'. Now, mention two behaviours and methods each by taking the 'Cricket Ball' as a software Object.
Answer
Characteristics — Colour, Condition
Behaviours/Methods — throw(), stop()
Question 12
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.
False
Address is behaviour of the class.
False
Acceptdata( ) and PrintData( ) are the common behaviour of the objects of class 'MySchool'.
True
Behaviours are the medium of inter-object communication.
True
Creating multiple objects of class 'MySchool' is not possible.
False
Question 13
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
but having only functions as