• No results found

LESSON 2 FIRST JAVA PROGRAMS

N/A
N/A
Protected

Academic year: 2021

Share "LESSON 2 FIRST JAVA PROGRAMS"

Copied!
5
0
0

Loading.... (view fulltext now)

Full text

(1)

LESSON 2 – FIRST JAVA PROGRAMS

FILL IN THE BLANKS

Complete the following sentences by writing the word or words in the blanks provided.

1. Java bears some resemblance to the _______________ programming language, making it easier for programmers who know that language to pick up Java very quickly.

2. Java programs are called ________________, meaning they can usually be run on different types of computers without having to modify the program.

3. The Java compiler translates Java source code into __________________, not machine code. 4. ________________________ compilation is a feature used by some JVM's to interpret byte

code into machine code the first time it is processed, which speeds up program execution. 5. The _______________ I/O interface requires a user to enter a value at a prompt, and then

press the Enter key to input the value to the program.

6. Java program statements must be terminated by a(n) ____________________.

7. In the statement, System.out.println("Hello"), the period or dot between the word out and println is called the _____________________________________ operator.

8. Software such as Microsoft's Visual J++ and Borland's JBuilder use a(n)

_______________________ development environment to create and compile Java programs. 9. Incorrectly typing the name of an object or a variable, or, omitting a parentheses or

semicolon, would all cause a(n) ______________________ error, also called a compile-time error, to occur when the source code is compiled.

10. The __________________ statement can be used in a Java program to include an already written class in the new program.

11. In the statement, object1 = 25;, the equal sign (=) is called the ________________ operator.

TRUE/FALSE

Circle T if the statement is true or F if the statement is false.

T F 1. Companies such as IBM and Sun use C++ as their primary development language, but are beginning to use Java more frequently.

T F 2. Java programs typically run slower than the same program developed using C++. T F 3. It is possible to limit the capabilities of a Java program because it runs within a

virtual machine.

T F 4. So far, computer hackers have not managed to penetrate any of Java's security mechanisms.

T F 5. It is easier to implement a GUI interface in a language like Java than it would be using Visual Basic.

(2)

T F 8. There are four separate and distinct steps involved in creating and running a Java program, and they are Edit (enter source code), Compile (convert to byte code), Interpret (convert to machine code), and Execute (run the machine code). T F 9. Some Java compile-time error messages may not be clear as to exactly what the

error is, but they do provide the location in the source code where the error was discovered.

T F 10. The process of creating an object before it can be used is called instantiating the object.

T F 11. To write effective Java programs, the programmer must have detailed knowledge of the inner workings of any object to be used in the program.

MULTIPLE CHOICE

Select the best response for the following statements.

1. A process that can run concurrently with other processes is called a(n) _____. a. string.

b. thread c. object. d. path.

2. Which of the following statements about Java is true when Java is compared to C++? a. Java is easier to learn and use.

b. Java is less error prone.

c. Java is better suited for Internet use. d. all of the above.

3. Which of the following is required in order to run a Java program on any given computer? a. a Windows operating system.

b. A Java Virtual Machine. c. an Internet connection. d. a Java object code translator.

4. What is the name given to small Java programs contained within a Web page and interpreted by your Web browser?

a. applets. b. scripts. c. JVAs. d. mini-apps.

5. Which of the following is the name of a Java object that knows how to print or display characters in a terminal window?

a. println. b. cout. c. System.out. d. Terminal.out.

6. When a message is sent to an object, the string of characters that appears within the parentheses following the message is called a(n) ____.

(3)

7. Which of the following file extensions is always used to denote a Java byte code file? a. .class.

b. .btc. c. .byte. d. .jbc.

8. Java source code files are created and saved using what file extension? a. .jav.

b. .java. c. .jsrc. d. .jcod.

9. Which of the following techniques can be used to improve the readability of a Java source code file?

a. indentation.

b. adding blank lines and/or spaces within the program statements. c. placing each instruction on separate lines.

d. all of the above.

10. Which of the following statements could be used to create a new object called myBall, of a class named Ball?

a. Ball myBall = new Ball();. b. myBall - new Ball();. c. myBall(Ball) = new Ball();. d. Ball.myBall = new Ball();.

11. Which of the following symbols is used to denote a comment statement contained within a Java source code file?

a. /*. b. '. c. //. d. \\.

WRITTEN QUESTIONS

Write your answers to the following questions.

1. Describe several features of Java that make it an attractive and popular choice for

programming a new software system. Describe at least one disadvantage of using Java for a large software system.

(4)

2. What makes a Java program so easy to transport to another type of computer? How is that done?

3. What makes Java a more secure language than any other language? Is it possible to violate Java's security features?

4. Explain the process of just-in-time (JIT) compilation. What is the end result of a program that is executed using JIT?

5. Briefly describe the difference between a graphical user interface (GUI) and a terminal I/O interface.

(5)

6. Explain the overall purpose and the three major parts of the instruction System.out.println("Hello World");.

7. What is a "development environment", and what types of development environments exist for creating Java programs?

8. What is readability, and why should you consider that factor when creating a program? What can you do to increase the readability of a program?

9. What is the difference between a variable and a variable value? How is a value assigned to a variable?

References

Related documents

The point at which the resultant of lift forces acts is: A) the hub. B) the center of gravity. D) the center of pressure.. A) airflow velocity increasing downward having been

In this paper, we present projection sorting, an alternative to the traditional Verlet list algorithm for pairwise short-range force calculations, and show that it can be

The VX Cycle offers a broad range of scales for the cost-effective production of LNG/CCNG, and the Cycle can be integrated with existing CNG stations, pipeline compressor stations

The computed coefficient of multiple determination (R 2 ) value of 0.569 indicated that 56.9% of the total variation in commercial loans and advances (LCBLA) is accounted

• Impairment loss as the difference between carrying amount and discounted value of the estimated future cash flow using the original effective interest rate.. • Effective interest

The results presented indicate that the high volatile acid pro- duction of starters is not the result of mixtures of two or more cultures of Bact. PRESENCE IN

Every time the in-memory data structure for a particular column family is dumped to disk we set its bit in the commit log stating that this column family has been successfully

In the present study, we aimed to investigate physiological changes and metabolic signatures of the M. growth phases, blastospores and hyphae. Specifically, we hypothesized