Professional Documents
Culture Documents
A class serves as an object's template. Object behavior is also described by a class. A member or
"instance" of a class is an object.
Every property of an object has a state in which those values are either explicitly declared by
you or are determined by default settings.
2. Consider the scenario of buying flowers from a florist. Outline the objects in such a
transaction together with the messages exchanged.
Answer:
Maria as an object
attributes:
name = Maria
address = gundaway
budget = 400
methods:
purchase () {
Flourist.takeOrder ( “maria”, “roses”, “gundaway”, “19 june”)
}
getBudget () { return budget}
Flourist
attributes:
name = flourist
methods:
takeOrder ( who, stock, address, date ) {
check with flower shop on stock availability
check with flower shop delivery schedule
if ok then {
instinct flower shop to deliver stock to address on date
return ok
} else return not ok
}
3. Given a class definition Rectangle below, describe the structure of any 3 instances of
Rectangle.
Answer:
Class Rectangle {
Attributes:
Length
Width
Methods:
getLength() { return length }
getWidth() { return wirth }
draw() { … }
}
With your own inbuilt variables directly dumping into the program. That means a user is
required to submit the input values.
4. How would you implement the concept of class and method in a non-object-oriented
programming language such as COBOL, Pascal or C?
Answer:
Because they lack the idea of inheritance, COBOL, Pascal, and C are not OOP (object oriented
programming) languages. Although we can use struts in COBOL, Pascal, and C, these languages lack
suitable classes and methods. Struts also lack the ability to have private and public members.
Polymorphism cannot be found in COBOL, Pascal, or C.
5. Define using the following structure a class definition for cars. A car generally has abilities to
start, move forward, and move backward, stop and off. A car can also return to its relative
location. The starting location is a value 0.
Answer:
Class Car {
Attributes:
Name = Car
Methods:
StartingLocation ()
Check the car keys and start
Move the car using accelerator and steering wheel
Turn off the car while your in the parking and leave
}
The car falls under a car category, which establishes limitations on things like the
range of permitted size, engine power, weight, and other factors. The values defined by the
car model settings must not be in contradiction with the limitations imposed by the
automobile category. For instance, turn the wheel left, turn the wheel right, and then press
the throttle.
6.Distinguish between a client and a server
Answer:
The primary distinction between a client and a server is that a client is a device or
program that makes service requests via the internet, whereas a server is a device or
program that fulfils such requests for clients.
7. A client communicates with a server by sending a _______ to the server. The ___________ is
a call on a _____________ of the server.
Answer:
Request
8. Using the figure below, create a program using any JAVA programming text editor (Sublime
Text,Atom, Notepad++, Textpad, gEdit) or an IDE (such as Eclipse or NetBeans).
Programs
Circle.java
public Circle() {
radius = 1.0;
color = "red";
public Circle(double r) {
radius = r;
color = "red";
}
// A public method for retrieving the radius
return radius;
return radius*radius*Math.PI;
Testcircle.java