CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.

Slides:



Advertisements
Similar presentations
OOP Abstraction Classes Class Members: Properties & Methods Instance (object) Encapsulation Interfaces Inheritance Composition Polymorphism Using Inheritance.
Advertisements

CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look 1 Xiang Lian The University of Texas – Pan American Edinburg,
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
CS 211 Inheritance AAA.
CSE 1302 Lecture 8 Inheritance Richard Gesick Figures from Deitel, “Visual C#”, Pearson.
Java Inheritance. What is inherited A subclass inherits variables and methods from its superclass and all of its ancestors. The subclass can use these.
C++ Inheritance Systems Programming.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
ASP.NET Programming with C# and SQL Server First Edition
Review of C++ Programming Part II Sheng-Fang Huang.
Dale Roberts Object Oriented Programming using Java - Class Constructors Dale Roberts, Lecturer Computer Science, IUPUI Department.
Object-Oriented Programming: Inheritance Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Object-Oriented Programming: Inheritance
Object Based Programming. Summary Slide  Instantiating An Object  Encapsulation  Inheritance  Polymorphism –Overriding Methods –Overloading vs. Overriding.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
Chapter 8 More Object Concepts
Object Oriented Concepts
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
More about Class 靜宜大學資工系 蔡奇偉副教授 ©2011. 大綱 Instance Class Members Class members can be associated with an instance of the class or with the class as a.
Object Based Programming Chapter 8. 2 In This Chapter We will learn about classes Garbage Collection Data Abstraction and encapsulation.
Android How to Program, 2/e © Copyright by Pearson Education, Inc. All Rights Reserved.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
 Classes in c++ Presentation Topic  A collection of objects with same properties and functions is known as class. A class is used to define the characteristics.
Visual C# 2012 for Programmers © by Pearson Education, Inc. All Rights Reserved.
Visual C# 2012 for Programmers © by Pearson Education, Inc. All Rights Reserved.
C# Classes and Inheritance CNS 3260 C#.NET Software Development.
CSCI 3327 Visual Basic Chapter 9: Object-Oriented Programming: Classes and Objects UTPA – Fall 2011.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
1 Chapter Four Creating and Using Classes. 2 Objectives Learn about class concepts How to create a class from which objects can be instantiated Learn.
Dale Roberts Object Oriented Programming using Java - Final and Static Keywords Dale Roberts, Lecturer Computer Science, IUPUI
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Chapter 3 (B) 3.5 – 3.7.  Variables declared in a function definition’s body are known as local variables and can be used only from the line of their.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
Object-Based Programming in VB.NET. Must Understand Following: Encapsulation Information hiding Abstract Data Type Class, Instance, Reference Variable.
Classes, Interfaces and Packages
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Object-Oriented Programming: Inheritance and Polymorphism.
Chapter 2 11/18/2015 © by Pearson Education, Inc. All Rights Reserved. Lect9 GC 2011.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
Jozef Goetz Credits: Copyright  Pearson Education, Inc. All rights reserved. expanded by J. Goetz, 2016.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
CSCI 3328 Object Oriented Programming in C# Chapter 6: Methods – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX 78539
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley.
Object-Oriented Programming: Classes and Objects Chapter 1 1.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 7: Introduction to Object- Oriented Programming in Python – Exercises Xiang Lian The University of.
C# Programming: From Problem Analysis to Program Design1 Creating Your Own Classes C# Programming: From Problem Analysis to Program Design 4th Edition.
Part -1 © by Pearson Education, Inc. All Rights Reserved.
Object Based Programming Chapter 8. 2 Contrast ____________________ Languages –Action oriented –Concentrate on writing ________________ –Data supports.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Classes (Part 1) Lecture 3
Object-Oriented Programming: Classes and Objects
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
The University of Texas Rio Grande Valley
Object Based Programming
Classes & Objects: Examples
CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look – Exercises UTPA – Fall 2012 This set of slides is revised from.
CSCI 3328 Object Oriented Programming in C# Review: Exam I
The University of Texas Rio Grande Valley
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Review: Exam II
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
The University of Texas – Pan American
CIS 199 Final Review.
Inheritance in C++ Inheritance Protected Section
Presentation transcript:

CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX

Objectives In this chapter, you will do some exercises about: – classes and objects – Keywords such as this, static, readonly 2

Multiple Choices A static method in the string class, called _______, is similar to method Console.Write, but returns a formatted string rather than displaying a string in a console window. – A. ToString B. Format C. WriteLine D. Static If a method contains a local variable with the same name as one of its class's fields, the local variable ________ the field in that method's scope. – A. removes B. replaces the memory of C. hides D. is hidden by The ______ is called by the garbage collector just before it reclaims an object's memory. – A. constructor B. method C. destructor D. variable If a class declares constructors, the compiler will not create a(n) __. – A. method B. default constructor C. destructor D. variable An object's _______method can be called implicitly when an object appears in code where a string is needed. – A. constructor B. destructor C. ToString D. [ ] 3

Multiple Choices (cont'd) A(n) _____ variable represents classwide information that is shared by all the objects of the class. – A. object B. private C. static D. public Declaring an instance variable with keyword _____ specifies that the variable is not modifiable. – A. static B. private C. readonly D. ref Properties can contain both ______accessors. – A. return and value B. get and value C. get and set D. set and return Keyword _____introduces a class definition. – A. newclass B. classdef C. VC#class D. class 4

Multiple Choices (cont'd) A class can yield many _____, just as a primitive data type can yield many values – A. names B. objects (instances) C. values D. types Variables can be initialized ____. – A. when they are declared B. to their default values C. in a constructor D. All of the above Instance variables declared private are not accessible_____. – A. outside the class B. by other methods of the same class C. inside the same class D. All of the above. 5

True/False Statements You can use properties of an object in the select clause of an LINQ query. An object initializer first calls the class's constructor, then assigns the specified property values. Base-class constructors are not inherited by derived classes. Inheritance encourages the reuse of proven high-quality software. 6

True/False Statements (cont'd) When a derived class redefines a base-class method, by using the same signature and return type, the derived class is said to overload that base-class method. A base class's private members are accessible anywhere that the application has a reference to an object of that base class or to an object of any of its derived classes. When an object of a derived class is instantiated, a base class constructor is called implicitly or explicitly. Derived-class constructors can call base class constructors via the base keyword. 7

8