COMP 328 Homework 5 Topic 3 Introduction to Java

COMP 328 Homework 5 Topic 3 Introduction to Java - COMP 328...

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

View Full Document Right Arrow Icon
COMP 328 Homework 5 Topic 3 Introduction to Java COMP 328 Homework 5 (Topic 3) Introduction to Java Read the following then answer the questions: Chapter 1 – Sections 4, 6, 8 Chapter 2 – Sections 1 thru 10 - pp. 34 - 56 Chapter 3 – Sections 1 thru 8 – pp. 82 - 109 Chapter 4 – All sections – pp. 134 - 169 Lecture Supplements: Java Features Similar to C++ Variables, Strings, and IO Classes 1. What does the Java virtual machine (JVM) do? Circle all that apply . (a) Compiles Java source files. (b) Translates a .java file into a .class file of the same name. (c) Executes .java source files directly. (d) X Interprets Java byte code into machine code at run time. (e) X Executes .class files. (f) X Verifies byte codes are valid. 2. If you are writing the code for a Java class called Pitcher (as in baseball), what must the file name be? Pitcher.java 3. What method of a Java class identifies it as a Java application? main 4. If sqrt is a static method of the Math class that receives a double and returns its square root as a double , what is the line of code to store the square root of 1.2 in double variable root1 ? double root1 = Math.sqrt(1.2); Rakocy/Volkers 5/8/2011 1:02 a5/p5 Page 1 of 7
Background image of page 1

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

View Full DocumentRight Arrow Icon
COMP 328 Homework 5 Topic 3 Introduction to Java 5. Assume Pitcher is a class with this non-static method public double getera(void) which returns the earned run average (era) of a pitcher. Which of the following is a valid statement to assign the returned value to double variable earnedRunAverage ? Circle all that apply. (a) earnedRunAverage = Pitcher.getera( ); (b) Pitcher.getera(earnedRunAverage); (c) X Pitcher p1; earnedRunAverage = p1.getera( ); (d) Pitcher p1; p1.getera(earnedRunAverage); 6. Based on your answers to the two previous questions, what describes, in general, how to call a non- static method of a class? Circle all that apply. (a) X
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/08/2011 for the course ECET 220 taught by Professor Smith during the Spring '11 term at DeVry Austin.

Page1 / 7

COMP 328 Homework 5 Topic 3 Introduction to Java - COMP 328...

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

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