INFO 3231 chapter 1

¡Supera tus tareas y exámenes ahora con Quizwiz!

How would you compare C# with Java?

C# is very similar to Java because Java was also based on C++. However, C# is more truly object-oriented. Unlike in Java, every piece of data in C# is an object, providing all data with increased functionality. In Java, simple data types are not objects; therefore, they do not work with built-in methods. Additionally, in Java, data can only be passed to and from methods using a copy; C# omits this limitation.

What are the components of a C# method?

Every method in C# contains a header and a body. A method header includes the method name and information about what will pass into and be returned from a method. The method body of every method is contained within a pair of curly braces and includes all the instructions executed by the method.

What are the features supported by object-oriented programming?

For a language to be considered object-oriented, it must support the following features: * Classes * Objects * Encapsulation and Interfaces * Inheritance * Polymorphism

Explain the concept of methods in object-oriented programming.

For convenience, the individual operations used in a computer program often are grouped into logical units called methods. For example, a series of four or five comparisons and calculations that together determine an employee's federal tax withholding value might be grouped as a method named CalculateFederalWithholding().

What is the meaning of the keyword static in C# in a method header?

In C#, the reserved keyword static indicates that the method will be executed through a class-not by a variety of objects. It means that you do not need to create an object to use the method; rather, the method is invoked using the class name.

Explain the main characteristics of inheritance.

Inheritance provides the ability to extend a class so as to create a more specific class. The more specific class contains all the attributes and methods of the more general class, and usually contains new attributes or methods as well. For example, if you have created a Dog class, you might then create a more specific class named ShowDog. Each instance of the ShowDog class would contain all the attributes and methods of a Dog, along with additional methods or attributes.

Explain the main characteristics of encapsulation.

Like procedural programs, object-oriented programs have variables (attributes) and procedures (methods), but the attributes and methods are encapsulated into objects that are then used much like real-world objects. Encapsulation is the technique of packaging an object's attributes and methods into a cohesive unit that can be used as an undivided entity. Programmers sometimes refer to encapsulation as using a "black box," a device you use without regard for the internal mechanisms. If an object's methods are well written, the user is unaware of the low-level details of how the methods are executed; in such a case, the user must understand only the interface or interaction between the method and object. For example, if you can fill your Automobile with gasoline, it is because you understand the interface between the gas pump nozzle and the vehicle's gas tank opening. You don't need to understand how the pump works or where the gas tank is located inside your vehicle. If you can read your speedometer, it does not matter how the display figure is calculated. In fact, if someone produces a new, more accurate speedometer and inserts it into your Automobile, you don't have to know or care how it operates, as long as the interface remains the same as the previous one. The same principles apply to well-constructed objects used in object-oriented programs.

What are the attributes and state of an object?

Object-oriented programming (OOP) is an extension of procedural programming. OOP uses variables and methods like procedural programs do, but it focuses on objects. An object is a concrete entity that has attributes and behaviors. The attributes of an object are the features it "has"; the values of an object's attributes constitute the state of the object. For example, attributes of a paycheck include its payee and monetary value, and the state of those attributes might be "Alice Nelson" and $400.

What are the types of comments supported by C#?

There are three types of comments in C#: * Line comments start with two forward slashes (//) and continue to the end of the current line. Line comments can appear on a line by themselves, or they can occupy part of a line following executable code. * Block comments start with a forward slash and an asterisk (/*) and end with an asterisk and a forward slash (*/ ). Block comments can appear on a line by themselves, on a line before executable code, or after executable code. When a comment is long, block comments can extend across as many lines as needed. * C# also supports a special type of comment used to create documentation from within a program. These comments, called XML-documentation format comments, use a special set of tags within angle brackets (<>). (XML stands for Extensible Markup Language.)

What are the requirements when choosing an identifier for a C# class?

You can define a C# class using any identifier you need, as long as it meets the following requirements: * An identifier must begin with an underscore, the "at" sign (@), or a letter. (Letters include foreign-alphabet letters, which are contained in the set of characters known as Unicode.) * An identifier can contain only letters, digits, underscores, and the "at" sign (@). It cannot contain spaces or any other punctuation or special characters such as #, $, or &. * An identifier cannot be a C# reserved keyword, such as class or void. (Actually, you can use a keyword as an identifier if you precede it with an "at" sign, as in @class. An identifier with an @ prefix is a verbatim identifier. This feature allows you to use code written in other languages that do not have the same set of reserved keywords. However, when you write original C# programs, you should not use the keywords as identifiers.)


Conjuntos de estudio relacionados

Evaluating & Selecting Sources: Quiz

View Set

General Biology 1 Quiz Questions Chapter 4 and 5

View Set

ECON175 - Ch. 2 Economic Models: Trade-offs and Trade

View Set

Swiss Reformation, Marburg Colloquy, and Anabaptists

View Set

CISSP - Chapter 2: Asset Security

View Set

History 1850 cumulative review 1

View Set