COMP 328 Homework 5 Topic 3 Introduction to Java

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

Info icon This 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
Image of page 1

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

View Full Document Right 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);
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 ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern