sp05_quiz1_ans

sp05_quiz1_ans - 1.00/1.001 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 2 3 4 5 1.00/1.001 Introduction to Computers and Engineering Problem Solving Quiz 1 – March 4, 2005 Name: E-mail Address: TA: Section: 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. Question Points 12 23 10 20 35 Total 100 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. The class Test contains a main method. a. Complete the method addIt() of the class Tools. b. Write a main () method in class Test that initializes two integers to the values 5 and 77, calls addIt () appropriately, and prints the MyInt that is returned, using the method provided. public class MyInt{
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.

This note was uploaded on 11/29/2011 for the course CIVIL 1.00 taught by Professor Georgekocur during the Spring '05 term at MIT.

Page1 / 9

sp05_quiz1_ans - 1.00/1.001 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