OBJECT ORIENTED PROGRAMMING– 1ST EXAM Summer 2007 – July 12, 2007

Time

1 h 00 min

1. In the memory we could see the following array. Use this array to answer the questions below

1.1. The elements with zero values are: a. The second and 6th elements b. The 3rd and 7th elements c. The elements with index 2 and index 6 d. Both a & c e. Both b & c 1.2. The array has how many elements? a. 11 b. flexible

c. 12

d. 13

e. Cannot tell

1.3. It is possible to declare and fill the array using which statement(s): a. b. c. d. e. f. g. h.

int [] c float [] c double [] c uint [] c

= = = =

{-45, {-45, {-45, {-45,

6, 6, 6, 6,

0, 0, 0, 0,

72, 72, 72, 72,

1543, 1543, 1543, 1543,

-89, -89, -89, -89,

0, 0, 0, 0,

62, 62, 62, 62,

-3, -3, -3, -3,

1, 1, 1, 1,

6453, 6453, 6453, 6453,

78} 78} 78} 78}

a & d & c are possible Both a & b & c are possible All of the above None of the above

1.4. The value of k after the statement ( int k = c.Length; ) will be: a. NaN b. 11 c. 13 d. 12 e. 0 1.5. ( ) (T/F) The value of c[12]=78

f. None of the above

2. Multiple Choice 2.1. The statement ( float k = -1.0f/0.0f; ) will: i. Assign Infinity to k j. Assign NaN to k k. Cause a runtime error l. Assign –Infinity to k m. Assign 0 to k n. None of the above 2.2. The statement ( int k = -1/0; ) will: a. Assign Infinity to k b. Assign NaN to k c. Cause a runtime error d. Assign –Infinity to k e. Assign 0 to k f. None of the above 2.3. If two strings are to be read, they must be a. separated by semicolons b. separated by spaces c. each enclosed in quotes d. on separate lines 2.4. Reading an integer is done with a. Console.ReadLine(); Convert.ToInt32; b. Console.ReadLine(); Convert.ToInt16; c. Console.ReadLine(); Convert.ToInt8; d. Console.ReadLine(); Convert.ToDecimal; e. All of the above except (d) 2.5. To get access to the Console class, we start a program with which directive? a. access Console;

b. import Console;

c. using Console;

d. using System;

2.6. If the following is written in a program, what will happen? 1 2 3 4

a. b. c. d.

double[] a = new double[10]; for (int i=1; i<=10; i++) a[i] = i; Console.WriteLine("Completed");

Completed will be printed IndexOutOfRangeException will be raised Compilation error at line 3 because a is a double array Compilation error because a[0] does not have a value

2.7. What does IDE stand for? a. Integrated Design Enhancement b. Integrated Design Environment c. Integrated Development Environment d. Intensive Development Environment 2.8. How many elements are in the array SomeArray[10,5,20]? a. 684 b. 500 c. 1000 d. 35 e. 200

f. None of the above

2.9. How many elements are in the following array? int [] SomeJaggedArray = new int [10][]

a. 684

b. 500

c. 100

d. Cannot tell since the jagged rows are not shown

2.10. How many Vehicle objects are created in memory after the following code snippet int num = 8; Vehicle[] myCollection = new Vehicle[num]; a. 9

b. 8

c. 0

d. 7

2.11. If the following is written in a program, what will happen? int i = 3; int j = 0; Console.WriteLine("Answer = "+(i/j).ToString());

a. b. c. d.

Answer = 0 will be printed Answer = Infinity will be printed Answer = -Infinity will be printed An Exception will be raised by c#

2.12. How many rows are in the following array? int [] AnotherJaggedArray = new int [100][]

a. 684

b. 500

c. 100

d. Cannot tell since the jagged rows are not shown

2.13. What is the value of (201 % 4)? b. 1 a. 0

c. 2

d. 3

2.14. What punctuation character is used with a goto label? b. , c. : a. ;

d. !

2.15. What punctuation is used to separate multiple expressions in a for statement? a. ; b. , c. : d. ! 2.16. What command is used to jump to the next iteration of a loop? a. next b. break c. continue

d. exit

2.17. An array that can be used to keep the number of patients an emergency hospital sees every hour of the day would be declared as: a. b. c. d.

int[] tally = new int[24]; int[] tally = new int[23]; int[][] tally = new int[24][]; Patients[] tally = new Patients[24];

2.18. If myAge, a, and b are all int variables, what are their values after:

a. c.

myAge = 39; a = myAge++; b = ++myAge; myAge =39 , a =39 myAge =41 , a =40

, and b = 39 , and b = 41

b. myAge =41 d. myAge =41

, a =40 , a =39

, and b = 40 , and b = 41

2.19. To declare a jagged array with 4 rows and 1 more column than the row index (i.e. a triangle), we can use: (a)

int a[][]; for (int i=0; i<4; i++) int a[][i] = new int[4][i+1];

(b)

int a[][] = new int[4][]; for (int i=0; i<4; i++) a[i] = new int[i+1];

(c)

int a[][] = new int[4][Row+1];

(d)

int a[][] = new int[4][]; for (int i=0; i<4; i++) a[i] = new int[i];

3. True or False 3.1. ( ) (T/F) int [] C = new float[25];

is a valid array declaration.

3.2. ( ) (T/F) float [] C = new int[25];

is a valid array declaration.

3.3. ( ) (T/F) float [] C = new float[25]; 3.4. ( ) (T/F) char myInitial = “a”; initialization.

is a valid fixed-length array declaration.

is a valid char variable declaration and

3.5. ( ) (T/F) It is essential to have an understanding of a problem before writing a program to solve it. 3.6. ( ) (T/F) When writing a program, it is equally essential to understand the types of building blocks that are available and to employ proven program construction principles. 3.7. ( ) (T/F) The order of actions of an algorithm is not important. 3.8. ( ) (T/F) Program control is not vital () to the outcome of an application. 3.9. ( ) (T/F) The if structure is a repetition structure. 3.10. ( ) (T/F) The body of an if structure only executes if the condition is evaluated as true. 3.11. ( ) (T/F) It is required that a programmer indent the lines in the body of an if statement. 3.12. ( ) (T/F) Because the condition of a while structure is before the body, the body is executed only once after the condition becomes false. 3.13. ( ) (T/F) The cast operator performs a conversion between data types. 3.14. ( ) (T/F) Variables that store totals should be initialized before being used in a program. 3.15. ( ) (T/F) Variables other than counters need not be initialized to zero before being used in a program. 3.16. ( ) (T/F) The increment and decrement operators can be used on expressions such as: ++(x + 1)

3.17. ( ) (T/F) Unary operators should be placed next to their operands with no spaces. 3.18. ( ) (T/F) A variable used as a counter should be initialized when it is declared. 3.19. ( ) (T/F) Using a decrement in a for loop rather than an increment will always result in a logic error. 3.20. ( ) (T/F) If a while condition is never true, the body will never execute. 3.21. ( ) (T/F) for structures cannot be replaced as while structures. 3.22. ( ) (T/F) By default, a control variable that is declared in a for structure header may not be used outside of the body of the for structure. 3.23. ( ) (T/F) Only one control variable may be initialized, incremented or decremented in a for structure header. 3.24. ( ) (T/F) The Visual C# .NET operator ^ can be used for exponentiation. 3.25. ( ) (T/F) A cast operator is needed to convert values of type double to values of type Decimal. 3.26. ( ) (T/F) A default case must be provided for every switch statement. 3.27. ( ) (T/F) A case that consists of multiple lines must be enclosed in braces. 3.28. ( ) (T/F) A case with no statements is called an empty case, and only requires the break statement. 3.29. ( ) (T/F) The loop body of a do…while structure always executes at least once.

3.30. ( ) (T/F) In a while loop, the increment statement should always be placed after a continue statement. 3.31. ( ) (T/F) The break statement will cause the first statement after the structure to be executed. 3.32. ( ) (T/F) The statements break and continue are slow and inefficient. 3.33. ( ) (T/F) The && operator has higher precedence than the || operator. 3.34. ( ) (T/F) Visual C# .NET will not evaluate the second operand of a && statement if the first operand evaluates to true. 3.35. ( ) (T/F) The while statement is sufficient to perform any type of repetition. 3.36. ( ) (T/F) Arrays are data structures consisting of data items of different types. 3.37. ( ) (T/F) Arrays remain the same size once they are created. 3.38. ( ) (T/F) An array is a group of contiguous memory locations that all have the same name and type. 3.39. ( ) (T/F) The first element in every array is the zeroth element. 3.40. ( ) (T/F) An array must be declared and allocated in the same statement. 3.41. ( ) (T/F) A constant must be initialized in the same statement where it is declared and cannot be modified. 3.42. ( ) (T/F) Visual C# .NET performs bounds () checking to ensure the program doesn't access data outside the bounds of an array. 3.43. ( ) (T/F) Multi-dimensional arrays require two or more indices to identify particular elements. 3.44. ( ) (T/F) By convention, the first subscript of a double-subscripted array identifies an element's column and the second identifies the row. 3.45. ( ) (T/F) % Mod operator works on floating point types. 3.46. ( ) (T/F) We use unnecessary parentheses when precedence (   ) will determine which operators are acted on first to make the code easier to understand. 3.47. ( ) (T/F) Tabs, spaces, and new lines (known as whitespaces) have no effect on the program, although wise use of whitespace can make the program easier to read. 3.48. ( ) (T/F) The statements x = 3 and x == 3 can be used interchangeably (  ). 3.49. ( ) (T/F) A solution is a collection of one or more projects and related files in Visual Studio .NET. 3.50. ( ) (T/F) Visual C++, Visual Basic, and C# projects all can reside within the same solution? 3.51. ( ) (T/F) A variable is declared static in a class for the objects declared with the same class to share the value of this variable. 3.52. What is the result of 10 + 3 * 2? _____________ 3.53. What are the possible results of a conditional operation? ______________________ 3.54. Give three reasons why C# is a great choice of programming language. ____________________

____________________

_____________________

3.55. Briefly: What is the difference between a signed variable and an unsigned variable? _______________________________________________________________________

3.56. Link the character to its name: ^

Backslash

<

Ampersand

\

Tilde

|

Caret



Vertical, bar

&

Left angle bracket

~

Double quote

4. Bonus 4.1. A valid declaration for an enumerated type for some planets would be: a. type Planets = enum {Mercury, Mars, Venus, Earth}; b. enum Planets = {Mercury, Mars, Venus, Earth} c. enum Planets = {Mercury, Mars, Venus, Earth}; d. enum Planets {Mercury, Mars, Venus, Earth} 4.2. ( ) (T/F) It is not good programming practice to place a blank line between declarations and executable statements. 4.3. ( ) (T/F) Placing a space character between the symbols that compose an arithmetic assignment operator improves readability. 4.4. ( ) (T/F) Braces are normally included with do…while structures even when unnecessary to avoid confusion with while structures. 4.5. ( ) (T/F) A swap between two variables requires a third variable to act as a holder.

Time 1 h 00 min 1. In the memory we could see the ...

e. a & d & c are possible f. Both a & b & c are possible g. All of the above h. None of the above. 1.4. The value of k after the statement ( int k = c.Length; ) will be: a. NaN b. .... NET operator ^ can be used for exponentiation. 3.25. ( ) (T/F) A cast operator is needed to convert values of type double to values of type. Decimal. 3.26.

142KB Sizes 7 Downloads 138 Views

Recommend Documents

Page 1 MWe could not he executed our IPO in the timeframe We gift ...
offeri ngs company. The decreased ... BIO supports extending the disclosure rules, giving rise to ... BIO supports enhanced short often apply one-size-fits-all.

Page 1 MWe could not he executed our IPO in the timeframe We gift ...
offeri ngs company. The decreased regulatory burden under ... W at: companies. Proxy advisory firms. BIO supports enhanced short often apply one-size-fits-all.

1 min to 1-hr -
Particulate Monitor Design ... I wonder is anybody interested in kicking around a Particulate monitor design in detail? ... Humidity not specified on data sheet.

June 1, 2016 1:00 p.m. The Greenfield Township Trustees met in ...
The Greenfield Township Trustees met in special session at the Greenfield Township Firehouse to interview Fire Chief applicants. Dave Cotner moved to go into executive session to interview applicants. Lonnie Kosch seconded. All voted yes. Lonnie Kosc

April 5, 1:00 – 4:00 pm, in the Media Center/Learning ...
Apr 28, 2017 - HIGH SCHOOL ACADEMY. 800 Santa Fe Drive Encinitas, CA 92024. (760) 753-1121. Fax: (760) 943-3555 www.sd.sduhsd.net. Principal.

1 the fearless heart – adv. intermediate - 30 min - Libsyn
hands at heart. Figure Four w/ hands at heart ... Standing with hands to heart. Forward Fold. Mountain. Dancer ... Wild Thing twist. Firelog. Knees Into Chest.

Yoga for Cyclists #1 - 20 min. - Level 1 - 2 - Libsyn
Knees into Chest. Dead Bugs Pose. Baddha Konasana. Savasana. Bent Knee Hip Opener. Left Leg High. Down Dog. Half Lift. Forward Bend. Tadasana. Samasthiti. Forward Bend leggs crossed. Tadasana. Tadasana. Back Bend. Forward Bend. Down Dog. Half Lift. R

Yoga for Cyclists #1 - 20 min. - Level 1 - 2 - Libsyn
Forward Bend. Half Lift. Down Dog. Right Leg High. Down Dog. Bent Knee Hip Opener. Down Dog. Half Lift. Forward Bend. Forward Bend. Down Dog. Left Leg High. Tadasana. Tadasana. Back Bend. Forward Bend. Half Lift. Right Leg High. Runner's Lunge. Frog.

Cognition in the lab and cognition in the wild 00 p. 1 ...
Georgia Institute of Technology. Mike Martin. University of ... comparing subjects of roughly the same age range X young adulthood to (late) middle age. .... tend to benefit more for schema0consistent information, Shi et al., 2012, this issue) 00 or

Sunday Monday 10:00-11:00 1:00-2:00 4:00-5:00 11:00 ...
Shooter. Squad 14. Position. Shooter. Squad 20. Position. Shooter. 1 Gregory. Amanda. 1 Sweet. Ben. 1. 2 Sand. Evan. 2 lowe. Jackson. 2. 3 Smalley. Ben. 3 Nolde. Mackenzie. 3. 4 Weigel. Alexander. 4 Seeley. Alex. 4. 5 Weigel. Andrew. 5 Miller. Peyton

Page 1 - 00), (SD-- tº Republic of the Philippines ...
Aug 22, 2016 - ADMINISTRATION OF THE PHILIPPINE EDUCATIONAL PLACEMENT TEST ... Learners from non-formal and informal education programs c.

Jivamukti Yoga #1 - 20 min - Libsyn
Jivamukti Yoga #1 - 20 min - Level 1-2. 3 knees into chest. Spinal Twist knees into chest. Spinal Twist knees into chest. Savasana. Fish. Please help us keep this podcast going by donating $1.00 for each episode you download, or $1.00 each month. Ple

Yoga for Cyclists #1 - 20 min. - Level 1 - 2 - Libsyn
Knees into Chest. Dead Bugs Pose. Baddha Konasana. Savasana. Bent Knee Hip Opener. Left Leg High. Down Dog. Half Lift. Forward Bend. Tadasana. Samasthiti. Forward Bend leggs crossed. Tadasana. Tadasana. Back Bend. Forward Bend. Down Dog. Half Lift. R

0:00 0.09 - - 1:00 0.08 - - 2:00 0.10 - - 3:00 0.14 - - 4 ... -
The Project team will be led by Professor Yoichiro Matsumoto, Executive Vice ... Tanaka, General Manager of Division for Environment, Health and. Safety). 3.

2 Samuel Things we will learn: 1. We see David a man just like us. He ...
Page 1 ... David desires to build God's house but God turned around to build his house. 2 Samuel 7. 5. 2 Samuel 7:27 “For thou, O LORD of ...... My own calculations might be off based on David's age of 30 as stated here when he became king.

1 LPG eneral 101 CS 1 0 5 Min 9 2 102 CS 1 0 5 Min ...
Item. Gend Item. Max. Item Name. Partici Pinnan. Code er Type pants y. 101 Prasangam - Malayalam. O 5 Min. 102 Padyamchollal - Malayalam. 0 5 Min.

Yoga Sculpt #1 - 20 min - Libsyn
Crescent Lunge. Warrior 2. Yoga Sculpt #1 - 20 min - Level 3-4. Chaturanga. Up Dog. Down Dog. Reverse Flys. Low Lunge. Leg High. Crescent Lunge.

Yoga Sculpt #1 - 20 min - Libsyn
3. Yoga Sculpt #1 - 20 min - Level 3-4. Plank Pose lift from mat. Up Dog. Down Dog. Table Top. Down Dog. Leg High. Crescent Lunge. Low Lunge. Warrior 2. Reverse Warrior. Chaturanga. Up Dog. Down Dog. Knee Into Chest reach up and down. Spinal Twist. K

1 The Short-Time Compensation Program in France: An Efficient ...
The short-time compensation (STC) program aims at avoiding redundancies in case .... industry; financial intermediation; real estate activities and administration.

2 Samuel Things we will learn: 1. We see David a man just like us. He ...
brings us closer to God and make certain of our salvation. 3. We are all ... Israelite and knows of Saul's anointing; and falling on his own sword did not do it.

H-1.pdf
En su origen,. Hampa que designaba al conjunto de maleantes que unidos en una especie de sociedad, cometían. robos y otros delitos, y usaban un lenguaje ...

Jivamukti Yoga #1 - 20 min - Libsyn
comfortable seated position. Samasthiti. Forward Fold. Half Lift. Plank. Knees Chest Chin. Cobra. Childs Pose. Down Dog. Half Lift. Forward Fold. Tadasana.