Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

1 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

2 Objectives In this chapter, you will
Do some exercises about classes and objects in C#

3 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

4 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);

5 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

6 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

7


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

Similar presentations


Ads by Google