1. In the object-oriented design of an airline passenger reservation program, su
ID: 3685235 • Letter: 1
Question
1. In the object-oriented design of an airline passenger reservation program, suppose that "airplane" has been identified as one object and "airplane seat" has been identified as another object. Focusing specifically on the airplane object, how does it relate to the airplane seat object?
a) a has-a relationship
b) an is-a relationship
c) an independent and equal relationship
d) a and b above
2. In the object-oriented design of an airline passenger reservation program, suppose that "airplane seat," "aisle seat," and "window seat" have been identified as objects. Focusing specifically on the aisle seat object, how does it relate to the airplane seat object?
a) a has-a relationship
b) an is-a relationship
c) an independent and equal relationship
d) a and b above
3. Consider the following portion of a problem definition: The program displays a menu to the user. If the user responds with 'T', the program displays the time of day. If the user responds with 'D', the program displays today's date. In an object-oriented design, which of the following probably would not be identified as an object?
a) menu
b) user
c) time of day
d) date
4. In object-oriented design, which of the following is not likely to be a problem-domain object?
a) a factory assembly line
b) a robot arm
c) a sorted list
d) a and b above
5. Inserting into an unsorted list and inserting into a sorted list are the same time complexity.
a) True
b) False
Explanation / Answer
First see the difference between IS-A relationship and HAS-A relationship.
the concept of IS-A is based on Inheritance, For example, Apple is a Fruit, Car is a Vehicle etc. It is uni-directional. For example House is a Building. But Building is not a House.
HAS-A relationship means use of instance variables that are references to other objects. For example: Maruti has Engine, or House has Bathroom
ques1:
If we consider airplane object and airplane seat object.. It is example of composition not inheritance. because Airplance has seat in it. Airplane is not a type of seat.
Both Airplanne and Airplane seat class are independent of each other and we will use airplane seat object in airplane class.
So It is a has-a relationship
Ques2:
If we consider aisle seat and window seat both are type of seat and window seat is a aisle seat with some unique and more features or you can say different features.
it is a type of
Aisle Seat Class
{
}
Window Seat Class extends Aisle Seat class
{
}
So It is an is-a relationship
Ques3:
Object is an instance of class which has its unique name and attribute to identify
Now we have 3 things
date, time and menu
Date is a object because it it is part of Date Class which always have one unique value and behaviour to identify
Time is a object of Time Class which follow same property as Date
Now you can think Menu is output statements which is shown to user. We can conver Menu in to class and access it through object. So It means Menu can also be identified as object.
But user is real life entitiy which is going to use other objects. Which gives you input and expect output. It is neither a class nor follow any class properties.
So User would not be identified as an object. ( b )
Ques 4:
Problem domain is a term referring to all information that defines the problem and constrains of the solution and Problem domain class are not real class which follow inheritance composition etc features but give proper understanding of problem statement description.
Now in given options
a factory assembly line, a robot arm, a sorted list
Sorted List is not likely to be a problem domain object because we can not identify any problem descriptions from sorted List which is itself a one type of solution in its own
Ques5:
Inserting into an unsorted list and inserting into a sorted list are the same time complexity. False
because when we insert in sorted List we will just append the new item in list. We will not take care of exact location and we will not do any comparision because we have to add it in last only irrespective of other elements. Will take O(1) time.
But in case of sorted List we have to first find appropriate location so that order will remain maintained. i.e. after inserting new element list has to be sorted again and for this we have to do comparision of new element with existing element and then reshuffle the list to one position down/up according to new element value.
So Inserting into an unsorted list and inserting into a sorted list will have different time complexity.
1:a
2:b
3:b
4:c
5:b
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.