Chapter 2. Building Multitier Programs with Classes The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill
|
|
- Annabelle Henderson
- 5 years ago
- Views:
Transcription
1 Chapter 2 Building Multitier Programs with Classes McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved.
2 Objectives Discuss object-oriented terminology Create your own class and instantiate objects based on the class Create a new class based on an existing class Divide an application into multiple tiers Throw and catch exceptions Choose the proper scope for variables Validate user input using the TryParse and display messages using an ErrorProvider component McGraw-Hill 2-2
3 Object-Oriented Programming A key concept of OOP is using building blocks, or classes In VB everything is based on classes Each form is a class and must be instantiated before it can be used Variables of the basic data types are objects, with properties and methods McGraw-Hill 2-3
4 OOP Terminology Key features of object-oriented programming Abstraction Encapsulation Inheritance Polymorphism McGraw-Hill 2-4
5 Abstraction Abstraction means to create a model of an object for the purpose of determining the properties and methods of the object For example, a Customer class is an abstract representation of a real customer Think of objects generically What are the characteristics of a typical product Not what are the characteristics of a specific product McGraw-Hill 2-5
6 Encapsulation Combination of characteristics of an object along with its behaviors One package holds the definition of all properties, methods, and events Makes data hiding possible Properties and methods are hidden Public and Private keywords expose only those properties and methods that need to be seen by the outside world Any Windows program is an example of encapsulation Form is a class Methods and events are enclosed within the Class and End Class statements Variables are properties of that specific form class McGraw-Hill 2-6
7 Inheritance - 1 The ability to create a new class from an existing class Add enhancements to a class without modifying the original The original class is called the base, superclass, or parent class The inherited class is called a subclass, a derived class, or a child class Inherited classes always have an is a relationship with the base class McGraw-Hill 2-7
8 Inheritance - 2 Place common code in a base class Create derived classes or subclasses to call the shared functions Create a class strictly for inheritance Called an abstract class Declared with MustInherit in the class header Cannot instantiate objects from an abstract class, only inherit new classes from it McGraw-Hill 2-8
9 Multiple subclasses can inherit from a single base class Inheritance - 3 McGraw-Hill 2-9
10 Polymorphism Ability to take on many shapes or forms Methods with identical names but different implementations, depending on the situation The Select method is different for radio buttons, check boxes, and list boxes A single class can have more than one method with the same name but a different argument list The method is said to be overloaded When an overloaded method is called, the argument type determines which version of the method to use McGraw-Hill 2-10
11 Reusable Objects Big advantage of OOP is the ability to reuse objects Class modules can be used in multiple projects Each object from the class has its own set of properties Developing applications is like building objects with Lego blocks The blocks fit together and can be used to build many different things McGraw-Hill 2-11
12 Multitier Applications - 1 Three-tier applications are popular Presentation (user interface) tier Business services tier Business logic or business rules may be written in multiple classes that can be stored and run from multiple locations Data tier Goal is to create components that can be combined and replaced McGraw-Hill 2-12
13 Multitier Applications - 2 McGraw-Hill 2-13
14 Designing Your Own Class Variables are characteristics or properties Methods are behaviors Sub procedures or function procedures McGraw-Hill 2-14
15 Creating Properties in a Class Declare all variables in a class as Private to accomplish encapsulation Private variable values are available only to procedures within the class When objects are created from a class, assign values to the properties Use special property procedures to Pass the values to the class module Return values from the class module McGraw-Hill 2-15
16 Property Procedures - 1 Property procedures allow a class to access its properties A Get retrieves a property value A Set assigns a value to a property Name Property procedures with a name that describes the property, such as LastName or EmployeeNumber McGraw-Hill 2-16
17 Property Procedures - 2 Set statement uses the Value keyword Refers to the incoming value for the property Property procedures are public by default Omit the option Public keyword Inside the procedure, assign a return value to the procedure name Or use a Return statement The data type of the incoming value for a Set must match the type of the corresponding Get McGraw-Hill 2-17
18 The Property Procedure General Form Private ClassVariable As DataType Declared at the module level. [Public] Property PropertyName() As DataType Get PropertyName = ClassVariable or Return ClassVariable End Get Set(ByVal Value As DataType) [statements, such as validation] ClassVariable = Value End Set End Property McGraw-Hill 2-18
19 The Property Procedure - Example Private LastNameString As String Declared at the module level. Public Property LastName() As String Get Return LastNameString Alternate version: LastName = LastNameString End Get Set(ByVal Value As String) LastNameString = Value End Set End Property McGraw-Hill 2-19
20 Read-Only and Write-Only Properties - 1 Use the ReadOnly modifier and write only the Get portion of a property procedure to create a read-only property Private paydecimal As Decimal Declared at the module level. Public ReadOnly Property Pay() As Decimal Make the property read-only. Get Return PayDecimal End Get End Property McGraw-Hill 2-20
21 Read-Only and Write-Only Properties - 2 Use the WriteOnly modifier and write only the Set portion of a property procedure to create a write-only property Private PasswordString As String Declared at the module level. Public WriteOnly Property Password() As String Make it write-only. Set (ByVal Value as String) PasswordString = Value End Set End Property McGraw-Hill 2-21
22 Constructors and Destructors A constructor is a method that automatically executes when a class is instantiated Create a constructor for a class by writing a Sub New procedure A destructor is a method that automatically executes when an object is destroyed Must be named Dispose and override the Dispose method of the base class McGraw-Hill 2-22
23 Overloading the Constructor - 1 Two methods that have the same name but a different list of arguments (the signature) are overloaded Create overloaded methods by giving the same name to multiple procedures Each has a different argument list McGraw-Hill 2-23
24 Overloading the Constructor - 2 Constructors in the Payroll class. Sub New() Constructor with empty argument list. End Sub Sub New(ByVal HoursInDecimal As Decimal, ByVal RateInDecimal As Decimal) Constructor that passes arguments. Assign incoming values to private variables. HoursDecimal = HoursInDecimal RateDecimal = RateInDecimal End Sub McGraw-Hill 2-24
25 A Parameterized Constructor A constructor that requires arguments Allows the passing of arguments/properties as the new object is created Instantiate new object in a Try/Catch block to catch missing or invalid input McGraw-Hill 2-25
26 Assigning Arguments to Properties Use property procedures to assign initial property values Within the class module, use the Me keyword to refer to the current class Improved constructor for the Payroll class. Sub New(ByVal HoursInDecimal As Decimal, ByVal rate Decimal AsDecimal) Assign arguments to properties. With Me.Hours = HoursInDecimal.Rate = RateInDecimal End With End Sub McGraw-Hill 2-26
27 A Basic Business Class Payroll application in two tiers Does not have a data tier as there is no database element McGraw-Hill 2-27
28 The Presentation Tier Also called the user interface Handles all communication with the user Results of calculations and any error messages to the user come from this tier Validation for numeric input handled in the form Business rules validation handled in the business services tier McGraw-Hill 2-28
29 The Business Services Tier Validation and calculations performed in the class, part of this tier McGraw-Hill 2-29
30 Throwing and Catching Exceptions The system throws an exception when an error occurs A program can catch the exception and take an action or ignore the exception Enclose any code that could cause an exception in a Try/Catch block McGraw-Hill 2-30
31 What Exception to Throw? Use existing.net Framework exception classes Create your own exception class that inherits from existing classes Use the System.ApplicationException class when you throw your own exceptions from application code Use the Throw statement in this format: Throw New ApplicationException( Error message to display. ) McGraw-Hill 2-31
32 Passing Additional Information in an Exception Constructor for the ApplicationException class takes only the error message as an argument Class has additional properties that can be set and checked For example, set the Source property and the Data property which can hold sets of key/value pairs McGraw-Hill 2-32
33 Throwing Exceptions Up a Level Show error messages to the user only in the user interface For a class that does not have a user interface Pass the exception up the next higher level which is the component that called the current code Use the Throw keyword to pass the exception to the form that invoked the class McGraw-Hill 2-33
34 Guidelines for Throwing Exceptions Always include an error message The message should be Descriptive Grammatically correct, in a complete sentence with punctuation at the end McGraw-Hill 2-34
35 Alternatives to Exception Handling Use exception handling for situations that are errors and out of the ordinary Use the TryParse method to help avoid parsing exceptions for invalid user input Bad input data is handled by the Else clause Dim HoursDecimal As Decimal Decimal.TryParse(HoursTextBox.Text, Hours Decimal) If HoursDecimal > 0 Then Passed the conversion; perform calculations. Else MessageBox.Show( Invalid data entered. ) End If McGraw-Hill 2-35
36 Modifying the User Interface to Validate at the Field Level Further improves the user interface Displays a message directly on the form, next to the field in error Use an ErrorProvider component for the message rather than a message box Perform field-level validation for numeric data in the Validating event of each text box McGraw-Hill 2-36
37 The Validating Event Order of events of the text box Enter GotFocus Leave Validating Validated LostFocus McGraw-Hill 2-37
38 Canceling the Validating Event CancelEventArgs argument of the Validating event handler cancels Validating event and returns focus to the control To not allow validation to cancel the form s closing, write an event handler for the form s FormClosing event e.cancel = False McGraw-Hill 2-38
39 Controlling Validating Events Suppress extra Validating events by temporarily turning off CausesValidation With.RateTextBox.SelectAll().CausesValidation = False.Focus().CausesValidation = True End With McGraw-Hill 2-39
40 The ErrorProvider Component Use an ErrorProvider component to make an error indicator appear next to the field in error Add the ErrorProvider at design time and set its properties in code If input data is invalid, a blinking icon next to the field in error can be displayed, along with a popup message Clear the ErrorProvider after the error is corrected McGraw-Hill 2-40
41 Modifying the Business Class Modify the business class Create a new class that inherits from the original class Add properties and methods to an existing class If any applications use the class, do not change the behavior of existing properties and methods McGraw-Hill 2-41
42 Instance Variables versus Shared Variables Instance Variables Each new instance of an object has its own values These properties are called instance properties, instance variables, or instance members Shared Variables Called shared properties, shared variables, or shared members Use to accumulate totals and counts for all instances of a class Private to the class, use public Get methods to make the properties accessible Retrieve shared properties by using the class name McGraw-Hill 2-42
43 Displaying the Summary Data To display a second form from the main form, declare an instance of the form s class and show the form Retrieve the summary values in a summary form from the shared properties of the business tier McGraw-Hill 2-43
44 Namespaces Used for grouping and referring to classes and structures A class or structure name must be unique in any one namespace Most classes in the.net Framework are in the System namespace Can declare namespaces in VB projects By default, each project namespace matches the project name McGraw-Hill 2-44
45 Scope Determine the scope by the location of the declaration and its accessibility modifier (Public or Private) Choices for scope, from widest to narrowest Namespace Module level Procedure level Block level McGraw-Hill 2-45
46 Namespace Any variable, constant, class, or structure declared with the Public modifier has namespace scope Declare classes and structures as Public, but not variables and constants Classes share variables only by using Property Set and Get procedures McGraw-Hill 2-46
47 Module Level Also called class-level scope A Private variable declared inside any class, structure, or module, but outside any sub procedure or function Declare module-level variables at the top of the class Variables can be declared anywhere inside the class, but outside of a procedure or function McGraw-Hill 2-47
48 Procedure Level Also called local scope Declare procedure level variables inside a procedure or function, but not within a block Can reference the variable anywhere inside the procedure but not in other procedures All procedure-level variables are private and declared with the Dim keyword Public keyword is not legal inside a procedure McGraw-Hill 2-48
49 Block Level - 1 A variable declared inside a code block Code blocks include: If/End If Do/Loop For/Next Select Case/End Select Try/Catch/Finally/End Try McGraw-Hill 2-49
50 Block Level - 2 Blocks that cause confusion are the Try/Catch/Finally/End Try The Try is one block Each Catch is a separate block The Finally is a separate block Cannot declare a variable in the Try and reference it in the Catch or the Finally blocks Declare an object variable at module or procedure level and instantiate the object inside the Try block McGraw-Hill 2-50
51 Lifetime The lifetime of a variable is as long as the variable remains in scope A namespace-level variable s lifetime is as long as the program is running A module-level variable s lifetime is as long as any reference to the class remains Generally as long as the program runs A procedure-level variable s lifetime is one execution of the procedure McGraw-Hill 2-51
52 Accessibility Domains McGraw-Hill 2-52
53 Creating Classes That Inherit Add a new class to the project Recommended approach Create a new file for each Public class Name the file the same name as the class name Exceptions are helper classes that will never be used by any other application Declare with the Friend keyword Used only in the current project McGraw-Hill 2-53
54 Adding a New Class File Select Project/Add Class Creates a new file with the.vb extension Add the Inherits clause on the first line following the Class declaration Add comments above the Class statement McGraw-Hill 2-54
55 Creating a Constructor A subclass must have its own constructor because constructors are not inherited If a constructor is not created, VS creates an implicit empty constructor First statement in a constructor of an inherited class should call the constructor of the base class MyBase.New() Pass arguments to a parameterized constructor in a base class McGraw-Hill 2-55
56 Inheriting Variables and Methods All public and protected variables and methods are inherited from the base class Constructors are not inherited McGraw-Hill 2-56
57 Shadowing and Overriding Methods An inherited class can have a method with the same name as a method in its base class The new method may shadow or override the base class method McGraw-Hill 2-57
58 Overriding To override a method in the base class, the method must be declared as overridable In the derived class the Overrides keyword must be used and it must have the same accessibility as the base class Write separate methods to override each version/signature of the base-class method McGraw-Hill 2-58
59 Shadowing A method in a derived class can shadow a method in the base class The new method replaces the base-class method in the derived class Does not replace it in any new classes derived from that class Shadowing hides all signatures with the same name in the base class McGraw-Hill 2-59
60 Using Properties and Methods of the Base Class Any public property or method of the base class can be referenced from the subclass If the base-class method has not been overridden or shadowed in the subclass, the method can be called directly Call a function in the base class by including the MyBase keyword Use the Me keyword to refer to a property or method of the current class McGraw-Hill 2-60
61 Passing Control Properties to a Component Convert a text box value to integer Integer.Parse(QuantityTextBox.Text) Pass the Checked property of a check box to a Boolean property Create an enumeration for the available choices of a radio button group or a list box McGraw-Hill 2-61
62 Creating an Enumeration Sets up a list of choices for a property VB compiler substitutes the numeric value of the element Enum is a list of named constants Data type must be integer, short, long, or byte McGraw-Hill 2-62
63 Garbage Collection The process of destroying unused objects and reclaiming memory Allow variables to go out of scope when you are finished with them The garbage collector runs periodically and destroys objects and variables that have no active reference McGraw-Hill 2-63
Building Multitier Programs with Classes
2-1 2-1 Building Multitier Programs with Classes Chapter 2 This chapter reviews object-oriented programming concepts and techniques for breaking programs into multiple tiers with multiple classes. Objectives
More informationAdvanced Programming Using Visual Basic 2008
Building Multitier Programs with Classes Advanced Programming Using Visual Basic 2008 The OOP Development Approach OOP = Object Oriented Programming Large production projects are created by teams Each
More information9/21/2010. Based on Chapter 2 in Advanced Programming Using Visual Basic.NET by Bradley and Millspaugh
Building Multitier Programs with Classes Based on Chapter 2 in Advanced Programming Using Visual Basic.NET by Bradley and Millspaugh The Object-Oriented Oriented (OOP) Development Approach Large production
More informationChapter 12. OOP: Creating Object- Oriented Programs. McGraw-Hill. Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Chapter 12 OOP: Creating Object- Oriented Programs McGraw-Hill Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. Objectives (1 of 2) Use object-oriented terminology correctly. Create
More informationChapter 02 Building Multitier Programs with Classes
Chapter 02 Building Multitier Programs with Classes Student: 1. 5. A method in a derived class overrides a method in the base class with the same name. 2. 11. The Get procedure in a class module is used
More informationChapter 12. OOP: Creating Object-Oriented Programs The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill
Chapter 12 OOP: Creating Object-Oriented Programs McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter Objectives - 1 Use object-oriented terminology correctly Create a two-tier
More informationMicrosoft Visual Basic 2005: Reloaded
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 10 Creating Classes and Objects Objectives After studying this chapter, you should be able to: Define a class Instantiate an object from a class
More informationCIS Intro to Programming in C#
OOP: Creating Classes and Using a Business Tier McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Understand how a three-tier application separates the user interface from the business
More informationChapter 5 Object-Oriented Programming
Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares
More informationOOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.
OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.
More informationHierarchical inheritance: Contains one base class and multiple derived classes of the same base class.
1. What is C#? C# (pronounced "C sharp") is a simple, modern, object oriented, and type safe programming language. It will immediately be familiar to C and C++ programmers. C# combines the high productivity
More informationPublic Class ClassName (naming: CPoint)
Lecture 6 Object Orientation Class Implementation Concepts: Encapsulation Inheritance Polymorphism Template/Syntax: Public Class ClassName (naming: CPoint) End Class Elements of the class: Data 1. Internal
More informationObject-Oriented Programming
Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object
More informationUnderstanding Inheritance and Interfaces
Chapter 8 Objectives Understanding Inheritance and Interfaces In this chapter, you will: Implement the Boat generalization/specialization class hierarchy Understand abstract and final classes and the MustInherit
More informationChapter 6. Multiform Projects The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill
Chapter 6 Multiform Projects McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter Objectives - 1 Include multiple forms in an application Use a template to create an About box
More informationLecture 10 OOP and VB.Net
Lecture 10 OOP and VB.Net Pillars of OOP Objects and Classes Encapsulation Inheritance Polymorphism Abstraction Classes A class is a template for an object. An object will have attributes and properties.
More informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation
More informationArgument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.
Local Variable Initialization Unlike instance vars, local vars must be initialized before they can be used. Eg. void mymethod() { int foo = 42; int bar; bar = bar + 1; //compile error bar = 99; bar = bar
More informationFramework Fundamentals
Questions Framework Fundamentals 1. Which of the following are value types? (Choose all that apply.) A. Decimal B. String C. System.Drawing.Point D. Integer 2. Which is the correct declaration for a nullable
More informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
More informationContents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix
PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring
More informationCMSC 132: Object-Oriented Programming II
CMSC 132: Object-Oriented Programming II Java Support for OOP Department of Computer Science University of Maryland, College Park Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationData Structures (list, dictionary, tuples, sets, strings)
Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access
More informationAbsolute C++ Walter Savitch
Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents
More informationCompaq Interview Questions And Answers
Part A: Q1. What are the difference between java and C++? Java adopts byte code whereas C++ does not C++ supports destructor whereas java does not support. Multiple inheritance possible in C++ but not
More information2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction
1. Which language is not a true object-oriented programming language? A. VB 6 B. VB.NET C. JAVA D. C++ 2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a)
More informationC++ (Non for C Programmer) (BT307) 40 Hours
C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular
More informationObject-Oriented Programming (OOP) Fundamental Principles of OOP
Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract Classes
More information1. A Web Form created in Visual Basic can only be displayed in Internet Explorer. True False
True / False Questions 1. A Web Form created in Visual Basic can only be displayed in Internet Explorer. 2. Windows Explorer and Internet Explorer are Web browsers. 3. Developing Web applications requires
More informationObject Oriented Programming With Visual Basic.NET
Object Oriented Programming With Visual Basic.NET Jinan Darwiche All rights reserved. This book and its content are protected by copyright law. No part of this book may be used or reproduced in any manner
More informationLecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance?
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 5: Inheritance & Polymorphism Lecture Contents 2 What is Inheritance? Super-class & sub class Protected members Creating subclasses
More informationZhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson
Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationOverview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017
Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 5: Inheritance & Polymorphism Lecture Contents 2 What is Inheritance? Super-class & sub class Protected members Creating subclasses
More informationMicrosoft Visual Basic 2015: Reloaded
Microsoft Visual Basic 2015: Reloaded Sixth Edition Chapter Three Memory Locations and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named constants
More informationOBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationCSC207H: Software Design. Java + OOP. CSC207 Winter 2018
Java + OOP CSC207 Winter 2018 1 Why OOP? Modularity: code can be written and maintained separately, and easily passed around the system Information-hiding: internal representation hidden from the outside
More informationVB.NET MOCK TEST VB.NET MOCK TEST I
http://www.tutorialspoint.com VB.NET MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to VB.Net. You can download these sample mock tests at your local
More informationCpt S 122 Data Structures. Introduction to C++ Part II
Cpt S 122 Data Structures Introduction to C++ Part II Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Objectives Defining class with a member function
More informationCS608 Lecture Notes. Visual Basic.NET Programming. Object-Oriented Programming Inheritance (Part II) (Part II of II) (Lecture Notes 3B)
CS608 Lecture Notes Visual Basic.NET Programming Object-Oriented Programming Inheritance (Part II) (Part II of II) (Lecture Notes 3B) Prof. Abel Angel Rodriguez CHAPTER 8 INHERITANCE...3 8.2 Inheritance
More informationGet Unique study materials from
Downloaded from www.rejinpaul.com VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : IV Section : EEE - 1 & 2 Subject Code
More informationPROGRAMMING LANGUAGE 2
31/10/2013 Ebtsam Abd elhakam 1 PROGRAMMING LANGUAGE 2 Java lecture (7) Inheritance 31/10/2013 Ebtsam Abd elhakam 2 Inheritance Inheritance is one of the cornerstones of object-oriented programming. It
More informationDEVELOPING OBJECT ORIENTED APPLICATIONS
DEVELOPING OBJECT ORIENTED APPLICATIONS By now, everybody should be comfortable using form controls, their properties, along with methods and events of the form class. In this unit, we discuss creating
More informationVB.NET. Exercise 1: Creating Your First Application in Visual Basic.NET
VB.NET Module 1: Getting Started This module introduces Visual Basic.NET and explains how it fits into the.net platform. It explains how to use the programming tools in Microsoft Visual Studio.NET and
More informationCS-202 Introduction to Object Oriented Programming
CS-202 Introduction to Object Oriented Programming California State University, Los Angeles Computer Science Department Lecture III Inheritance and Polymorphism Introduction to Inheritance Introduction
More informationSTRUCTURING OF PROGRAM
Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the
More informationWhat is Inheritance?
Inheritance 1 Agenda What is and Why Inheritance? How to derive a sub-class? Object class Constructor calling chain super keyword Overriding methods (most important) Hiding methods Hiding fields Type casting
More informationCLASSES AND OBJECTS IN JAVA
Lesson 8 CLASSES AND OBJECTS IN JAVA (1) Which of the following defines attributes and methods? (a) Class (b) Object (c) Function (d) Variable (2) Which of the following keyword is used to declare Class
More informationObject oriented programming. Encapsulation. Polymorphism. Inheritance OOP
OOP Object oriented programming Polymorphism Encapsulation Inheritance OOP Class concepts Classes can contain: Constants Delegates Events Fields Constructors Destructors Properties Methods Nested classes
More informationCSC207H: Software Design. Java + OOP. CSC207 Winter 2018
Java + OOP CSC207 Winter 2018 1 Why OOP? Modularity: code can be written and maintained separately, and easily passed around the system Information-hiding: internal representation hidden from the outside
More informationIntroduction. In this preliminary chapter, we introduce a couple of topics we ll be using DEVELOPING CLASSES
Introduction In this preliminary chapter, we introduce a couple of topics we ll be using throughout the book. First, we discuss how to use classes and object-oriented programming (OOP) to aid in the development
More informationLecture 5: Inheritance
McGill University Computer Science Department COMP 322 : Introduction to C++ Winter 2009 Lecture 5: Inheritance Sami Zhioua March 11 th, 2009 1 Inheritance Inheritance is a form of software reusability
More informationPaytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value
Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object
More information7. Inheritance & Polymorphism. Not reinventing the wheel
7. Inheritance & Polymorphism Not reinventing the wheel Overview Code Inheritance Encapsulation control Abstract Classes Shared Members Interface Inheritance Strongly Typed Data Structures Polymorphism
More informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING Unit I : OVERVIEW PART A (2 Marks) 1. Give some characteristics of procedure-oriented
More informationDepartment of Computer science and Engineering Sub. Name: Object oriented programming and data structures Sub. Code: EC6301 Sem/Class: III/II-ECE Staff name: M.Kavipriya Two Mark Questions UNIT-1 1. List
More information3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.
3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.
More informationData Structures using OOP C++ Lecture 3
References: th 1. E Balagurusamy, Object Oriented Programming with C++, 4 edition, McGraw-Hill 2008. 2. Robert L. Kruse and Alexander J. Ryba, Data Structures and Program Design in C++, Prentice-Hall 2000.
More informationInheritance and Polymorphism
Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg
More informationChapter 12: How to Create and Use Classes
CIS 260 C# Chapter 12: How to Create and Use Classes 1. An Introduction to Classes 1.1. How classes can be used to structure an application A class is a template to define objects with their properties
More informationObject Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia
Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing
More informationCS260 Intro to Java & Android 03.Java Language Basics
03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance
More informationContents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance
Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass
More informationGlossary. For Introduction to Programming Using Python By Y. Daniel Liang
Chapter 1 Glossary For Introduction to Programming Using Python By Y. Daniel Liang.py Python script file extension name. assembler A software used to translate assemblylanguage programs into machine code.
More informationSTUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming
More informationWhat are the characteristics of Object Oriented programming language?
What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is
More informationAN OVERVIEW OF C++ 1
AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function
More informationChapter 14 Abstract Classes and Interfaces
Chapter 14 Abstract Classes and Interfaces 1 What is abstract class? Abstract class is just like other class, but it marks with abstract keyword. In abstract class, methods that we want to be overridden
More informationOops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including:
Oops known as object-oriented programming language system is the main feature of C# which further support the major features of oops including: Abstraction Encapsulation Inheritance and Polymorphism Object-Oriented
More informationCh02. True/False Indicate whether the statement is true or false.
Ch02 True/False Indicate whether the statement is true or false. 1. The base class inherits all its properties from the derived class. 2. Inheritance is an is-a relationship. 3. In single inheritance,
More informationObject Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming
Overview of OOP Object Oriented Programming is a programming method that combines: a) Data b) Instructions for processing that data into a self-sufficient object that can be used within a program or in
More informationM Introduction to Visual Basic.NET Programming with Microsoft.NET 5 Day Course
Module 1: Getting Started This module introduces Visual Basic.NET and explains how it fits into the.net platform. It explains how to use the programming tools in Microsoft Visual Studio.NET and provides
More informationComputer Science 4U Unit 1. Programming Concepts and Skills Modular Design
Computer Science 4U Unit 1 Programming Concepts and Skills Modular Design Modular Design Reusable Code Object-oriented programming (OOP) is a programming style that represents the concept of "objects"
More informationMicrosoft Visual Basic 2005: Reloaded
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationC++ Important Questions with Answers
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
More informationEMBEDDED SYSTEMS PROGRAMMING OO Basics
EMBEDDED SYSTEMS PROGRAMMING 2014-15 OO Basics CLASS, METHOD, OBJECT... Class: abstract description of a concept Object: concrete realization of a concept. An object is an instance of a class Members Method:
More informationChapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language
Categories of languages that support OOP: 1. OOP support is added to an existing language - C++ (also supports procedural and dataoriented programming) - Ada 95 (also supports procedural and dataoriented
More informationInterview Questions of C++
Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.
More informationStandard. Number of Correlations
Computer Science 2016 This assessment contains 80 items, but only 80 are used at one time. Programming and Software Development Number of Correlations Standard Type Standard 2 Duty 1) CONTENT STANDARD
More informationInheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods.
Inheritance Inheritance is the act of deriving a new class from an existing one. Inheritance allows us to extend the functionality of the object. The new class automatically contains some or all methods
More informationIntroduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#)
Introduction to Programming Microsoft.NET Applications with Visual Studio 2008 (C#) Course Number: 6367A Course Length: 3 Days Course Overview This three-day course will enable students to start designing
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationInheritance (Outsource: )
(Outsource: 9-12 9-14) is a way to form new classes using classes that have already been defined. The new classes, known as derived classes, inherit attributes and behavior of the pre-existing classes,
More information1 Shyam sir JAVA Notes
1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write
More informationMicrosoft Visual Basic 2005: Reloaded
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 1 An Introduction to Visual Basic 2005 Objectives After studying this chapter, you should be able to: Explain the history of programming languages
More informationComputer Science II (20073) Week 1: Review and Inheritance
Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system
More informationIntroduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview
Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple
More informationData Abstraction. Hwansoo Han
Data Abstraction Hwansoo Han Data Abstraction Data abstraction s roots can be found in Simula67 An abstract data type (ADT) is defined In terms of the operations that it supports (i.e., that can be performed
More informationImportant when developing large programs. easier to write, understand, modify, and debug. each module understood individually
Chapter 3: Data Abstraction Abstraction, modularity, information hiding Abstract data types Example-1: List ADT Example-2: Sorted list ADT C++ Classes C++ Namespaces C++ Exceptions 1 Fundamental Concepts
More informationCGS 2405 Advanced Programming with C++ Course Justification
Course Justification This course is the second C++ computer programming course in the Computer Science Associate in Arts degree program. This course is required for an Associate in Arts Computer Science
More informationVB.NET Web : Phone : INTRODUCTION TO NET FRAME WORK
Web :- Email :- info@aceit.in Phone :- +91 801 803 3055 VB.NET INTRODUCTION TO NET FRAME WORK Basic package for net frame work Structure and basic implementation Advantages Compare with other object oriented
More informationWindows Database Updates
5-1 Chapter 5 Windows Database Updates This chapter provides instructions on how to update the data, which includes adding records, deleting records, and making changes to existing records. TableAdapters,
More informationObject Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year
Object Oriented Programming Assistant Lecture Omar Al Khayat 2 nd Year Syllabus Overview of C++ Program Principles of object oriented programming including classes Introduction to Object-Oriented Paradigm:Structures
More information