Topic 1.3: Java Basics - Create executable Java applications with a main method; run a Java program from the command line; produce console output Flashcards

1
Q

this format flag adds grouping separators to numeric values.

A

How does the format flag “,” affect numeric values in printf()?

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

This is part of Java Runtime Environment (JRE) and is Responsible for executing Java bytecode.

it achieves this by interpreting and translating bytcode into machine-specific instructions.

A

define and note the role of the
Java Virtual Machine (JVM)

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

The console output methods belong to the PrintStream class.

A

Which class do the console output methods belong to?

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

How does the format flag “-“ affect the output in printf()?

A

This format flag left-justifies the value within the specified width

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

How can
console output
be performed in Java?

A

this can be performed using the out field of the System class (System.out). which is an instance of the PrintStream class

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

This format flag left-justifies the value within the specified width

A

How does the format flag “-“ affect the output in printf()?

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

In what order should elements of the format specifiers be used in printf()?

A

The order for these is

%[flags][width][precision][specifier]

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

This determines the number of digits after the decimal point for floating-point numbers.

Note:
rounding upwards will occur

A

What is the purpose of precision in printf()?

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

An executable Java application is a program that can be executed independently.

A requirement for this is that we define a class with a special method called the main method. the main method will then act as the entry point for the program execution

A

What is a requirement for creating an executable java application

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

What is the purpose of the width specifier in printf()?

A

this specifies the minimum number of characters to be printed for the corresponding value.

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

define the
Java Runtime Environment (JRE)
and note some of its components

A

This Consists of files and components necessary for running Java applications at runtime.

Notable components include:
* Java Virtual Machine (JVM): Executes Java bytecode.
* Standard Java class libraries: Collection of pre-defined classes and APIs.
* Runtime components: Additional tools and resources required for execution.

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

the syntax / usage of this is using a period (.) followed by a positive integer after the width specifier.

A

What is the syntax for specifying precision in printf()?

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

How can you specify the width of the output in printf()?

A

The width is specified as a positive integer between the % symbol and the format specifier.

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

The printf() method is used to create formatted strings by replacing format specifiers with values.

A

What is the purpose of the printf() method?

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

This is a software development kit provided by Oracle Corporation for developing, compiling, and running Java applications.

Notable components include:
* Java Compiler (javac): Used to compile Java source code into bytecode.
* Java Runtime Environment (JRE): Includes the JVM (java) and necessary runtime components for running Java applications.
* Development Tools: Various tools for Java development, such as debugger, profiler, and documentation generator.

A

define the
Java Development Kit (JDK)
and note some of its components

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

Step: Compile the source code using the Java compiler (javac).

Command: javac YourClass.java

Output: Creates a .class file containing the bytecode.

A

what is the

  • first step
  • command
  • output

of Running a Java Program from the Command Line

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

What are some common format specifiers in printf()?

A

Common format specifiers include:
* %s (string),
* %d (integer),
* %f (floating-point),
* %c (character),
* and %b (boolean).

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

What is the purpose of the printf() method?

A

The printf() method is used to create formatted strings by replacing format specifiers with values.

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

Format flags change the behavior of the format specifier and are set using a single character preceded by the % symbol

A

What is a format flag in printf()?

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

what is the output of

System.out.printf("%.3f", 1.23456789);

A

Output: 1.235

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

what is the
header of the main method

A

the header for this is:

public static void main(String[] args)

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

What does the format flag “(“ do in printf()?

A

This format flag encloses negative numbers within parentheses.

23
Q

what is the output of

System.out.printf("|%-10s|", "Hello");

A

Output: |Hello |

24
Q

what is the output of

System.out.printf("%(.2f", -3.14);

A

Output: (3.14)

25
The order for these is `%[flags][width][precision][specifier]`
In what order should elements of the format specifiers be used in printf()?
26
This format flag pads numeric values with leading zeros instead of spaces. note that a length must be given and the "-" flag may not be used
What is the purpose of the format flag "0" in printf()?
27
what is the * second step * command * output of Running a Java Program from the Command Line
Step: Execute the bytecode using the Java Virtual Machine (JVM) and runtime environment. Command: java YourClass (extension is not required) Output: JVM starts the execution and searches for the main method in YourClass. The main method in YourClass is executed, and the program starts running
28
This format flag encloses negative numbers within parentheses.
What does the format flag "(" do in printf()?
29
What is the difference between the println() and print() methods?
The println() method adds a new line character at the end of the text, while the print() method does not automatically add a new line character.
30
The println() method adds a new line character at the end of the text, while the print() method does not automatically add a new line character.
What is the difference between the println() and print() methods?
31
Common format specifiers include: * %s (string), * %d (integer), * %f (floating-point), * %c (character), * and %b (boolean).
What are some common format specifiers in printf()?
32
What is the purpose of the format flag "0" in printf()?
This format flag pads numeric values with leading zeros instead of spaces. note that a length must be given and the "-" flag may not be used
33
what is the * first step * command * output of Running a Java Program from the Command Line
Step: Compile the source code using the Java compiler (javac). Command: `javac YourClass.java` Output: Creates a .class file containing the bytecode.
34
What does precision refer to in printf()?
Precision applies to floating-point numbers and determines the number of digits after the decimal point.
35
what is the output of `System.out.printf("%+d", 42);`
Output: +42
36
what is the output of `System.out.printf("%,d", 1000000);`
Output: 1,000,000
37
The width is specified as a positive integer between the % symbol and the format specifier.
How can you specify the width of the output in printf()?
38
What does the format flag "+" do in printf()?
This format flag includes a sign (+ or -) for numeric values.
39
This Consists of files and components necessary for running Java applications at runtime. Notable components include: * Java Virtual Machine (JVM): Executes Java bytecode. * Standard Java class libraries: Collection of pre-defined classes and APIs. * Runtime components: Additional tools and resources required for execution.
define the **Java Runtime Environment (JRE)** and note some of its components
40
this can be performed using the out field of the System class (System.out). which is an instance of the PrintStream class
How can **console output** be performed in Java?
41
define the **Java Development Kit (JDK)** and note some of its components
This is a software development kit provided by Oracle Corporation for developing, compiling, and running Java applications. Notable components include: * Java Compiler (javac): Used to compile Java source code into bytecode. * Java Runtime Environment (JRE): Includes the JVM (java) and necessary runtime components for running Java applications. * Development Tools: Various tools for Java development, such as debugger, profiler, and documentation generator.
42
Step: Execute the bytecode using the Java Virtual Machine (JVM) and runtime environment. Command: java YourClass (extension is not required) Output: JVM starts the execution and searches for the main method in YourClass. The main method in YourClass is executed, and the program starts running
what is the * second step * command * output of Running a Java Program from the Command Line
43
This format flag includes a sign (+ or -) for numeric values.
What does the format flag "+" do in printf()?
44
define and note the role of the **Java Virtual Machine (JVM)**
This is part of Java Runtime Environment (JRE) and is Responsible for executing Java bytecode. it achieves this by interpreting and translating bytcode into machine-specific instructions.
45
What is the syntax for specifying precision in printf()?
the syntax / usage of this is using a period (.) followed by a positive integer after the width specifier.
46
What is the purpose of precision in printf()?
This determines the number of digits after the decimal point for floating-point numbers. Note: rounding upwards will occur
47
How does the format flag "," affect numeric values in printf()?
this format flag adds grouping separators to numeric values.
48
What is a format flag in printf()?
Format flags change the behavior of the format specifier and are set using a single character preceded by the % symbol
49
what is the output of `System.out.printf("%08d", 42);`
Output: 00000042
50
Precision applies to floating-point numbers and determines the number of digits after the decimal point.
What does precision refer to in printf()?
51
the header for this is: `public static void main(String[] args)`
what is the **header of the main method**
52
What is a requirement for creating an executable java application
An executable Java application is a program that can be executed independently. A requirement for this is that we define a class with a special method called the main method. the main method will then act as the entry point for the program execution
53
this specifies the minimum number of characters to be printed for the corresponding value.
What is the purpose of the width specifier in printf()?
54
Which class do the console output methods belong to?
The console output methods belong to the PrintStream class.