1.
Untuk menjalankan program Java, komputer harus terinstall:
Correct Answer
B. JRE
Explanation
To run a Java program, the computer must have JRE (Java Runtime Environment) installed. JRE provides the necessary runtime environment for executing Java applications. It includes the Java Virtual Machine (JVM), libraries, and other components required to run Java programs. JRE does not include the Java development tools or compiler, but it is sufficient for running already compiled Java programs. Therefore, JRE is the correct answer as it is essential for executing Java programs.
2.
Berikut ini merupakan jenis bahasa program yang berbasis compiler (compiled programming), kecuali:
Correct Answer
C. Perl
Explanation
Perl is not a compiled programming language. It is an interpreted language, which means that the code is executed line by line without the need for compilation. In contrast, Java, C, and Pascal are all compiled programming languages, where the source code is compiled into machine code before execution.
3.
Jika ingin membuat aplikasi Java untuk dijalankan di perangkat mobile, maka paling tepat menggunakan:
Correct Answer
B. J2ME
Explanation
J2ME is the most appropriate option for developing a Java application for mobile devices. J2ME (Java 2 Micro Edition) is a platform that provides a runtime environment for running Java applications on small devices with limited resources, such as mobile phones. It offers a set of APIs and libraries specifically designed for mobile development, allowing developers to create applications that are optimized for mobile devices. Therefore, J2ME is the best choice for developing a Java application that can be run on mobile devices.
4.
Pengecekan tipe data di Java dilakukan saat:
Correct Answer
A. Program dikompilasi.
Explanation
In Java, data type checking is performed during program compilation. This means that the compiler checks if the data types used in the program are compatible and consistent with the operations and assignments performed. Any errors or inconsistencies in the data types will be detected and reported during the compilation process. This ensures that the program is syntactically correct and helps prevent type-related errors during runtime.
5.
Secara otomatis Java akan menghapus pengalokasian memory yang sudah tidak digunakan dengan proses yang disebut:
Correct Answer
D. Garbage collector
Explanation
Java memiliki mekanisme pengelolaan memori yang disebut Garbage Collector. Garbage Collector bertugas untuk secara otomatis menghapus pengalokasian memori yang sudah tidak digunakan oleh program. Hal ini dilakukan untuk mengoptimalkan penggunaan memori dan mencegah terjadinya kebocoran memori. Dengan adanya Garbage Collector, programmer tidak perlu secara manual menghapus objek yang sudah tidak digunakan, sehingga memudahkan dalam pengembangan program.
6.
Fitur di Java yang memungkinkan programmer mengatur penanganan error yang terjadi dalam program, disebut:
Correct Answer
A. Exception handling
Explanation
Exception handling adalah fitur di Java yang memungkinkan programmer untuk mengatur penanganan error yang terjadi dalam program. Dengan menggunakan exception handling, programmer dapat menangani dan mengelola error dengan cara yang terstruktur dan terkontrol, sehingga program dapat tetap berjalan dengan baik meskipun terjadi error.
7.
Berikut ini editor yang dapat digunakan untuk menuliskan program Java, kecuali:
Correct Answer
D. JavaBeans
Explanation
JavaBeans is not an editor that can be used to write Java programs. It is a software component model for Java that allows for the creation of reusable software components. Notepad, Eclipse, and JCreator are all editors that can be used to write Java programs.
8.
Pernyataan yang benar berhubungan dengan program Java, kecuali:
Correct Answer
B. Method main() harus ada dalam setiap class program Java
Explanation
The statement "Method main() harus ada dalam setiap class program Java" is incorrect because the main() method is not required in every class in a Java program. The main() method is only required in the class that serves as the entry point for the program, typically named the "main" class. Other classes in the program may or may not have a main() method depending on their purpose.
9.
Berikut ini merupakan keyword yang terdapat dalam Java, kecuali:
Correct Answer
D. String
Explanation
The given options are if, break, goto, and string. All of these options are keywords in Java except for the keyword "string". In Java, "string" is not a keyword, but it is a class that represents a sequence of characters. Keywords in Java have predefined meanings and cannot be used as identifiers, while "string" can be used as an identifier for variables, methods, or classes.
10.
Berikut ini merupakan penamaan variabel yang benar dalam Java, kecuali:
Correct Answer
D. Nilai-mhs
Explanation
The given variable names "nim_mahasiswa", "$nilai", "NAMA", and "nilai-mhs" are all valid variable names in Java. However, "nilai-mhs" is not a valid variable name because it contains a hyphen, which is not allowed in variable names in Java.
11.
Komentar program dalam Java dapat menggunakan perintah:
Correct Answer
C. // dan /* … */
Explanation
The correct answer is "// dan /* ... */" because in Java, comments can be written using double slashes (//) for single-line comments and using /* ... */ for multi-line comments. The other options mentioned (/* ... */ saja, #, and // saja) are not valid ways to write comments in Java.
12.
Berikut ini pernyataan yang benar berhubungan dengan class dan object dalam Java, kecuali:
Correct Answer
C. Object terdiri dari keyword dan method.
Explanation
The correct answer is "Object terdiri dari keyword dan method." This statement is incorrect because an object is an instance of a class and it consists of data (state) and behavior (methods), not just keywords and methods.
13.
Berikut ini merupakan tipe data dasar dalam Java, kecuali:
Correct Answer
C. String
Explanation
The given options represent different data types in Java. "long", "int", and "float" are all valid data types in Java. However, "string" is not a valid data type in Java. The correct data type for representing textual data in Java is "String" (with a capital "S"). Therefore, the correct answer is "string" because it is not a valid data type in Java.
14.
Untuk menyimpan data nim mahasiswa, tipe data yang paling tepat digunakan adalah:
Correct Answer
B. String
Explanation
The most appropriate data type to store student ID data is a string. Student ID numbers typically consist of a combination of numbers and letters, and can vary in length. Using a string data type allows for flexibility in storing and manipulating these values. Numeric data types such as int or float would not be suitable as they only allow for numerical values, while a string data type can accommodate alphanumeric characters.
15.
Salah satu operator aritmatika yang akan menghasilkan sisa hasil bagi dari 2 operand, yaitu:
Correct Answer
D. %
Explanation
Operator aritmatika yang akan menghasilkan sisa hasil bagi dari 2 operand adalah %. Operator ini disebut juga sebagai operator modulus. Ketika operand pertama dibagi dengan operand kedua, operator modulus akan mengembalikan sisa hasil bagi dari pembagian tersebut.
16.
Konsep OOP yang memungkinkan suatu class dapat menurunkan sifat ke class lain, adalah:
Correct Answer
B. Inheritance
Explanation
Inheritance is a concept in object-oriented programming that allows a class to inherit or acquire properties and behaviors from another class. It enables code reusability and promotes the concept of hierarchy in programming. With inheritance, a class can inherit attributes and methods from a parent class, known as the superclass or base class. This allows the subclass or derived class to extend or modify the functionality of the superclass while inheriting its common characteristics. Inheritance facilitates code organization, improves code readability, and reduces code duplication.
17.
Suatu method yang akan dijalankan otomatis saat object dari class dibuat, dikenal dengan:
Correct Answer
C. Constructor
Explanation
A constructor is a special method that is automatically executed when an object of a class is created. It is used to initialize the object's state and perform any necessary setup tasks. In this case, the question is asking for the term that refers to the method that is automatically executed when an object of a class is created. The correct answer is "Constructor".
18.
Apa yang dimaksud dengan method overloading?
Correct Answer
A. Method-method yang memiliki nama sama tetapi dengan parameter yang berbeda.
Explanation
Method overloading adalah ketika terdapat beberapa method dengan nama yang sama tetapi memiliki parameter yang berbeda. Hal ini memungkinkan penggunaan yang lebih fleksibel dan memudahkan pemanggilan method dengan parameter yang sesuai dengan kebutuhan. Dengan adanya method overloading, kita dapat memiliki beberapa implementasi dari sebuah method dengan nama yang sama tetapi dengan fungsionalitas yang berbeda tergantung pada parameter yang diberikan.
19.
Untuk mengakses class atas (parent class) dapat menggunakan keyword:
Correct Answer
B. Super
Explanation
The keyword "super" is used to access the parent class in Java. It is used to call the constructor, methods, and variables of the parent class from the child class. This allows the child class to inherit and utilize the functionality of the parent class.