Inheritance Inheritance :

Similar documents
COIMBATORE EDUCATIONAL DISTRICT

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Introduction to Programming Using Java (98-388)

SRI SARASWATHI MATRIC HR SEC SCHOOL PANAPAKKAM +2 IMPORTANT 2 MARK AND 5 MARK QUESTIONS COMPUTER SCIENCE VOLUME I 2 MARKS

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING


Object Oriented Programming. C++ 6 th Sem, A Div Ms. Mouna M. Naravani

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

Sri Vidya College of Engineering & Technology

What does it mean by information hiding? What are the advantages of it? {5 Marks}

Object Orientated Analysis and Design. Benjamin Kenwright

PROGRAMMING IN C++ COURSE CONTENT

Inheritance, and Polymorphism.

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

Object Oriented Programming. Solved MCQs - Part 2

Data Structures using OOP C++ Lecture 3

SRE VIDYASAAGAR HIGHER SECONDARY SCHOOL

Downloaded from

AMCAT Automata Coding Sample Questions And Answers


Absolute C++ Walter Savitch

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

JAVA MOCK TEST JAVA MOCK TEST II

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

Chapter-8 DATA TYPES. Introduction. Variable:

6.096 Introduction to C++ January (IAP) 2009

- HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2013 CISC2200 Yanjun Li 1. Fall 2013 CISC2200 Yanjun Li 2

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2017 CISC2200 Yanjun Li 1. Fall 2017 CISC2200 Yanjun Li 2

C++ Important Questions with Answers

Object-Oriented Programming Concepts

User-defined Functions Case study

Elementary Concepts of Object Class

STRUCTURING OF PROGRAM

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30

CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE

Declaration Syntax. Declarations. Declarators. Declaration Specifiers. Declaration Examples. Declaration Examples. Declarators include:

Chapter 4: Writing Classes

Anatomy of a Class Encapsulation Anatomy of a Method

VALLIAMMAI ENGINEERING COLLEGE

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

What are the characteristics of Object Oriented programming language?

EECS168 Exam 3 Review

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

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat

22316 Course Title : Object Oriented Programming using C++ Max. Marks : 70 Time: 3 Hrs.

9/19/2018 Programming Data Structures. Polymorphism And Abstract

Objective-C: An Introduction (pt 1) Tennessee Valley Apple Developers Saturday CodeJam July 24, 2010 August 7, 2010

CS 231 Data Structures and Algorithms, Fall 2016

Short Notes of CS201

CLASSES AND OBJECTS IN JAVA

Problem Solving with C++

CS201 - Introduction to Programming Glossary By

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

Anatomy of a Method. HW3 is due Today. September 15, Midterm 1. Quick review of last lecture. Encapsulation. Encapsulation

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

Object Oriented Design

CS242 COMPUTER PROGRAMMING

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

cast.c /* Program illustrates the use of a cast to coerce a function argument to be of the correct form. */

A flow chart is a graphical or symbolic representation of a process.

A SHORT COURSE ON C++

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

OBJECT ORIENTED PROGRAMMING

Kapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class

Dot and Scope Resolution Operator

Data Structures using OOP C++ Lecture 6

COMPUTER PROGRAMMING (ECE 431) TUTORIAL 9

Dr. Md. Humayun Kabir CSE Department, BUET

Why C++? C vs. C Design goals of C++ C vs. C++ - 2

Get Unique study materials from

HOLIDAYS HOMEWORK CLASS : XII. Subject : Computer Science

COMMON QUARTERLY EXAMINATION SEPTEMBER 2018

ENCAPSULATION. private, public, scope and visibility rules. packages and package level access.

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

JAVA: A Primer. By: Amrita Rajagopal

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects


Chapter 2: Introduction to C++

Chapter 5 Object-Oriented Programming

Topic 1: Introduction

COMS W3101 Programming Language: C++ (Fall 2016) Ramana Isukapalli

Quiz Start Time: 09:34 PM Time Left 82 sec(s)

Base class or Super class. Subclass or Derived class

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Design issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?

CS201 Latest Solved MCQs

Exception-Handling Overview

CGS 2405 Advanced Programming with C++ Course Justification

Chapter 7 Array. Array. C++, How to Program

Inheritance and Overloading. Week 11

Programming in C++ 5. Integral data types

CS 1316 Exam 1 Summer 2009

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING

COMP322 - Introduction to C++

Memory and Addresses. Pointers in C. Memory is just a sequence of byte-sized storage devices.

Chapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

EMBEDDED SYSTEMS PROGRAMMING OO Basics

C++_ MARKS 40 MIN

Transcription:

: is the process of creating a new class(derived classes) from existing classes( ase lasses). The derived classes not only inherit the capabilities of the base class abut also can add new features of their own. The process of inheritance does not affect the base class. The most important features of inheritance is that it allows reusability of code, and also a debugged class can be used to work in different situations. Reusability of code saves money as well as time and increase program reliability. is very useful in original conceptualization and design of a programming problem. Single level Multi Level Hierarchical Types of inheritance Multiple Hybrid D Visibility Under Different Modes Member Object Member Member Object Object ly Derived

ly Derived Derived las Single class lassname Derived SYNT Single Level class <Derived class name>:<ccess specifier> < Name> Example of single Level ountry State lass ountry class state :public country int no_of_farms; void Get( ); void Put ( );

class lassname Multi Level class <Derived class name>:<ccess specifier> < Name> SYNT Multi Level ountry State District class <Devied class Name> :<ccess Specifier> < Name> <lass Member >; <lass member>; <lass member>; Example of Multi Level lass ountry class state :public country int no_of_farms; void Get( ); void Put ( ); class District : public state int no_of_offices; void input( ); void output( );

class lassname class lassname Multiple SYNT Multiple class < Name>:<ccess Specifier>< Name>, <ccess Specifier> < Name> <lass Member>; <class Member>; ountry Rules Example of multiple lass ountry 1 class Givernment int articleno; 2 void Get( ); void Put( ); lass Rules: public ountry, public Government char description[80]; void input( ); void output( ); } Government

class lassname Hierarchical lass < Name1>:<ccess Specifier>< Name> Syntax Hierarchical lass < Name2>:<ccess Specifier>< Name> ountry Example of Hierarchical class ountry class state :public country int no_of_farms; void Get( ); void Put ( ); State Union Territory class UnionTerritory : public ountry int no_of_offices; void Input( ); void Output( );

Q1. nswer the question with the help of the portion of program shown below class U int u; int y; void haveit( ); void showit(); class T : public U int x1; void calc ( ); int y1; void doit( ); int z1; void ShowIt(); void ddit( ); class P: private T int x2; int y2; int z2; void Display(); void hange( ); a) Name the member function(s), which can be accessed from the object of, class P. b) Name the data member(s), which can be accessed from the member function of class T. c) Name the data member(s), which can be accessed from the object of class U. d) is the data member Y declared in class U accessible to the member function hange( ) of class P. e) How many bytes will be required by an object of class P. f) Write the definition of member function display ( ) of class P to display all data members which are accessible from it. g) Write the name of base class and derived class of class T. h) Name the inheritance shown in this example.

Object Oriented Programming & Procedural Programming Object Oriented Programming Procedural Programming Emphasis on data Emphasis on doing things( function) Follows bottom-up approach in program design Follow top down approach in program design oncept of data Hiding prevents accidental change Due to presence of global variables, there is a in the data possibility of accidental change in data Polymorphism,, Data Encapsulation Not pplicable possible Data Encapsulation: Wrapping up of data and function in a single unit is known as data encapsulation. In a class, we encapsulate the data and function together in a single unit. Data Hiding : Keeping the data in private/ visibility mode of a class to prevent it from accidental modification ( hange) is known as data Hiding dditional Definition Run Time Error : run time error occurs during the execution of the program, when the program perform an illegal /unexpected operation For example ( Division by Zero) = U*H-P; y = Z/ ; // will be run time error if becomes zero from the first statement Syntax Error : syntax error occurs when the compiler is unable to translate the program to machine language due to violation of rules of the programming language. For example ( in ++, if statement is not enclosed in brackets) if x> 90 cout<< \n Value of x is 90 ; Logical Error : logical error occurs when the program contains wrong formula or wrong manipulation, which may me syntactically correct. The program having logical error may give some output but not the expected one. For Example // int sum; float average;../., verage = sum /5;