Your chief Software designer has shown you a sketch of the new Computer parts system she is about to create. At the top of the hierarchy is a Class called Computer and under this are two child classes. One is called LinuxPC and one is called WindowsPC. The main difference between the two is that one runs the Linux operating System and the other runs the Windows System (of course another difference is that one needs constant re-booting and the other runs reliably). Under the WindowsPC are two Sub classes one called Server and one Called Workstation. How might you appraise your designers work?

► Give the goahead for further design using the current scheme

► Ask for a re-design of the hierarchy with changing the Operating System to a field rather than Class type

► Ask for the option of WindowsPC to be removed as it will soon be obsolete

► Change the hierarchy to remove the need for the superfluous Computer Class.

When a variable is define as static in a class then all object of this class,

► Have different copies of this variable► Have same copy of this variable

► Can not access this variable► None of given

Question No: 11( Marks: 1 )- Please choose one

_______ remain in memory even when all objects of a class have been destroyed.

► Static variables► Instance variable

► Primitive variables► None of given

Question No: 12( Marks: 1 )- Please choose one

Given the following class

class Base{

int Age=33;

}

How you can improve above class with respect to accessing the field Age?

► Define the variable Age as private

► Define the variable Age as protected

► Define the variable Age as private and create a get method that returns it and a set method that updates it► Define the variable Age as protected and create a set method that returns it and a get method that updates it

Question No: 13( Marks: 1 )- Please choose one

The life of sub object is not dependant on the life of master class in ___________.

A type of programming in which programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure. In addition, programmers can create relationships between one object and another. For example, objects can inherit characteristics from other objects.

Question No: 19( Marks: 2 )

Fill in the blanks below with public, protected or private keyword.

Public members of base class are _____ public _____ members of derived class

Protected members of base class are __ protected or private ________members of derived class.

Question No: 20( Marks: 3 )

What do you mean by the term Abstraction? Why we use it.

Abstraction is way to cope with complexity and it is used to simplify things.

Principle of abstraction:

Capture only those details about an object that are relevant to current perspective

Abstraction

Example:

Suppose we want implement abstraction for the following statement, "Ali is a PhD student and teaches BS Students"

Here object Ali has two perspectives one is his student perspective and second is his teacher perspective

Abstraction Advantages,

Abstraction has following major advantages,

1. It helps us understanding and solving a problem using object oriented approach as it hides extra irrelevant details of objects.

2. Focusing on single perspective of an object provides us freedom to change implementation for other aspects of for an object later.

Similar to Encapsulation Abstraction is also used for achieving information hiding as we show only relevant details to related objects, and hide other details.

Object quality. inheritance gives reusability, The derived classes have all the features of the base class and the programmer can choose to add new features specific to the newly created derived class. The relationship between a parent and child class under private inheritance¤ is not "is a", but "is implemented as a"

Example: father and child relation. father properties power

Get the child.

Consider a class Man derived class of Monkey an object of

Man inherits some of monkeys qualities and overrides some

Qualities like walking straight with two legs and have

Additional functions like speech etc..

The simple example in C++ is having a class that inherits a data member from its parentclass.
class A
{ public: integer d;
};

class B : public A
{ public:
};

The class B in inherits the data member d from class A. When one class inherits from another, it acquires all of its methods and data. We can then instantiate an object of class B and call into that data member.

Suppose we have a furniture store with the following types of furniture, Chairs, Tables, Computer Tables, Dining Tables and Beds.

You have to model this store using inheritance by describing base class, derived classes.

You also have to describe the IS–A relationship between these classes.

Part B.

What is IS-A relationship, show how it is implemented using c++ code (you do not have to give the detailed code simply show in a single line or two how it will be implemented).

In knowledge representation and object-oriented programming and design, is-a is a relationship where one class D is a subclass of another class B (and so B is a superclass of D). In object-oriented programming the is-a relationship arises in the context of inheritance concept. One can say that "apple" may inherit all the properties common to all fruits, such as being a fleshy container for the seed of a plant.

The is-a relationship is contrasted with the has-a relationship, which constitutes the hierarchy. It may also be contrasted with the instance-of relation: see type-token distinction.

When designing a model (e.g., a computer program) of the real-world relationship between an object and its subordinate, a common error is confusing the relations has-a and is-a.

Your chief Software designer has shown you a sketch of the new Computer parts system she is about to create. At the top of the hierarchy is a Class called Computer and under this are two child classes. One is called LinuxPC and one is called WindowsPC. The main difference between the two is that one runs the Linux operating System and the other runs the Windows System (of course another difference is that one needs constant re-booting and the other runs reliably). Under the WindowsPC are two Sub classes one called Server and one Called Workstation. How might you appraise your designers work?