Friday 27 April 2018

Computer Science Engineering Interview Questions

1. What Is An Object In C++?

Answer : An object is a package that contains related data and instructions. The data relates to what the object represents, while the instructions define how this object relates to other objects and itself.

2. What Is A Message?

Answer : A message is a signal from one object to another requesting that a computation take place. It is roughly equivalent to a function call in other languages.

3. What Is A Class?

Answer : A class defines the characteristics of a certain type of object. It defines what its members will remember, the messages to which they will respond, and what form the response will take.

4. What Is An Instance?

Answer : An individual object that is a member of some class.

5. What Is A Super-class?

Answer : Given a class, a super-class is the basis of the class under consideration. The given class is defined as a subset (in some respects) of the super-class. Objects of the given class potentially posses all the characteristics belonging to objects of the super-class.

6. What Is Inheritance?

Answer : Inheritance is property such that a parent (or super) class passes the characteristics of itself to children (or sub) classes that are derived from it. The sub-class has the option of modifying these characteristics in order to make a different but fundamentally related class from the super-class.

7. To What Does Message Protocol Refer?

Answer : An object’s message protocol is the exact form of the set of messages to which the object can respond.

8. What Is Polymorphism?

Answer : Polymorphism refers to the ability of an object to respond in a logically identical fashion to messages of the same protocol, containing differing types of objects. Consider 1 + 5 and 1 + 5.1. In the former, the message “+ 5” is sent to an object of class integer (1). In the later, the message “+ 5.1” is sent to the same integer object. The form of the message (its protocol) is identical in both cases. What differs is the type of object on the right-hand side of these messages. The former is an integer object (5) while the later is a floating point object (5.1). The receiver (1) appears (to other objects) to respond in the same way to both messages. Internally, however, it knows that it must treat the two types of objects differently in order to obtain the same overall response.

9. What Are Instance Variables?

Answer : These represent an object’s private memory. They are defined in an object’s class.

10. What Are Class Variables?

Answer : These represent a class’s memory which it shares with each of its instances.

11. What Is A Method?

Answer : A method is a class’s procedural response to a given message protocol. It is like the definition of a procedure in other languages.

12. In C++ What Is A Constructor? A Destructor?

Answer : A constructors and destructors are methods defined in a class that are invoked automatically when an object is created or destroyed. They are used to initialize a newly allocated object and to cleanup behind an object about to be removed.

13. Compare And Contrast C And C++.?

Answer : Comparison: C++ is an extension to the C language. When C++ is used as a procedural language, there are only minor syntactical differences between them.
Contrast: When used as a procedural language, C++ is a better C because:
    • It vigorously enforces data typing conventions.
    • It allows variables to be defined where they are used.
    • It allows the definition of real (semantically significant) constants.
    • It allows for automatic pointer dereferencing.
    • It supports call-by-reference in addition to call-by-value in functions.
    • It supports tentative variable declarations (when the type and location of a variable cannot be known before hand.
As an object oriented language, C++ introduces much of the OOP paradigm while allowing a mixture of OOP and procedural styles.

14. What Is Operator Overloading?

Answer : It is the process of, and ability to redefine the way an object responds to a C++ operator symbol. This would be done in the object’s class definition.

15. What Is Cin And Cout?

Answer : They are objects corresponding to a program’s default input and output files. Contrast procedural and object oriented programming.
The procedural paradigm performs computation through a step-by-step manipulation of data items. Solving problems this way is akin to writing a recipe. ie: All the ingredients (data items) are defined. Next a series of enumerated steps (statements) are defined to transform the raw ingredients into a finished meal.
The object oriented model, in contrast, combines related data and procedural information into a single package called an object. Objects are meant to represent logically separate entities (like real world objects). Objects are grouped together (and defined by) classes. (This is analogous to user defined data types in procedural languages.) Classes may pass-on their “makeup” to classes derived from them. In this way, Objects that are of a similar yet different nature need not be defined from scratch.
Computation occurs though the intercommunication of objects. Programming this way is like writing a play. First the characters are defined with their attributes and personalities. Next the dialog is written so that the personalities interact. The sum total constitutes a drama.

More about Computer Science Engineering:

No comments:

Post a Comment