CS320 Midterm 1

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Why do we define classes in object oriented programming languages?

To create new data types and new abstractions.

In C, why did the designers choose to not implement the data type string?

C does not support OOP

Describe the purpose of pointers.

Allows for data to be referenced(shared) by other things (functions) that requires access. Allows for large set of data to be referenced without explicitly naming each one.

Why do multiple programming language exist?

Different languages express different ideas well resulting in languages suited for different tasks.

Why do we use malloc and new?

Dynamically allocate memory on the heap.

All programing languages share the same fundamental types. (True or False)

False

Shell scripting languages only run on Unix/Linux/BSD machines. True or False?

False

In C, why did the designers choose to require a format string as an argument to scanf?

Format strings tell the function how to attenmpt to interpret the data provide.

What language features would you look for when developing a large scale project? Also indicate why for each.

Object oriented programming - allows groups to work effectively and protects implementations inadvertent misuses.

Which of the following statements is true about an Object?

Objects must be built from classes.

Where do local variables have their memory placed by compilers ( in most languages)?

On the stack.

What is the purpose of shell scripting languages?

Organizing the actions of many smaller purpose driven applications to accomplish larger tasks.

What is scope?

Scope is the region in which a variables name is valid for use.

When organizing the actions of several programs it is often useful to write programs using:

Shell scripting

Why would you want to specify a memory allocation on the heap in C/C++?

So that it is available after the function finishes.

Why do we typically write Operating Systems in C, instead of an OOP language like C++ or Java? (One good reason is enough. There are a couple of fairly straight forward answers.)

We want to keep as close to the bare metal abstractions as possible. We do not always want to introduce new abstractions to these concepts.

When and why would you use a shell scripting language?

When: if a program is solvable using a collection of smaller tools. Why: faster to implement. Reliability of existing code base.

Given a text processing problem should we always always use shell language like bash?

Yes, bash handles strings well and will always solve the problem better than you could.

In C, as a programmer, using char arrays instead of strings has a unique benefit. What is it?

You can break the abstraction of the ascii characters and use them as either numbers or characters.

Why do most languages prevent you from accessing variables declared in other functions?

A variable's value is typically placed on the stack, and when a function finishes the stack changes resulting in the value at the memory location no longer being saved for that variable(which means it may be used for something else)

In C/C++, why is it not appropriate to return a reference to a local variable?

After the function returns the stacks memory may be overwritten.

Give at least one way that text based interfaces in OS ( such as a Shell) benefit the end user.

Automation is simpler

How is C different than C++?

C requires thinking primarily in terms of actions, whereas C++ allows us to think in terms of things.

Which of the following are true statements? a. C and C++ provide the same abstractions. b. C++ and Java provide the same abstractions. c. C and C++ are essentially the same language, C++ just adds OOP. d. Being a good C programmer means I will create good C++ abstractions.

C++ and Java provide the same abstractions. C and C++ are essentially the same language, C++ just adds OOP.

What would cause a program we wrote in Java to run slower than a program we wrote in C/C++?

C/C++ code can break abstractions, requiring less code to do certain tasks at a low level. We aren't necessarily very good programmers, and our implementations have flaws. Java requires a virtual machine that would have to interpret the java byte code.

How do we create new data representations of the ones and zeros in Object Oriented Programming Languages?

Define a class

Defining a class in object oriented language does what?

Defines a novel data type that the compiler can now work with.

Describe the pertinent differences between the C++ new and the C malloc.

New is more type safe than malloc. New ensures that data is initialized by the constructor.

Why are shell scripting languages usually not appropriate for large scale applications?

Interpreter does not provide very good debugging information.

Which of the following is MOST important when selecting a language for a project/application?

It depends. There is no single correct answer above.

Why would an organization choose to write an application in Java?

It is capable of running on multiple platforms without rewriting the code. It is capable of implementing very large software projects because of its design features. It has a large number of libraries built in that simplify many tasks.

Why would we write a program in Java that would run faster than a program written in C/C++?

Java contains many packages that may implement a optimized version of an algorithm. We aren't necessarily very good programmers, and our implementations have flaws. Java has a restricted syntax/usage preventing us from using less than ideal implementations.

Why is C typically considered to be a "faster" language in Java?

Java typically requires a virtual machine to execute its byte code. The java libraries are not well implemented Java is a higher level language that requires more processing time to provide the higher level abstractions.

What is the purpose of pointers?

Pointers allow you to access many elements of the data through a single variable name. Pointers allows different sections of programs to have access to the same memory.

What is a result of local variables having their memory placed by compilers onto the heap?

Variables have limited scope

How are large scale project (like Operating Systems) developed in C without OOP?

The problem is broken up into smaller chunks with purpose driven software written for each chunk.

What are the advantages to using a strictly typed language?

The type of input data to a function can be guaranteed. The amount of memory to be allocated on the stack is known before hand.

When would large scale projects (like Operating Systems) use a scripting language during development?

To automate certain parts of the build/compile system. To automate a test suite to prevent regression errors. (Run a test suite to check for errors)

Why do we use shell scripting languages?

To organize the execution of several different programs at once. To automate complex or repetitive tasks.

When language designers make new programming languages, they typically design the language such that variables have limited scope. Why do they choose to make variables have limited scope?

Two different functions/classes can use the same variable name without conflicts.

What discussing variables and values we often talk about using the correct type. What is a data type?

Types tell the compiler and the CPU how to interpret the ones and zeros in memory.

Why is it important for a programmer to understand scope?

Understand when variable will be available for use/how to access a piece of memory from another scope.

In C, as a programmer why must you specify a format string when using printf?

printf is written such that it requires the format string as input


संबंधित स्टडी सेट्स

Medical-surgical: gastrointestinal

View Set

WITHDRAWAL SYMPTOMS: Substance Abuse

View Set

Node.js Interview Questions - Advanced Level

View Set