{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

COMP 110 Midterm Practice

COMP 110 Midterm Practice - Name Date COMP 110 Midterm UNC...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Name__________________________ Date ___________ COMP 110 Midterm UNC Honor Pledge: I certify that no unauthorized assistance has been received or given in the completion of this work Signature ______________________________ You may NOT use any course materials in completing this test. The test consists of three sections: first, a section of short answer questions; second, a section requiring you to trace a short piece of code and write the output produced by the code; finally, a section requiring you to write code. The second and third sections each provide four questions of different point values. You can choose THREE questions from section two, and TWO questions from section three to be graded. It is possible to attempt greater than or fewer than 100 points, however your final grade will be calculated out of 100 points. Point values are given for each question. Illegible answers will not receive credit.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Part 1. (40 points) Answer ALL questions 1.) (2 points) What is the value of var ? double var = (3 / 2) * 2.0; 2.0 2.) (4 points) List 4 primitive types. Byte, short, int, long, float, double, char 3.) (3 points) Declare a variable to hold the amount of money you have saved for spring break and initialize it to 150.75. Name your Java variable so any programmer would know what value it holds. Your variable name should be at least two words. double breakMoney = 150.75; 4.) (3 points) Declare and calculate a double, averageAge, if you have (as integers) sumAges and totalPeople. double averageAge = (double)sumAges / (double)totalPeople; 5.) (2 points) Give me two good reasons why you should always comment your code.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}