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.

Slides:



Advertisements
Similar presentations
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,
Advertisements

CS 211 Inheritance AAA.
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.
Dale Roberts Object Oriented Programming using Java - Class Constructors Dale Roberts, Lecturer Computer Science, IUPUI Department.
Chapter 8 More Object 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.
Object Based Programming Chapter 8. 2 In This Chapter We will learn about classes Garbage Collection Data Abstraction and encapsulation.
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.
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.
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.
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.
Classes, Interfaces and Packages
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
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.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 7: Introduction to Object- Oriented Programming in Python – Exercises Xiang Lian The University of.
Object Based Programming Chapter 8. 2 Contrast ____________________ Languages –Action oriented –Concentrate on writing ________________ –Data supports.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Creating Your Own Classes
Classes (Part 1) Lecture 3
Classes and Objects: A Deeper Look
Examples of Classes & Objects
Object-Oriented Programming: Classes and Objects
Inheritance and Polymorphism
Object Oriented Programming using Java - Class Instance Variables
Microsoft Visual Basic 2005: Reloaded Second Edition
Object-Oriented Programming: Classes and Objects
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
The University of Texas – Pan American
The University of Texas Rio Grande Valley
Object-Oriented Programming: Inheritance
Object Based Programming
Chapter 9 Object-Oriented Programming: Inheritance
Chapter 9 Classes: A Deeper Look, Part 1
IFS410: Advanced Analysis and Design
Lecture 22 Inheritance Richard Gesick.
Classes & Objects: Examples
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
CSCI 3327 Visual Basic Review: Final Exam
The University of Texas – Pan American
The University of Texas Rio Grande Valley
Object Oriented Programming in java
CSCI 3328 Object Oriented Programming in C# Review: Exam II
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II – Exercises UTPA – Fall 2012 This set of slides is revised from.
Week 4 Object-based Programming (2) Classes and Objects: A Deeper Look
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects – Exercises UTPA – Fall 2012 This set of slides is revised.
The University of Texas – Pan American
CSCI 3327 Visual Basic Review: Exam I
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Chapter 6: Methods
Object-Oriented Programming: Classes and Objects
Object-Oriented Programming: Inheritance and Polymorphism
CSCI 3328 Object Oriented Programming in C# Chapter 9: Classes and Objects: A Deeper Look UTPA – Fall 2012 This set of slides is revised from lecture.
CSCI 3328 Object Oriented Programming in C# Review: Final Exam
Building Java Programs
Fundaments of Game Design
CIS 199 Final Review.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
Classes and Objects Systems Programming.
CSCI 3328 Object Oriented Programming in C# Review: Exam II
CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays – Exercises UTPA – Fall 2012 This set of slides is revised from lecture slides of Prof.
Presentation transcript:

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 lecture slides of Prof. John Abraham. -- Xiang Lian

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

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. [ ]

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

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.

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.

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. base.ToString();