PROMOTE MY BLOG: JUST CLICK BELOW BUTTON

Search Any Paper On This Blog

Saturday, December 4, 2010

CS304- Object Oriented Programming Complete Solved Past Paper Fall 2009

MIDTERM  EXAMINATION
Fall 2009
CS304- Object Oriented Programming (Session - 5)
    
Question No: 1    ( Marks: 1 )    - Please choose one
Which one of the following terms best represents the statement given below,
” Hiding details of an object from the other parts of a program”
       Obfustication.       Data Mining.       Compilation.       Encapsulation
  
 
Question No: 2    ( Marks: 1 )    - Please choose one
The process of hiding unwanted details from users is called __________.
       ► Protection        Encapsulation       ► Argumentation       ► Abstraction
   
Question No: 3    ( Marks: 1 )    - Please choose one
An employee working in an organization has

1. Name           2. Past experience        3. Age  4. Relatives       5. Hobbies in spare times
Keeping in view the principle of abstraction, which of the above information the company needs to save as employee’s record?
       ► 2, 4       ► 1, 3, 5       ► 1, 2, 3       ► 1, 2, 3, 4
   
Question No: 4    ( Marks: 1 )    - Please choose one
What a derived class can add?
       ► New data members       ► New member functions and New friend functions
       ► New constructors and destructor       ► All of given
    Question No: 5    ( Marks: 1 )    - Please choose one
The concept of derived classes is involved in,
       ► inheritance        encapsulation       structure         array
   
Question No: 6    ( Marks: 1 )    - Please choose one
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.

Question No: 7    ( Marks: 1 )    - Please choose one
Consider the code below,
class Fred {
public:
Fred();
...
};
int main()
{
Fred a[10];
Fred* p = new Fred[10];
...
}
Select the best option,
       Fred a[10]; calls the default constructor 09 times
Fred* p = new Fred[10];  calls the default constructor 10 times

       ► Produce an error

       ► Fred a[10]; calls the default constructor 11 times
Fred* p = new Fred[10];  calls the default constructor 11 times

       ► Fred a[10]; calls the default constructor 10 times
Fred* p = new Fred[10];  calls the default constructor 10 times
   
Question No: 8    ( Marks: 1 )    - Please choose one
   Which construct is the source for the creation of an object?
       ► Destructor of the class       ► New operator
       ► Delete operator       ► Constructor of the class
  
 
Question No: 9    ( Marks: 1 )    - Please choose one
this pointers are not accessible for static member functions.
       True       False
   
Question No: 10    ( Marks: 1 )    - Please choose one
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 ___________.
       ► Composition        Aggregation        ► Separation         ► None of the given
   
Question No: 14    ( Marks: 1 )    - Please choose one
Which one is not keyword in C++?
       ► operator       ► B_op       ► const       ► None of given
   

Question No: 15    ( Marks: 1 )    - Please choose one
The >= operator can be overloaded.
       ► True       ► False
   
Question No: 16    ( Marks: 1 )    - Please choose one
Identify which of the following overloaded operator function’s declaration is appropriate for the given call?
Rational_number_1 + 2.325
Where Rational_number_1 is an object of user defined class Rational_number.
       ► Rational_number operator+( Rational_number & obj);
       ► Rational_number operator+(double& obj);
       Rational_number operator+(Rational_number &obj, double& num);…mjh sy ye solve ni howa I think theak he ha.
       ► operator+(double& obj);
  
 
Question No: 17    ( Marks: 1 )
 Give one line definition of "Ternary Association".
Association between three classes
Diamond
May have association class connected at one corner of the diamond
Example: Association between Insurance Contract, Person, Insurance Policy 

Question No: 18    ( Marks: 1 )
Give one line definition of "Object Orientation".
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.
Question No: 21    ( Marks: 5 )
 Derived class can inherit base class features? Explain it with example.
Inheritance is a process by which an object inherits parent
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.
void func() { B b; b.d = 10; };
Question No: 22    ( Marks: 10 )
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.

Code:
Class newclsaa:public perent class{
}
 Part A.

No comments:

Post a Comment

PLEASE COMMENT ABOUT YOUR VISIT AND MY SITE

Note: Only a member of this blog may post a comment.