CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects – Exercises UTPA – Fall 2012 This set of slides is revised.

Slides:



Advertisements
Similar presentations
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall
Advertisements

Chapter 3 Introduction to Classes, Objects, Methods, and Strings
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 3: Control Structures (Part 1) – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
Introduction to Classes and Objects (Through Ch 5) Dr. John P. Abraham Professor UTPA.
Chapter 5 - Writing a Problem Domain Class Definition1 Chapter 5 Writing a Problem Domain Class Definition.
The University of Texas – Pan American
Object-Oriented Programming - Classes, Objects Methods, Strings 1 -Based on slides from Deitel & Associates, Inc. - Revised by T. A. Yang.
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects UTPA – Fall
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II UTPA – Fall
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
CS346 Javascript -3 Module 3 JavaScript Variables.
CSCI 3327 Visual Basic Chapter 9: Object-Oriented Programming: Classes and Objects UTPA – Fall 2011.
Chapter 4 Introduction to Classes, Objects, Methods and strings
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 3327 Visual Basic Chapter 6: More Examples of Methods UTPA – Fall 2011.
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.
AP Java Ch. 4 Review Question 1  Java methods can return only primitive types (int, double, boolean, etc).
CPSC 233 Tutorial 5 February 9 th /10 th, Java Classes Each Java class contains a set of instance variables and methods Instance Variables: Type.
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.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 7: Introduction to Object- Oriented Programming in Python – Exercises Xiang Lian The University of.
Chapter 3 Introduction to Classes, Objects Methods and Strings
3 Introduction to Classes and Objects.
Yanal Alahmad Java Workshop Yanal Alahmad
Yanal Alahmad Java Workshop Yanal Alahmad
Chapter 10: Void Functions
Chapter 3: Using Methods, Classes, and Objects
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
Chapter 2 Section 3.
The University of Texas – Pan American
The University of Texas – Pan American
The University of Texas Rio Grande Valley
Chapter 3 Introduction to Classes, Objects Methods and Strings
The University of Texas Rio Grande Valley
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I UTPA – Fall 2012 This set of slides is revised from lecture slides.
Chapter 3 Introduction to Classes, Objects Methods and Strings
The University of Texas – Pan American
The University of Texas – Pan American
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections
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 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.
The University of Texas – Pan American
The University of Texas – Pan American
CSCI 3327 Visual Basic Review: Final Exam
The University of Texas – Pan American
The University of Texas Rio Grande Valley
More on Classes and Objects
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.
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects UTPA – Fall 2012 This set of slides is revised from lecture.
The University of Texas – Pan American
CSCI 3328 Object Oriented Programming in C# Chapter 11: Files and Streams -- Exercises UTPA – Fall 2012 This set of slides is revised from lecture slides.
The University of Texas – Pan American
CSCI 3327 Visual Basic Review: Exam I
The University of Texas – Pan American
CSCI 3327 Visual Basic Chapter 6: Methods: A Deeper Look
CSCI 3328 Object Oriented Programming in C# Chapter 7: Arrays
CSCI 3328 Object Oriented Programming in C# Chapter 6: Methods
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.
Chapter 2 Section 3.
Object Oriented Programming in java
Java Programming Language
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.
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.
CSCI 3328 Object Oriented Programming in C# Review: Exam I
Presentation transcript:

CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects – 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 in C#

Multiple Choices A class can have __________ object(s). A. only 1 B. only 2 C. between 1 and 3 D. more than 1 Every class declaration contains keyword ____ followed immediately by the class’s name A. keyword B. public C. void D. class Which of the following statements is true to create a new object of class MyClass in C#? A. MyClass obj = new MyClass () B. MyClass obj = new MyClass ; C. MyClass *obj = new MyClass (); D. MyClass obj = new MyClass (); C# provides the following simple types for storing real numbers except for ________. A. real B. float C. double D. decimal

Multiple Choices (cont'd) Which of the following statements is the correct usage of Convert in C#? A. Console.Convert(); B. Convert.ToDecimal(); C. Convert.ReadLine(); D. Convert.ToDecimal(Console.ReadLine()); Return type _______indicates that a method will not return any information when it completes its task. A. NULL B. Nil C. Void D. void Which of the following statements is correct? A. Console.WriteLine({0:C}, 3); B. Console. Write("Hello world!"); C. Console.ReadLine(x); D. Console.Read(x);

True or False Statements 1. By convention, method names begin with a lowercase first letter and all subsequent words in the name begin with a capital first letter 2. A property's get accessor enables a client to modify the value of the instance variable associated with the property 3. Empty parentheses following a method name in a method declaration indicate that the method does not require any parameters to perform its task

True or False Statements (cont'd) 4. After defining a property, you can use it the same way you use a method, but with empty parentheses, because no arguments are passed to a property 5. Variable declared in the body of a particular method are known as instance variables and can be used in all methods of the class 6. A property declaration must contain both a get accessor and a set accessor