Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) A unique aspect of Java that allows code compiled on one machine to be execut

ID: 3606524 • Letter: 1

Question

1) A unique aspect of Java that allows code compiled on one machine to be executed on a machine of a different hardware platform is Java's 2) An error in a program that results in the program outputting $300 instead of the correct answer, $250 is 3) Which of the following reserved words in Java is used to create an instance of a class? A) class B) public C) public or private, either could be used D) import E) new 4.) To define a class that will represent a car, which of the following definitions is most appropriate? A) private class car B) public class car C) public class Car D) public class CAR E) private class Car 5. The relationship between a class and an object is best described as A) classes are instances of objects B) objects are instances of classes D) classes are programs while objects are variables C) objects and classes are the same thing E) objects are the instance data of classes 6) Mistyping "println" as "printn" will result in A) a syntax error B) a run-time error C) a logical error D) no error at all E) converting the statement into a comment 7) What is the output of the statement System.out.printlnxty); if x and y are int values where x=10 and y=5? Explain your Answer

Explanation / Answer

1. A unique aspect of Java that allows code compiled on one machine to be executed on a machine of a different hardware platform is Java's bytecodes

Java programs are first compiled into bytecodes, which are highly optimized set of instructions designed to be executed by Java run-time system, Java Virtual Machine(JVM). These bytecodes are architecturally neutral (that is, they can be used no matter what the architectural platform is). To execute the program, the bytecodes must be further compiled by a Java compiler or interpreted by a Java Virtual Machine.

2. An error in a program that results in the program outputting $300 instead of the correct answer, $250 is Logical error

3.  The reserved keyword in Java which is used to create an instance of a class is new

Objects are instances of class . The new operator dynamically allocates memory(at run-time) for an object and returns a reference to it.

4. public class Car - public allows the class to be accessed by other classes, i.e objects of this class can be created by other class and hence this class can be used by other class. For all class names, the first letter should be in upper case. If several words are used to form a name of the class, each inner word's first letter should be in upper case.

5. objects are instances of classes

We can access the members of classes by using objects. Objects have states and behaviors.

6. a syntax error

7. 105

In java "+" is overloaded which is also used for concatenation. The println statement considers parameter as String. So instead of adding x and y they are concatenated and displayed. In order to display sum of x and y we need to use brackets() around x+y i.e System.out.println(""+(x+y));