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
this format flag adds grouping separators to numeric values.
How does the format flag “,” affect numeric values in printf()?
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.
define and note the role of the
Java Virtual Machine (JVM)
The console output methods belong to the PrintStream class.
Which class do the console output methods belong to?
How does the format flag “-“ affect the output in printf()?
This format flag left-justifies the value within the specified width
How can
console output
be performed in Java?
this can be performed using the out field of the System class (System.out). which is an instance of the PrintStream class
This format flag left-justifies the value within the specified width
How does the format flag “-“ affect the output in printf()?
In what order should elements of the format specifiers be used in printf()?
The order for these is
%[flags][width][precision][specifier]
This determines the number of digits after the decimal point for floating-point numbers.
Note:
rounding upwards will occur
What is the purpose of precision in printf()?
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
What is a requirement for creating an executable java application
What is the purpose of the width specifier in printf()?
this specifies the minimum number of characters to be printed for the corresponding value.
define the
Java Runtime Environment (JRE)
and note some of its components
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.
the syntax / usage of this is using a period (.) followed by a positive integer after the width specifier.
What is the syntax for specifying precision in printf()?
How can you specify the width of the output in printf()?
The width is specified as a positive integer between the % symbol and the format specifier.
The printf() method is used to create formatted strings by replacing format specifiers with values.
What is the purpose of the printf() method?
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.
define the
Java Development Kit (JDK)
and note some of its components
Step: Compile the source code using the Java compiler (javac).
Command: javac YourClass.java
Output: Creates a .class file containing the bytecode.
what is the
- first step
- command
- output
of Running a Java Program from the Command Line
What are some common format specifiers in printf()?
Common format specifiers include:
* %s (string),
* %d (integer),
* %f (floating-point),
* %c (character),
* and %b (boolean).
What is the purpose of the printf() method?
The printf() method is used to create formatted strings by replacing format specifiers with values.
Format flags change the behavior of the format specifier and are set using a single character preceded by the % symbol
What is a format flag in printf()?
what is the output of
System.out.printf("%.3f", 1.23456789);
Output: 1.235
what is the
header of the main method
the header for this is:
public static void main(String[] args)