Technical Interview: Computer Science and Engineering: C ++ Programming

Doorsteptutor material for competitive exams is prepared by world's top subject experts: get questions, notes, tests, video lectures and more- for all subjects of your exam.

Computer Science and Engineering

C ++ Programming

37) How can we achieve data encapsulation in C ++ ?

38) Which of the methodology is used for reusability of code?

A) Polymorphism

B) Encapsulation

C) Inheritance

39) Which of the methodology is used for Readability of code?

A) Polymorphism

B) Encapsulation

C) Inheritance

40) What is class and object?

41) What are class members and mention the control that we can use on class members?

42) What is purpose of constructor and when it will be called?

43) Create a class with below specification

Define a class BOOK with the following specification:

Private members of the class ′ BOOK ″ are

BOOK NO integer type

BOOKTITLE 20 characters

PRICE float (price per copy)

TOTAL_COST () A function to calculate the total cost for N number of copies where N is passed to the method.

Public members of the class ′ BOOK ″ are

INPUT () function to read BOOK_NO. BOOKTITLE,

PRICE

PURCHASE () function to ask the user to input the number of copies to be purchased.

44) What is private, public, and protected Inheritance?

45) How we can achieve inheritance in c ++ ? What operator so we need for inheritance?

46) What is a base class and what is derived class? Explain with an exampling using C ++ ?

47) Write a inheritance classes in four models, named A, B, C, D. All models have same capacity of seats, shape and comes in four colors. The difference of Models is A is diesel, B is diesel with power steering, C is petrol and D is petrol with power steering.

48) What is difference between overriding and overloading?

49) What type of inheritance does the D class of below diagram represents?

What Type of Inheritance

50) class D: B

{

. .

} ;

In the above example what is access control of the base class B?

51) What are the advantages of Operator Overloading?

52) Give syntax of creating class template?

53) Consider the following two classes:

Public class Class A {

Public void one (int i) {

}

Public void two (int i) {

}

}

Public class Class B extends Class A {

Public static void one (int i) {

}

Public void two (int i) {

}

Public static void three (int i) {

}

Public static void three (int I, float f) {

}

Public static void four (int i) {

}

}

a. Which method overrides a method in the superclass?

b. Which method hides a method in the superclass?

c. What do the other methods do?

54) Which keyword is used to rectify the problem that causes in accessing the members of class A is class D?

Which Keyword is Used to Rectify the Problem

55) What is difference between Virtual function and pure virtual function?

56) If a class have at least on pure virtual class then what type of class it becomes?

57) In exception handling which block of code executes upon any exception in the execution?

58) What is the purpose of ‘throw’ keyword in C ++ ?

59) What is the output of below program

#include < iostream >

int main ()

{

int X =-1,

try

{

cout ≪ “Inside try ⧵ n,”

if (x < 0)

{

throw x,

cout ≪ “After throw ⧵ n,”

}

} catch (int x)

{

cout ≪ “Exception Caught ⧵ n,”

}

Cout ≪ “After catch ⧵ n,”

return 0,

}

60) Which header file is used for I/O operation on file?

Developed by: