Ticker

6/recent/ticker-posts

Class 10 Computer Engineering Object oriented Programming 2074 Solved Question Paper

 

SEE 2074

Group A

1.       Write down the names of any two object-oriented programming language.

àTwo object-oriented programming language are: C++, Python, Java etc.

 

2.       What is an inheritance?

àInheritance is a feature of OOP in which one class can derive properties and characteristics from another class.

 

3.       What is a header file?

àHeader file is a file with usually .h extension which is included in source program header to obtain access to its contents.

 

4.       What is the extension for C++ files?

àThe extension for C++ files is .cpp

 

5.       What is a constructor?

àA class constructor is a special function in a class that is called automatically whenever a new object of the class is created.

 

6.       How many objects can be created for a given class?

àAny number of objects can be created for a given class.

 

7.       What is a structure?

àA structure is user defined data type that can hold related data of various data types.

 

8.       Define polymorphism.

àPolymorphism is a feature of OOP that allows the same entity (function or operator) to behave differently in different scenarios.

 

9.       Define function overriding.

àFunction overriding is a feature in OOP that allows a subclass or child class to provide a specific implementation of a function that is already provided by one of its super classes or parent classes.

 

10.   What is an operator?

à Operator is a special symbol performing specific operation on one, two or three operands and then returning a result.

 

11.   What is a postfix notation?

à Postfix notation, also known as reverse Polish notation, is a syntax for mathematical expressions in which the mathematical operator is always placed after the operands.

 

12.   What is an access specifier?

à Access modifiers (or access specifiers) are keywords in object-oriented that  are used for determining or setting the boundary for the availability of class members (data members and member functions).

 

13.   What is a child class?

à The class which inherits all the non-private members of its base class is called Child or Derived or Sub class.

 

Group B

14.   Mention any two limitations of procedure oriented programming.

àTwo limitations of procedure oriented programming are:

·         Difficult to relate with real world objects.

·         Importance is given to the operation on data rather than the data.

·         Data is exposed to whole program, so no security for data.

 

15.   WAP in C++ to display "I am a technical student" on the standard output device.

à

#include <iostream>

using namespace std;

int main()

{

    cout<<"I am technical student";

    return 0;

}

 

16.   Write down the syntax of an inline function.

àSyntax:

inline return-type function-name (parameters)

 {

// function code

 }

 

17.   Mention different types of constructor.

àDifferent types of constructor are:

·         Default constructor

·         Parameterized Constructor

·         Copy constructor

 

18.   Write down the syntax for pure virtual function.

àSyntax:

virtual return_type function_name() = 0;

 

19.   List any four operators that can't be overloaded.

àFour operators that can't be overloaded are:

·         (.) Member access or dot operator

·         (? :) Ternary or conditional operator

·          (::) Scope resolution operator

·          Pointer-to-member Operator (.*)

·         (sizeof) The object size operator

 

20.   Differentiate between public and protected access specifier

à

Public access specifier

Protected access specifier

It doesn’t provide any kind of security for its data.

It provides security for its data.

Members of a class marked with public access specifier are accessible from anywhere within the program.

Members of a class marked with protected access specifier are accessible from the same class and from any other class that inherits it. (i.e. it's child class)

 

Group C

21.   Differentiate between procedure-oriented programming(POP) and object oriented programming (OOP)

à

OOP

POP

Stands for Object oriented Programming

Stands for Procedural oriented Programming

Emphasis on objects

Emphasis on functions

It follows bottom-up approach.

It follows top down approach.

There is a feature of inheritance in OOP

POP doesn’t have the concept of inheritance

Has access specifiers

Doesn’t have access specifiers

Supported by C++, java

Supported by C, Pascal

 

22.   WAP in C++ to convert the temperature from centigrade to fahreinheit scale using class and object.

à

 #include <iostream>

using namespace std;

class Convert{

                 float fahren, celsius;

                 public:

                void C(){

                                cout << "Enter the temperature in celsius: ";

                                 cin >> celsius;

 

                                                 // convert celsius to fahreneheit

                                                 // Multiply by 9, then divide by 5, then add 32

                                                  fahren =(9.0/5.0) * celsius + 32;

 

                                cout << celsius <<" Centigrade is equal to " << fahren <<"Fahrenheit";

                                                }

                               

};

int main() {

    Convert obj;

    obj.C();

    return 0;

}

 

23.   How is members of a structure accessed? Explain with an example.

à A structure member can be accessed by using period or dot (i.e. ".") operator. The syntax for accessing member of a structure variable is as follows:

Structure_variable.member;

 

Here, structure_variable refers to the name of a structure-type variable and member refers to the name of a member within the structure. The dot operator must have a structure variable on its left and a legal member on its right.

 

Here is an example, demonstrating how to access members of a structure in C++

#include<iostream>

struct st

{

 int a; // structure member

 int b; // structure member

 int sum; // structure member

}st_var; // structure variable

 

int main()

{

 cout<<"Enter any two number:\n";

                // accessing structure member a and b

                cin>>st_var.a>>st_var.b;

 // accessing structure member sum, a, and b

 st_var.sum = st_var.a + st_var.b;

 // accessing structure member sum

 cout<<"\nSum of the two number is "<<st_var.sum;

 return 0;

}

Output

Enter any two number:

3

4

Sum of the two number is 7

 

24.   Differentiate between static binding and dynamic binding.

àDifference between static and dynamic binding Static Binding:
1. It is a binding that happened at compile time

2.It is also called early binding
3. Static binding result in faster execution of program
4. It is achieved by function overloading and operator overloading.
5.It is less flexible.

Dynamic Binding:
1. It is a binding that happened at run time
2. It is also called late binding
3. It results in slow execution of program
4. It is achieved by virtual function and pointers.
5. It is more flexible.

25.   'Inheritance supports code reusability." Explain this statement.

àInheritance supports the concept of “reusability”, i.e. when we want to create a new class and there is already a class that includes some of the code that we want, we can derive our new class from the existing class. By doing this, we are reusing the fields and methods of the existing class.

Let's take an example to understand this statement better.

Consider a group of vehicles. You need to create classes for Bus, Car and Truck. The methods needFuel(), haveWhell(), applyBrakes() will be same for all of the three classes. If we create these classes avoiding inheritance then we have to write all of these functions in each of the three classes as shown in below figure: 
 

 

You can clearly see that above process results in duplication of same code 3 times. This increases the chances of error and data redundancy. To avoid this type of situation, inheritance is used. If we create a class Vehicle and write these three functions in it and inherit the rest of the classes from the vehicle class, then we can simply avoid the duplication of data and increase re-usability. Look at the below diagram in which the three classes are inherited from vehicle class:


Using inheritance, we have to write the functions only one time instead of three times as we have inherited rest of the three classes from base class (Vehicle). Hence inheritance supports code reusability.

Reactions

Post a Comment

0 Comments