001 - Hello World App Flashcards

1
Q

Question 2: Which of the following is not a valid comment:

a. /** comment /
b. /
comment /
c. /
comment
d. // comment

A

c. /* comment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Question 3: What is the first thing you should check if you see the following error at runtime:

Exception in thread “main” java.lang.NoClassDefFoundError:
HelloWorldApp.java.

A

Answer 3: Check your classpath. Your class cannot be found.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Question 4: What is the correct signature of the main method?

A

Answer 4: The correct signature is public static void main(String[] args) or public static void main(String… args)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Question 5: When declaring the main method, which modifier must come first, public or static?

A

Answer 5: They can be in either order, but the convention is public static.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Question 6: What parameters does the main method define?

A

Answer 6: The main method defines a single parameter, usually named args, whose type is an array of String objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Exercise 1: Change the HelloWorldApp.java program so that it displays Hola Mundo! instead of Hello World!.

A

Answer 1: This is the only line of code that must change:

System.out.println(“Hola Mundo!”); //Display the string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Exercise 2: You can find a slightly modified version of HelloWorldApp here: HelloWorldApp2.java

The program has an error. Fix the error so that the program successfully compiles and runs. What was the error?

A

Answer 2: Here’s the error you get when you try to compile the program:

HelloWorldApp2.java:7: unclosed string literal
System.out.println(“Hello World!); //Display the string.
^
HelloWorldApp2.java:7: ‘)’ expected
System.out.println(“Hello World!); //Display the string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Question 1: When you compile a program written in the Java programming language, the compiler converts the human-readable source file into platform-independent code that a Java Virtual Machine can understand. What is this platform-independent code called?

A

Bytecode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When creating a new Hello World app In the Name and Location page of the Netbeans new project wizard:

In the Project Name field, type ________
In the Create Main Class field, type _________.

A

Hello World App.

helloworldapp.HelloWorldApp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When you build the project, the __________ file HelloWorldApp.class is generated.

A

bytecode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

You can compile an individual file (as opposed to a whole project) using the IDE’s ________ (_________) command.

A

Compile File

F9

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

You can run an individual file (as opposed to a whole project) using the IDE’s __________ (___________) command.

A

Run Fille

Shift-F6

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

To turn off or on the

Auto Popup Completion Window

A
Choose 
Tools | 
     Options | 
          Editor, 
click the 
     Code Completion tab 
and clear the 
     Auto Popup Completion Window checkbox.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

When creating a new Java program in Windows notepad, in the Encoding combo box, the encoding must be left as _________.

A

ANSI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

To compile a HelloWorld app in CMD. At the prompt, type _________ command and press Enter.

A

javac HelloWorldApp.java

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

To run the Hello World Program with CMD:

In the same directory, enter the following command at the prompt:

A

java -cp . HelloWorldApp