C++ Important Questions with Answers

Similar documents
Chapter 5 Object-Oriented Programming

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

What are the characteristics of Object Oriented programming language?

CS 251 Intermediate Programming Inheritance

OOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Java Object Oriented Design. CSC207 Fall 2014

Object Oriented Programming. Solved MCQs - Part 2

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

CS105 C++ Lecture 7. More on Classes, Inheritance

Introduction to Programming Using Java (98-388)

OVERRIDING. 7/11/2015 Budditha Hettige 82

CS-202 Introduction to Object Oriented Programming

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).

Inheritance -- Introduction

02 Features of C#, Part 1. Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211

KLiC C++ Programming. (KLiC Certificate in C++ Programming)

Arrays Classes & Methods, Inheritance

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

C++ Crash Kurs. Polymorphism. Dr. Dennis Pfisterer Institut für Telematik, Universität zu Lübeck

INHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U

QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed?

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Instantiation of Template class

CSE 431S Type Checking. Washington University Spring 2013

Object Oriented Programming with c++ Question Bank

Practice for Chapter 11

Interview Questions of C++

What is Inheritance?

CGS 2405 Advanced Programming with C++ Course Justification

Object-Oriented Programming

C++ Inheritance and Encapsulation

Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:

Inheritance. Benefits of Java s Inheritance. 1. Reusability of code 2. Code Sharing 3. Consistency in using an interface. Classes

Inheritance and Polymorphism

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak

Lecture Notes on Programming Languages

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Chapter 6 Introduction to Defining Classes

STRUCTURING OF PROGRAM

More C++ : Vectors, Classes, Inheritance, Templates

Syllabus of C++ Software for Hands-on Learning: This course offers the following modules: Module 1: Getting Started with C++ Programming

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

More C++ : Vectors, Classes, Inheritance, Templates. with content from cplusplus.com, codeguru.com

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT

Short Notes of CS201

RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS

Inheritance and Polymorphism


CS201 - Introduction to Programming Glossary By

CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)

Chapter 5. Inheritance

(12-1) OOP: Polymorphism in C++ D & D Chapter 12. Instructor - Andrew S. O Fallon CptS 122 (April 3, 2019) Washington State University

OBJECT ORIENTED PROGRAMMING USING C++

Chapter 14 Abstract Classes and Interfaces

FINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING

Inheritance, Polymorphism and the Object Memory Model

QUESTIONS FOR AVERAGE BLOOMERS

Java: introduction to object-oriented features

AN OVERVIEW OF C++ 1

Programming II (CS300)

Polymorphism. Zimmer CSCI 330

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

Object Oriented Programming

XII- COMPUTER SCIENCE VOL-II MODEL TEST I

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Programming Exercise 14: Inheritance and Polymorphism

1 Shyam sir JAVA Notes

Day 4. COMP1006/1406 Summer M. Jason Hinek Carleton University

Inheritance, Polymorphism, and Interfaces

G52CPP C++ Programming Lecture 13

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Computer Science 210: Data Structures

OBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2, SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN, U.O.P. UNIT-2

Computer Science II (20073) Week 1: Review and Inheritance

HAS-A Relationship. If A uses B, then it is an aggregation, stating that B exists independently from A.

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Compaq Interview Questions And Answers

PROGRAMMING LANGUAGE 2

C++ (Non for C Programmer) (BT307) 40 Hours

Object-Oriented Design (OOD) and C++

+2 Volume II OBJECT TECHNOLOGY OBJECTIVE QUESTIONS R.Sreenivasan SanThome HSS, Chennai-4. Chapter -1

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

CS304 Object Oriented Programming Final Term

Character Stream : It provides a convenient means for handling input and output of characters.

CS260 Intro to Java & Android 03.Java Language Basics

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Course Content. Objectives of Lecture 24 Inheritance. Outline of Lecture 24. Inheritance Hierarchy. The Idea Behind Inheritance

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

Classes, Objects, and OOP in Java. June 16, 2017

Inheritance. COMP Week 12

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

Java Inheritance. Written by John Bell for CS 342, Spring Based on chapter 6 of Learning Java by Niemeyer & Leuck, and other sources.

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017

CMSC 132: Object-Oriented Programming II

Transcription:

1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? 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. 3. What are instance variables? These represent an object's private memory. They are defined in an object's class. 4. What is a super-class? 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. 5. What is an object in C++? 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. 6. What is polymorphism? The word polymorphism means having many forms. Typically, polymorphism occurs when there is a hierarchy of classes and they are related by inheritance. C++ polymorphism means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function. 7. What is operator overloading? 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.

8. Define Copy Constructor. A copy constructor is invoked when you initialize a new object of a class using an existing object. This will happen when: You pass a copy of an object as argument to a function (i.e. when passing by value). When you return an object from a function Or initialize an object during declaration using another object. If we don t specify a copy constructor, the compiler already has a default copy constructor. 9. What is the difference between overriding and overloading? An overrided method redefines an existing method in a superclass to specify a new behavior. Overloading means that you have multiple methods with the same name but with a different parameter list. 10. What is inline function? When you call the function, execution of the program jumps to those instructions, and when the function returns, execution jumps back to the next statement in the calling function. Performance degradation occurs in jumping into and out of functions. When a function is small, the program can be speeded-up using inline functions. The use of inline functions avoids have the program jump into and out of the same function over and over again.if a function is declared with the keyword 'inline', the compiler does not create a real function; it copies the code from the inline function directly into the calling function. No jump is made. 11. Write a short notes on recursion with example. Recursion is defined as a function calling itself. It is in some ways similar to a loop because it repeats the same code, but it requires passing in the looping variable and being more careful. Many programming languages allow it because it can simplify some tasks, and it is often more elegant than a loop. void recurse() {

recurse(); } void main() { } recurse(); 12. Is it possible to accept command line argument in C++? Yes, In C++ it is possible to accept command line arguments. To do so, you must first understand the full definition of int main(). It actually accepts two arguments, one is number of command line arguments, the other is a listing of the command line arguments. Ex. int main( int argc, char *argv[]) 13. Explain typecasting. Typecasting is making a variable of one type, such as an int, act like another type, a char, for one single operation. To typecast something, simply put the type of variable you want the actual variable to act as inside parentheses in front of the actual variable. (char)a will make 'a' function as a char. 14. What s the difference between public, private and protected? A member (either data member or member function) declared in a private section of a class can only be accessed by member functions and friends of that class A member (either data member or member function) declared in a protected section of a class can only be accessed by member functions and friends of that class, and by member functions and friends of derived classes A member (either data member or member function) declared in a public section of a class can be accessed by anyone 15. What are some advantages/ disadvantages of using friend functions?

Member functions and friend functions are equally privileged. The major difference is that a friend function is called like f(x), while a member function is called like x.f(). Thus the ability to choose between member functions (x.f()) and friend functions (f(x)) allows a designer to select the syntax that is deemed most readable, which lowers maintenance costs. The major disadvantage of friend functions is that they require an extra line of code when you want dynamic binding. 16. What s the difference between the keywords struct and class in c++? The members and base classes of a struct are public by default, while in class, they default to private. 17. What is c++? c++ is a general purpose object oriented programming language invented in the early 1980 by bajarne stroutrup. 18. What is class? A class can be declared as a collection of data members along with members function which allows association of data and functions into a single unit called encapsulation 19. What are the different features of c++? Following are the different features of the Classes in C++, Operators and function overloading Free storage management Constant types References Inline function Virtual function Templates Exception handling 20. Explain constructor? Constructors is a member function having the same name as that of its class and is executed automatically when the class is instantiated (object is created). 21. What is a function? A function is a block of code which executes the statements when we call it. It consists of three entities:

1) the function name. This is simply a unique identifier. 2) The function parameters. This is a set of zero or more typed identifier. 3) The function returns type this specifies the type of value function returns. 22. Explain Inline function? Inline functions are those functions whose function body is inserted in place of the function call. 23. What is function overloading? function polymorphism for function overloading is a concept that allows multiple functions to share the same name with different arguments type assigning one or more function body to the same name is known as function overloading. 24. What is implicit and explicit type conversion? In implicit casting in c++ compile automatically handle the type conversion. The final result expressed in the highest precision possible. Explicit: the conversion of data type of two operands is not automatic but forced. We can force an expression to be a specific type by using a cast. 25. What is inheritance in C++ and name the different types of inheritance? It is a technique of organizing information in a hierarchy form. It is like a child inheriting the features of its parent. The class which we are inheriting from is called as the base class and the class which inherits called as derived class. Different types of inheritance are as follows-: 1) single level 2) Multi-level 3) Multiple 4) Hierarchical (hybrid) 5) multipath. 26. What is friend function? A friend function is a function which is use to access the private data member of different class.