EECS 348 Exam 2

Ace your homework & exams now with Quizwiz!

Which of the following UML diagrams would you use to organize elements into groups?

Package

Abstraction

Present a problem and solution at appropriate levels of simplicity

reference architecture

Sets a standardized framework and best practices. Used as a reference for designing systems. Balances flexability and standardization.

Software architecture is represented in terms of:

Software components, connectors, config (topology)

pure polymorphism

Binding at compile time, overriding in class inheritance

Which statement allows you to quit and leave a loop in C?

Break statement

Composability

Build software elements so that they may be freely combined with others to produce new software

What is the result after execution of the following code if a is 10, b is 5, and c is 10? If ((a > b) && (a <= c)) a = a + 1; else c = c+1;

a = 11, c = 10

The continue statement, when executed in one of the loop statements, skips any remaining statement in the body of the loop and executions continue with the first statement after the loop.

False

The following UML multiplicity expressions are the same: 0..1 and 1

False

The following is a correctly formed statement: int i; cin >> i; if (n >= 1 <= 10) printf("n is between 1 and 10\n");

False

How many times will the following loop execute? for(int j = 1; j <= 10; j = j-1) { }

Forever

What will the following program print? #include <stdio.h> int main() { int x = 1; if (x = 5) printf ("Hello!"); else printf ("Bye!"); }

Hello!

Goal

High cohesion and low coupling

Coupling

Interdependence between different modules. They depend a lot on each other

Cohesion

Interdependence of elements of one module. All elements essential to a function are contained in one module

Describe the behavior of the following program? #include<stdio.h> int main() { int n; for(n = 7; n!=0; n--) printf("n = %d", n--); return 0; }

It is an infinite loop

Characteristics of a good test case

Must have unique identifier, clear purpose, defined pre conditions,specified inputs and expected outputs

A UML class is divided into which of the following compartments?

Name compartment , Not Selected Operation compartment , Not Selected Attribute compartment , Not Selected Correct answer: All of the above

Architectural styles

Named set of architectural design decisions

The expression: !(n < 5)

None of the above.

Consider the following code fragment: int grade;cin >> grade; // Assume 88 is entered so the grade=88 if (grade >= 90) if (grade == 100) printf ("Perfect! \n"); else printf ("Work harder.\n");

Nothing is printed

Fan-in

Number of UNITS that use a particular software

Fan-out

Number of units used by a particular software

Fault

Occurs when a human makes a mistake

A "switch" statement is used to

Switch from one variable to another variable Jump from one place to another in a program Switch between user defined functions in a program Correct answer: None of the above

Find the error in the following program fragment; assume n is a correctly defined integer. if (n % 2 == 0); printf("n is even\n");

Syntactically, the program is OK but semantically, the first semicolon is extraneous.

Decomposability

System can be deconstructed and studied as discreet subsystems, sub-processes, and activities

Domain specific software architectures

Tailored architectures for specific domains. Focus on reusable components and domain standards

Statement Coverage

Test cases that execute all lines of code

Decision coverage

Testing all conditional statements

White box testing

Testing based on an analysis of the internal structure of the component or system.

Regression testing

Testing existing software functionalities after changes to ensure no new defects

Integration testing

Testing of combined parts of an application to determine if they function together correctly.

Black Box Testing

Testing without and knowledge of the internal workings of an application

Condition Coverage

Tests each individual condition in a conditional statement

Multiple condition coverage

Tests every possible combination of conditions

Which of the following is true for a do-while loop?

The body of the loop executes least once.

Which of the following statements is true?

The default case is optional in the switch statement.

Which of the following statements about the main function is incorrect?

The main function must call at least one other function

Modularity

The subdivision of a computer program into separate subprograms

What will the value of the count be after the following code snippet? int count = 0; for (int i = 0; i <= 32; i *= 2) { count++; }

This is an infinity loop and will not terminate

What is the output when the following code fragment is executed? char ch; char title[] = "Titanic"; ch = title[1]; title[3] = ch; cout << title << endl;

Titinic

What's the objective of testing?

To find defects in the code

Because child classes in generalizations inherit the attributes, operations, and relationships of the parent, you must only define for the child the attributes, operations, or relationships that are distinct from the parent.

True

C/C++ support call by value and call by reference.

True

If c1 contains the value 'C' and c2 contains the value 'K', the value of the expression (c1 <= c2) is 1.

True

The compilation refers to the translation of a program written in a source language into a semantically equivalent program written in a target language.

True

The following statements are equivalent: if (X > Y) Z = 1; else Z = 0; Z = X > Y;

True

The preprocessor handles all directives in a C++ program.

True

To limit the scope of a variable (or a function) to a file, the static storage class is used.

True

Type qualifier const indicates that an object should not be modified after it is initialized.

True

An integer division like 7/3 results in

Truncating the fractional part

Data Definition Language (DDL)

Used by the DBA and database designers to specify the conceptual schema of a database; to define views

Which of the following is not a valid array declaration in C/C++?

double myArray = {1.0, 2.0, 3.0};

What is the semantically correct construction of a for loop?

for (initialization; condition; increment/decrement) statement;

What output does the following program fragment produce? int i = 1; switch (i % 3) { case 0: printf("zero"); case 1: printf("one"); case 2: printf("two"); }

onetwo

Software Architecture

the set of principal design decisions about the system

In C/C++, an array index can be a negative, zero, or positive number.

False

What will the result of num1 variable after execution of the following statements? int j = 1, num1 = 4; while (++j <= 10) { num1++; }

13

Header files

Can be included to a program Contain function declarations End with .h extension Correct answer: All of these

What will the value of x be? float x; int num = 42; x = num / 4 + 3.0;

13.0

Which operator has the highest priority?

++

Data Manipulation Language (DML)

- Used to specify database retrievals and updates - DML commands can be embedded in a general-purpose programming language (e.g., C++)

What will be the output of the following C program? #include <stdio.h> int main() { int x[5] = { 10, 20, 30 }; printf("%d", x[3]); return 0; }

0

Match the operators to their descriptions 1. % 2. & 3. * 4. ::

1. modulus operator. 2. Address Operator 3. Pointer Operator 4. Scope resolution operator

What is the final value of i when the code is run: for(int i=0; i<10; i++) ;

10

Which of the following is not a legal C/C++ identifier?

10_counters

What is the final value of a? int a = 10, b = 11, c = 5; if ((a!=b) && (a<b)) a++; else a = c;

11

What will be the output of the following C code? #include <stdio.h> int main(){ int a = 11; while (a < 20) { printf("%d ", a); a += 2; } return 0; }

11 13 15 17 19

What will be the output of the following C code? void main() { int x = 10; int y = x++ + 20; printf("%d,%d",x,y); return 0; }

11, 30

What will be the output of the following C program? #include <stdio.h> int myFunc(int x) { return (--x); } int main(){ int a = myFunc(13); printf("%d", a); return 0; }

12

What will the values of p, r, and x be respectively? All three variables are integer. #include <stdio.h> int main() { int p, r, x; p = r = x = 5; p *= x++; r = ++x + x; printf("%d %d %d \n", p, r, x); }

25 14 7

What will be the output of the following C++ code fragment? #include <stdio.h> #include<iostream> using namespace std; int main () { int array[] = {0, 2, 4, 6, 7, 5, 3}; int n, result = 0; for (n = 0; n < 7; n++) { result += array[n]; } cout << result; return 0; }

27

Which of the following is an example of a user-defined data type?

Class

What is the value of X after the following code fragment? int x = 5; if (x < 0) if (x > 10) x = x * 2; else x = x * 10;

5

What is the result of number of the code snippet? int number = 3; switch(number) { case 3: number++; case 2: number++; case 1: number++; default: number++; }

7

What is the output of the following C++ code snippet? #include<iostream> using namespace std; int main() { int arr[3][3] = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; cout << arr[2][1] << endl; return 0; }

8

Modified Condition/Decision Coverage (MC/DC)

A Software testing technique emphasizing on testing each condition with a decision statement

test coverage

A measure used to describe the degree to which the source code of a program is executed when a particular test suite runs

Which of the following data types is used to store a memory address in C/C++?

A pointer type

Criteria Subsumption

A test criterion C1 subsumes C2 if and only if every set of test cases that satisfies criterion C1 also satisfies C2

Which of the following C statements is syntactically incorrect?

All are syntactically correct

Defect

An error in coding logic

What does a class in C++ holds?

Data and functions (methods)

regular expression (regex)

Defines a pattern for text matching, searching and replacing

Failure

Departure from the systems required behavior

Software component

Encapsulates a subset of the system's functionality and/or data

An array subscript (index) can be of any data type.

False

C++ operators like + cannot be overloaded.

False

Every return statement must be followed by an expression.

False

What will be the output of the following C code? #include <stdio.h> int main(){ char grade = 'B'; switch (grade) { case 'A': printf("Excellent!\n"); case 'B': case 'C': printf("Well done\n"); case 'D': printf("You passed\n"); case 'F': printf("Better try again\n"); break; default: printf("Invalid grade\n"); } }

You passed , Not Selected Better try again , Not Selected Well done , Not Selected Correct answer: All of these

Which is correct with respect to the size of the data types in C?

char < int < double

EC 10 points] Write a C function to check whether the string s is a palindrome. Return 1 if s is a palindrome; return zero if it is not. You may assume that s is an array of 100 characters. int Palindrome(char s[]) { // Palindrome code }

write it out

Write a function, print_squares, that takes one integer parameter, n, and prints all even squares between 1 to n. For example, n is 100, the function should print the following: 4 16 36 64 100

write it out

[EC 10 points] Write a single expression whose value is either -1, 0, or +1, depending on whether i is less than, equal to, or greater than j, respectively. The variables i and j can be any type of variables, but for simplicity assume they are integer variables with values 5 and 10 respectively. This is a slightly tricky question. Hint: the question is asking for an expression, not a statement int i = t, j = 10;

write it out


Related study sets

ATI: RN Priority-Setting Frameworks Assessment 2.0

View Set

NUR ATI 3262-1 thru 3262-6/Finals Exam1-3/Kahoot/Fluid and electrolyte and ABG

View Set

NOT FINISHED--CHECK ANSWERS Grammar Unit 3: Linking Verbs & Predicate Words: Write the verb, then write AV if it is an action verb or LV if it is a linking verb.

View Set

Data Structures - Open Addressing - Add/Remove/Load Factor

View Set

Simulation Lab 1.2: Module 01 Install MS Security Scanner and Look for Malware

View Set