1.
What is this in JAVA?A blueprint from which individual objects are created.
Correct Answer
A. Class
Explanation
In Java, a class serves as a blueprint from which individual objects are created. It defines the properties and behaviors that the objects of that class will have. By creating objects from a class, we can access and utilize its attributes and methods. Therefore, the correct answer is "class".
2.
What is this in JAVA?An instance of a class.
Correct Answer
D. Object
Explanation
In Java, an object refers to an instance of a class. It is a fundamental concept in object-oriented programming where classes are used to define the blueprint for creating objects. Objects have their own set of attributes and behaviors defined by the class they belong to. They can be instantiated using the "new" keyword and can interact with each other through method calls. Therefore, an object is the correct answer as it represents an instance of a class in Java.
3.
What is this in JAVA?Describes an action that can be carried out on or by an object.
Correct Answer
B. Method
Explanation
A method in JAVA is a block of code that defines an action that can be performed on or by an object. It encapsulates a series of statements that can be executed when the method is called. Methods are used to perform specific tasks and can have parameters and return values. Therefore, the given correct answer, "Method," accurately describes an action that can be carried out on or by an object in JAVA.
4.
How would you call a method called ‘showSquare’ for an object called yellowSquare?
Correct Answer
A. YellowSquare.showSquare();
Explanation
To call a method called 'showSquare' for an object called yellowSquare, we use the dot notation. The correct syntax is yellowSquare.showSquare(); This syntax indicates that we are calling the method 'showSquare' on the object 'yellowSquare'.
5.
From which method does the execution of a Java application start?
Correct Answer
C. Main method
Explanation
The execution of a Java application starts from the main method. This is the entry point for the program where the JVM (Java Virtual Machine) starts executing the code. The main method is declared with the keyword "public" to make it accessible from outside the class, "static" so that it can be called without creating an instance of the class, "void" to indicate that it does not return any value, and "String args[]" to accept command-line arguments if any.
6.
Select the Java numeric data types from the following:NOTE: you need to choose more than one
Correct Answer(s)
A. Long
B. Short
C. Byte
D. Int
E. Float
F. Double
Explanation
The Java programming language provides several numeric data types that can be used to store different types of numerical values. The correct answer includes long, short, byte, int, float, and double. These data types allow programmers to work with integers (long, short, byte, int) and floating-point numbers (float, double) in their Java programs.
7.
How would you declare a constant variable called VAT whose value is 0.18?
Correct Answer
A. Final float VAT = 0.18;
Explanation
The correct answer is "final float VAT = 0.18;". In Java, to declare a constant variable, we use the "final" keyword. Here, the variable name is VAT and its data type is float. The value assigned to the variable is 0.18.
8.
A FOR loop is a predetermined loop.
Correct Answer
A. True
Explanation
A FOR loop is a predetermined loop because it is designed to execute a specific number of times. It uses a counter variable and a condition to determine when the loop should stop. The loop body is executed repeatedly until the condition is no longer true. This allows for precise control over the number of iterations, making it a predetermined loop.
9.
A do...while loop will loop 0 or more times.
Correct Answer
B. False
Explanation
A do...while loop will loop at least one time. The loop condition is checked at the end of each iteration, so even if the condition is initially false, the loop will still execute once before checking the condition. Therefore, it is not possible for a do...while loop to loop 0 times.
10.
A WHILE loop will loop one or more times.
Correct Answer
B. False
Explanation
A WHILE loop will only loop if the specified condition is true. If the condition is initially false, the loop will not execute at all. Therefore, it is possible for a WHILE loop to not loop at all. Hence, the statement "A WHILE loop will loop one or more times" is false.