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 is responsible for executing Java applications and provides the necessary runtime environment. It includes the Java Virtual Machine (JVM) and other libraries and components required to run Java programs. JRE does not include the Java development tools like the Java Compiler (JDK) or J2SDK (Java 2 Software Development Kit). Therefore, JRE is the correct answer as it is specifically designed for running Java applications.
2.
Berikut ini merupakan jenis bahasa program yang berbasis compiler (compiled programming), kecuali:
Correct Answer
C. Perl
Explanation
The given options consist of programming languages that are based on compilers, except for Perl. Java, C, and Pascal are all compiled programming languages that require a compiler to convert the source code into machine code or bytecode. However, Perl is an interpreted programming language, which means it does not need to be compiled before execution. Instead, the Perl interpreter reads and executes the code directly. Therefore, Perl is the correct answer as it is not a compiled programming language.
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 to run on mobile devices. J2ME, or Java 2 Micro Edition, is specifically designed for resource-constrained devices like mobile phones. It provides a platform for developing applications that can run efficiently on mobile devices with limited processing power, memory, and display capabilities. J2SDK, Applet, and Servlet are not specifically designed for mobile devices and may not provide the necessary features and optimizations required for mobile application development.
4.
Pengecekan tipe data di Java dilakukan saat:
Correct Answer
A. Program dikompilasi.
Explanation
In Java, type checking is performed during the compilation of a program. This means that any errors or mismatches in the types of variables or expressions will be detected and reported by the compiler before the program is executed. This helps to ensure that the program is syntactically correct and reduces the likelihood of runtime errors related to type mismatches. Therefore, the correct answer is "Program dikompilasi."
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 otomatis yang disebut "garbage collector". Garbage collector bertugas untuk menghapus atau membebaskan memori yang tidak lagi digunakan oleh program. Proses ini dilakukan secara otomatis oleh Java, sehingga pengguna tidak perlu secara manual menghapus memori yang tidak digunakan. Dengan adanya garbage collector, program Java menjadi lebih efisien dalam penggunaan memori dan mencegah terjadinya memory leak.
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 secara terstruktur, 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, used to create reusable components. It provides a set of guidelines for creating Java classes that can be easily integrated into different development environments. Therefore, JavaBeans is not a valid option for an editor 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 correct answer is "Method main() harus ada dalam setiap class program Java". This statement is incorrect because it is not necessary for every class in a Java program to have a main() method. The main() method is only required in the class that serves as the entry point for the program. Other classes can be created without a main() method.
9.
Berikut ini merupakan keyword yang terdapat dalam Java, kecuali:
Correct Answer
D. String
Explanation
The given keywords are "if", "break", and "goto". These are all valid keywords in the Java programming language. However, "string" is not a keyword in Java. It is a class that represents a sequence of characters and is used to manipulate strings in Java.
10.
Berikut ini merupakan penamaan variabel yang benar dalam Java, kecuali:
Correct Answer
D. Nilai-mhs
Explanation
The variable "nilai-mhs" is not a correct variable name in Java because it contains a hyphen ("-"). In Java, variable names cannot contain special characters like hyphens. Variable names can only consist of letters, numbers, and underscores. Therefore, "nilai-mhs" is not a valid variable name 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 the double forward slash (//) for single-line comments and the forward slash and asterisk (/* ... */) for multi-line comments.
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 given statement "Object terdiri dari keyword dan method" is incorrect. Objects in Java do not consist of keywords and methods. Objects are instances of classes and they have state (data) and behavior (methods). The statement is incorrect because it implies that objects are composed of keywords and methods, which is not true.
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".
14.
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 modulo atau modulus. Ketika operand pertama dibagi dengan operand kedua, operator % akan mengembalikan sisa hasil bagi dari operasi tersebut. Misalnya, jika operand pertama adalah 7 dan operand kedua adalah 3, maka hasilnya adalah 1 karena 7 dibagi dengan 3 menghasilkan sisa 1.
15.
Konsep OOP yang memungkinkan suatu class dapat menurunkan sifat ke class lain, adalah:
Correct Answer
B. Inheritance
Explanation
Inheritance is the OOP concept that allows a class to inherit or acquire the properties and behaviors of another class. It enables code reusability and promotes the hierarchical organization of classes. Inheritance allows a class to inherit the attributes and methods of another class, known as the parent or base class, and also allows the derived class to add its own unique attributes and methods. This concept facilitates the creation of more specialized classes based on existing ones, promoting code efficiency and modularity.
16.
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 operations. In this case, the correct answer is "Constructor" because it is the method that is executed automatically when an object is created.
17.
Apa yang dimaksud dengan method overloading?
Correct Answer
A. Method-method yang memiliki nama sama tetapi dengan parameter yang berbeda.
Explanation
Method overloading adalah konsep dalam pemrograman dimana terdapat beberapa method dengan nama yang sama, tetapi memiliki parameter yang berbeda. Dengan menggunakan method overloading, kita dapat memiliki beberapa versi dari method yang berbeda dalam hal parameter yang diterima. Hal ini memungkinkan kita untuk menggunakan method yang sama dengan cara yang berbeda tergantung pada tipe atau jumlah parameter yang kita berikan saat memanggil method tersebut.
18.
Jika suatu method dideklarasikan sebagai protected, maka:
Correct Answer
C. Method dapat diakses oleh class dimana method berada dan class turunannya.
Explanation
When a method is declared as protected, it can be accessed by the class where the method is located and its subclasses. This means that any class that extends the class where the protected method is declared can access and use that method. However, classes that are not subclasses of the class where the protected method is declared cannot access or use the method.
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. It is used when there is a need to refer to a method or variable from the parent class within the child class. By using "super", the child class can access and utilize the methods and variables defined in the parent class.