quiz1answers

quiz1answers - 1.00 Introduction to Computers and...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 – March 4, 2005 E-mail Address: TA: Section: Name: You have 80 minutes to complete this exam. For coding questions, you do not need to include comments, and you should assume that all necessary files have already been imported. 1 2 3 4 5 Question Points 12 23 10 20 35 100 Total 1 / 9
Background image of page 1

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

View Full DocumentRight Arrow Icon
Question 1. True/False (12 Points) Answer the following questions about Java by circling TRUE or FALSE as appropriate. 1) Two classes in the same package can access each other's private variables as object.variableName, where object is an instance of the other class, and variableName is a private variable of that object TRUE FALSE 2) The following piece of code will compile double a = 5.5; double b = 6.9; int sum = a+b; TRUE FALSE 3) Consider the following lines of code int i=6; ± int j=5; ± double result = i/j + i%j; ± The value stored in variable result is 2.2 TRUE FALSE 4) A class constructor may have an int return value. TRUE FALSE 2/9
Background image of page 2
Question 2: Methods (23 Points) In the code provided below, MyInt is a class with a single private variable value . Another class Tools has a static method addIt() which adds two integers, stores the value as an object of type MyInt and returns the MyInt object. a. Complete the method addIt() of the class Tools. (15 Points) b. Write a main() method in class Tools that initializes two integers to the values 5 and 77, calls addIt() appropriately, and prints the MyInt that is returned. (8 Points)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

quiz1answers - 1.00 Introduction to Computers and...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online