1.
API stands for:
Correct Answer
B. Application programming interface
Explanation
API stands for Application Programming Interface. It is a set of rules and protocols that allows different software applications to communicate with each other. APIs define the methods and formats that should be used for data exchange between applications, enabling developers to create new software by utilizing existing functionality. This allows for seamless integration and interoperability between different systems and applications, making it easier for developers to build complex software solutions.
2.
JVM stands for:
Correct Answer
A. Java Virtual Machine
Explanation
JVM stands for Java Virtual Machine. It is a virtual machine that allows computer programs written in Java to run on any operating system. The JVM is responsible for interpreting the Java bytecode and executing the program by translating it into machine code that can be understood by the underlying hardware. It provides a platform-independent execution environment for Java applications, enabling them to be run on different devices and operating systems without the need for recompilation.
3.
The file containing Java programming statements is also known as:
Correct Answer
B. Source code
Explanation
The file containing Java programming statements is commonly referred to as the "source code". This file contains the human-readable instructions and commands written in Java programming language. It serves as the input for the Java compiler, which translates the source code into bytecode that can be executed by the Java Virtual Machine.
4.
The Java machine-independent code is called:
Correct Answer
C. Byte code
Explanation
Byte code is the correct answer because it refers to the machine-independent code generated by the Java compiler. This code is not directly executable by the computer's processor, but it can be interpreted and executed by the Java Virtual Machine (JVM). The JVM converts the byte code into machine code that is specific to the underlying operating system and hardware, allowing Java programs to run on any platform that has a compatible JVM. Therefore, byte code serves as an intermediate representation of the Java program that enables portability and platform independence.
5.
The three main types of programs that you can write using Java are:
Correct Answer(s)
A. Applications
C. Applets
D. Servlets
Explanation
The correct answer is Applications, Applets, and Servlets. These are the three main types of programs that can be written using Java. Applications are standalone programs that can be run on a computer or a mobile device. Applets are small programs that are embedded in webpages and run within a web browser. Servlets are Java programs that run on a web server and generate dynamic web content. These three types of programs allow developers to create a wide range of applications and web-based solutions using Java programming language.
6.
Java applications can be further subdivided into 2 of the following applications:
Correct Answer(s)
B. Console applications
D. Windowed applications
Explanation
Java applications can be further subdivided into two types: console applications and windowed applications.
Console applications are text-based applications that run in a command-line interface. They interact with the user through text input and output. These applications are typically used for tasks that do not require a graphical user interface, such as data processing or system administration.
Windowed applications, on the other hand, have a graphical user interface and run in a windowing system. They provide a visual interface for users to interact with the application using buttons, menus, and other graphical elements. These applications are commonly used for tasks that require a more interactive and visually appealing user experience.
Therefore, the correct answer is Console applications and Windowed applications.
7.
Java programming language is modeled after which language?
Correct Answer
C. C++
Explanation
Java programming language is modeled after C++ because Java was designed to be similar to C++ in terms of syntax and structure. Both languages share many similarities, such as the use of classes, objects, and inheritance. Additionally, Java borrowed several features from C++, including the concept of pointers (although Java does not allow direct manipulation of pointers like C++ does). The goal of modeling Java after C++ was to make it easier for C++ programmers to transition to Java and leverage their existing knowledge and skills.
8.
Which of the following Java statements is the correct way to display "Hello World" on the screen?
Correct Answer
C. System.out.println("Hello World");
Explanation
The correct way to display "Hello World" on the screen in Java is by using the statement System.out.println("Hello World");. This statement will print the string "Hello World" followed by a new line.
9.
Every statement in Java must be terminated by:
Correct Answer
B. A semicolon
Explanation
In Java, every statement must be terminated by a semicolon. This is a fundamental rule in the syntax of the Java programming language. The semicolon acts as a delimiter to mark the end of a statement and allows the compiler to understand the structure of the code. Without a semicolon, the code would result in a compilation error. Therefore, it is essential to include a semicolon at the end of each statement in Java.
10.
Java is case-sensitive
Correct Answer
A. True
Explanation
Java is case-sensitive because it distinguishes between uppercase and lowercase letters in its syntax. This means that variables, methods, and classes must be written with the exact same capitalization each time they are referenced. For example, if a variable is declared as "myVariable", it cannot be referenced as "myvariable" or "MYVARIABLE". This case-sensitivity allows Java to differentiate between different identifiers and ensures that the correct elements are being referenced in the code.
11.
All Java applications must have a main() method
Correct Answer
A. True
Explanation
In Java, the main() method is the entry point of any application. It is a mandatory method that is required in every Java application. The main() method is where the program starts its execution and it is responsible for invoking other methods and performing necessary operations. Without a main() method, the Java program would not be able to run or execute any code. Therefore, it is essential for all Java applications to have a main() method.
12.
Program comments are non-executing statements.
Correct Answer
A. True
Explanation
Program comments are non-executing statements that are used to provide explanations or documentation within a program's code. They are ignored by the compiler or interpreter and do not affect the execution of the program. Comments are typically used to make the code more readable and understandable for other programmers or for future reference. They can also be used to temporarily disable a piece of code without deleting it. Therefore, the statement "Program comments are non-executing statements" is true.
13.
An error that occurs when you introduce typing errors into your program is known as :
Correct Answer
B. Syntax error
Explanation
A syntax error occurs when there are mistakes in the structure or syntax of a program. This means that the code does not follow the correct rules and grammar of the programming language. Typing errors, such as misspelled keywords or missing punctuation, can result in syntax errors. These errors prevent the program from being compiled or executed successfully.
14.
Java source files are saved with the extension:
Correct Answer
C. .java
Explanation
Java source files are saved with the extension ".java" because it is the standard file extension for Java source code files. This allows the Java compiler to recognize and process the file as a Java source code file. Other file extensions like ".doc" are not used for Java source files as they are typically used for word processing documents, while ".javadoc" is used for generated documentation files, and ".class" is used for compiled Java bytecode files.
15.
Which of the following arithmetic operators will give you the remainder after dividing?
Correct Answer
D. %
Explanation
The arithmetic operator % is known as the modulus operator, which gives the remainder after dividing two numbers. Therefore, when using the % operator, the result will be the remainder of the division operation.
16.
The variable data type that can hold only two values, true or false is:
Correct Answer
D. Boolean
Explanation
The correct answer is boolean because it is the only variable data type that can hold only two values, true or false. Int, float, and double are numerical data types that can hold a range of values, whereas boolean is specifically designed to represent logical values.
17.
Which of the following are Java reserved words?
Correct Answer(s)
B. Public
G. Double
H. Do
Explanation
The correct answer includes the words "public," "double," and "do." These are Java reserved words because they have specific meanings and uses in the Java programming language. "public" is a keyword used to declare that a method or variable can be accessed from other classes. "double" is a data type used to represent decimal numbers. "do" is a keyword used to start a do-while loop, which executes a block of code at least once before checking a condition.
18.
Which data type can I use to store the first letter of my surname?
Correct Answer
B. Char
Explanation
The data type "char" can be used to store a single character, such as the first letter of a surname. It is the most appropriate data type for this purpose as it specifically represents individual characters. The other data types listed (boolean, string, and byte) are not designed to store individual characters in the same way as the "char" data type.
19.
Which data type can I use to store my surname?
Correct Answer
C. String
Explanation
A string data type can be used to store a surname because it can hold a sequence of characters, such as letters, numbers, and symbols. Unlike other data types mentioned, like boolean or byte, a string can accommodate multiple characters and is suitable for storing textual information like a surname.
20.
Which data type can I use to store my salary in Java?
Correct Answer
C. Double
Explanation
In Java, the "double" data type can be used to store the salary. The "double" data type is a floating-point type that can hold decimal values and provides a wider range of values compared to the "int" and "long" data types. The "real" data type does not exist in Java, so it is not a valid option for storing the salary.