CS246 Object Oriented Test 1

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What are the non-structured programming languages?

FORTRAN, BASIC, COBOL (old version)

How does function overloading use a common name?

The common name allows a general action and the different arguments let the compiler choose the specific method

How does the compiler know which function to call if a function is overloaded?

The compiler knows which function to call by its argument type

What is the general form for inheritance?

class derived-class: access base-class { body of new class }

How can using exclusively structured/procedural programming techniques be described?

"Code acting on data"

How can object-oriented programs be described?

"Data controlling access to the code"

What is polymorphism?

"One interface, multiple methods." Allows one interface to control access to a general class of actions.

What are functions and variables in a class called?

Member functions and member variables/data members

<iostream> vs. stdio.h

Modern C++ does not use the .h header extension.

When was the committee established to create an ANSI C standard?

Summer 1973

What is Standard C++?

The ANSI/ISO standard for C++ from 1998

What are the C-like features of C++ called?

The C-subset

What is the STL?

The STL is a set of generic subroutines that you can use to manipulate date. Powerful, elegant, large

What did the C99 committee focus on?

The addition of several new numeric libraries and several special use features (eg variable length arrays and restrict pointers)

What is the name for the most general class?

The base class

What is C++'s most important feature?

The class is C++'s most important feature

What is the same from C to C++?

return 0, strings, backslash characters

What file extension does C traditionally use?

.C

What file extension does C++ traditionally use?

.CPP

What is the limit of a C code?

25,000-100,000 lines max of code

How long did the C standardization process take?

6 years

What is the scope resolution operator and how is it used?

:: is the scope resolution operator and it is used to tell that a function is in the scope of a class. Used when coding a member function

What was C invented and implemented on?

A DEC PDP-11 with a UNIX operating system

What does a class create?

A class creates a new data type that may be used to create objects of that type

What is a class?

A class is a general form of an object. Keyword: class

How can classes and objects be described in relation to each other?

A class is a logical abstraction and an object is a real instance of a class

What is a code block?

A code block is a logically connected group of program statements that is treated as a unit

What is the use of a constructor function?

A constructor function allows objects to initialize themselves when they are created

What does a derived class have access to?

A derived class has access to both its own members and the *public members* of the base-class

What is the complement of a constructor?

A destructor

What are reasons to have a destructor?

A destructor can free allocated memory or close a file

When is a destructor called?

A destructor is automatically called when an object is destroyed

What is the definition of a constructor?

A special function that is a member of a class and has the same name as that class EX: stack::stack()

What does using the namespace std allow?

After the using namespace std statement, there is no difference in working with an old style header or a new one

Who created the standard template library?

Alexander Stepanov

Who invented the C language?

Bjarne Stroustrup

Who invented the first C++ extensions?Where? When?

Bjarne Stroutrup; Bell Labs; Murray Hill, NJ

What is a class by default?

By default, all parts of a class are private, though they can be declared to be public

What makes C special as a mid level language?

C can manipulate bit, bytes, words, pointers, and addresses

What level programming language is C?

C is a middle level language

int main() vs int main(void)

C++ function parameters are void by default, making int main(void) redundant and unnecessary

What does C++ include from C?

C++ includes the entire C language

What is the version of C adopted in 1989 commonly referred to as?

C89

What was the updated version of C called?

C99

What is an object?

Code and data linked together for manipulation

What is the distinguishing feature of a structured language?

Compartmentalization, the ability of a language to section off and hide from the rest of the program to perform specific tasks

What return type does a constructor have?

Constructors cannot return values, and thus have no return type

When was ANSI C finally adopted?

December of 1989

What is encapsulation?

Encapsulation is the mechanism that binds code and the data it manipulates in such a way that both are safe from interference and misuse. Keeps code together and safe

What three traits are common to all OOPL

Encapsulation, polymorphism, and inheritance

Why should you avoid global variables?

Excessive use of global variables may allow bugs to creep into a program by causing unwanted side effects

How does function overloading work?

Function overloading allows two functions or more functions to have the same name as long as their parameters are different.

Who is the author of The Complete Reference of C++?

Herbert Schildt

Why is Herbert Schildt a trustworthy authority?

Herbert Shildt is a leading authority on C, C++, C#, Java, and a master Windows programmer.

What is the difference in function prototyping between C and C++?

In C function prototypes are optional; in C++, function prototypes are required

What does C++ do with defaulting to int?

In C89 and original C++ used default to int, but modern C++ dropped this rule

Where must local variables be declared?

In C89 you must declare local variables at the start of a block. In C99 and C++, variables can be declared at any point within a block

When was C invented?

In the 1970's

What caused the need for C++?

Increasing complexity of programs

using namespace std;

Informs the compiler you want to use standard namespace.

How is inheritance supported?

Inheritance is supported by allowing one class to incorporate another class into its declaration

What does inheritance support?

Inheritance supports classification base ^ | derived

What are the new C++ includes?

Instead of using a .h, use <>, for example math.h-> <cmath>. The old header styles still exist in older c++ but are now obsolete

How is a destructor coded?

It also has no return type and uses the ~ character. EX: stack::~stack()

What was the predecessor of C and who invented that language?

Ken Thompson invented B, the predecessor of C

What keyword must be used to make parts of a class accessible to other parts of the program?

Keyword: public:

What is a namespace?

Namespaces help in the organization of a large program by allowing access to C++ libraries and providing a space for declaring various program elements

How do C++ compilers handle default to int?

Nearly all c++ compilers still support default to int but it is not good practice to use this feature as it is technically no longer allowed

Are any of the C99 innovations in the C++ standard?

No

Has C++ replaced C?

No, C is still alive and well

Is polymorphism specific to C++?

No, all languages have some form of polymorphism in varying degrees

Is the access part of the inheritance form necessary?

No, but if included it must be private, public, or protected

Must function overloading only be used on related functions?

No, it can be used on unrelated function but should not to avoid confusion

What is OODB?

Object-oriented data base

What is OOP?

Object-oriented programming

What is OOPL?

Object-oriented programming languages

How does polymorphism work?

Only the compiler has to handle the specific action; the programmer only has to remember the general interface

What are some other terms to describe base/derived classes?

Parent/child, Superclass/subclass

What are the structured programming languages?

Pascal, Ada, Java, C#, C++, C, Modula-2

What is private code/data?

Private data/code is only accessible by another part of the object

What is a private part of a class?

Private data/functions of a class cannot be accessed by any member that is not a member of that class

How can private members be accessed?

Private members can only be accessed by functions that are members of that object. object.private_member does not work. Have to use object.public_function()

How should private variables be handled?

Private variables should be accessed using public functions.

What is inheritance?

Process where one object inherits the properties of another

What is public data/code?

Public data/code is accessible by the entire program

What is the name for the more specific class?

The derived class

What is the hierarchy of inheritance?

The hierarchy of classes goes from most general to most specific

What must differ in an overloaded function?

The number and/or type of arguments must differ. A different return type is not enough

Are structured programs limited?

They are limited by a programs size. They cannot handle very large programs

What are the two ways programs can be organized?

They can be organized around their code or around their data

How many major revisions has C++ undergone?

Three: 1985, 1990, standardization of C++ 1998

What is the purpose of a namespace?

To localize the names of identifiers to avoid name collisions

What is one way to achieve compartmentalization?

Use subroutines that use local/temporary variables

Should variables be public or private? Why?

Variables can be public but should be private to support encapsulation.

How does overloading an operator work?

When an operator is overloaded, it takes on an additional meaning relative to a certain class

cout<</cin>> vs. printf()/scanf()

While printf()/scanf() can still be used, cout<</cin>> are preferred. NOTE: LEFT AND RIGHT SHIFT ARE OVERLOADED

What is the major advantage of inheritance?

You can create a general class that can be incorporated into more specific ones

Why should you use temporary variables?

You can write a subroutine that will not cause side effects on the rest of your program

When coding a function for a class, what must you do?

You have to tell the compiler which class it is a member of

How must you reference a member of a class in code that is not part of that class?

You must refer to the member in conjunction with an object of that class. object.member


Kaugnay na mga set ng pag-aaral

CHAPTER 11. The Philippine-American War

View Set

Honors 9th grade Lit. - Poetic Devices Quiz

View Set

Vocabulary Workshop Level G Unit 7 Synonyms and Antonyms Practice

View Set

Chapter 1 Quiz- Money and Banking

View Set

словарь переводческих терминов

View Set

AMH1010: Give Me Liberty Chapter 8 Review Quiz

View Set

Developmental Stages: Early and Late Adulthood

View Set

MGMT 3720 CH 17, MGMT Exam 4(Ch. 14, 15, 16. 18)

View Set

9. Magyarország a világháborúk korában fogalmak

View Set