2023 Assesment Exam Flashcards
Define syntax
refers to the set of rules that define the structure of a program
Define Java API
Application Programming Interface, is a collection of pre-written software components that developers can use in their Java programs.
Define a Variable
a named storage location in memory that holds a value during program execution.
Define source code
the set of instructions written by a programmer using the Java programming language.
Define an Algorithm
set of well-defined instructions that are executed in a specific order to solve a particular problem
State examples of eselctive control structures
sequence , The If statement , the Switch(case) statement , iteration loops(For Loop, Do-while loop, while loop)
Assume that there is a java class called Test and it has not been compiled but we want to run it.
i. Identify the appropriate command to use to compile this class on command line interface.
javac Test.java
Assume that there is a java class called Test and it has not been compiled but we want to run it.
java Test
Use one java instruction to write a statement that displays the following output on the screen.
Hello
World
System.out.println(“Hello”+”\n”+”World”);
Identify (3) rules which a programmer must consider when using a loop that should terminate at some point.
- INITIALIZE the loop control variable outside the loop
- Use the loop control variable as a variable in the loop
- Alter the loop control variable
Identify a loop which should be used in a situation where it should execute at least once.
Do while statement
Justify why statements in the body of a loop must be indented.
- Improve legibility
- Improve readability
- Neatness
Define Sub routines
Methods are essentially self-contained blocks of code that perform specific tasks within a class.
Define a constructor
a constructor is a special type of method that is called automatically whenever you create an object of a class using the “new” keyword.
Give an example demonstrating how subroutines/methods are defined in Java
public static void add(int a, int b ){
int sum;
sum = a + b;
}