0% found this document useful (0 votes)
6 views6 pages

Dark Code Java Inter

The document promotes a quiz platform where users can earn $5 for each question answered. It includes a completed quiz with a score of 11 out of 20, detailing questions and correct answers related to Java programming concepts. The document also highlights various programming resources and company information.

Uploaded by

sang4019
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Dark Code Java Inter

The document promotes a quiz platform where users can earn $5 for each question answered. It includes a completed quiz with a score of 11 out of 20, detailing questions and correct answers related to Java programming concepts. The document also highlights various programming resources and company information.

Uploaded by

sang4019
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Dapatkan $5 per jawaban

Hasilkan uang dari menjawab pertanyaan sederhana. Kami membayar Anda secara tunai.

Quiz Completed!
Your Score: 11 / 20
Review Your Answers:
Q1: What is the purpose of the 'finally' block in a try-catch-finally
statement?
A. It handles any exceptions that are not caught by the 'catch' block. ✗ Your
Answer
B. It executes only if an exception occurs in the 'try' block.
C. It executes regardless of whether an exception is thrown or not in the 'try'
block. ✓ Correct Answer
D. It is used to define the main logic of the program.
Correct Answer: C. It executes regardless of whether an exception is
thrown or not in the 'try' block.

Q2: Which of the following is NOT a valid access modifier in Java?


A. public
B. private
 DarkCode C. protected 
D. internal ✓ Correct Answer
Correct Answer: D. internal

Q3: What is the difference between '==' and '.equals()' in Java


when comparing objects?
A. '==' compares the object's values, while '.equals()' compares the object's
references. ✗ Your Answer
B. '==' compares the object's references, while '.equals()' compares the object's
values. ✓ Correct Answer
C. '==' and '.equals()' both compare the object's values.
D. '==' and '.equals()' both compare the object's references.
Correct Answer: B. '==' compares the object's references, while '.equals()'
compares the object's values.

Q4: Which data structure follows the LIFO (Last-In, First-Out)


principle?
A. Queue
B. Stack ✓ Correct Answer
C. Linked List
D. Array
Correct Answer: B. Stack

Q5: What is the purpose of the 'volatile' keyword in Java?


A. It prevents a variable from being garbage collected.
B. It ensures that a variable is always read directly from main memory, not from a
thread's cache. ✓ Correct Answer
C. It makes a variable immutable. ✗ Your Answer
D. It declares a variable as a constant.
Correct Answer: B. It ensures that a variable is always read directly from
main memory, not from a thread's cache.

Q6: Which of the following is an example of method overloading?


A. Having two methods with the same name and different return types.
B. Having two methods with the same name and same parameters.
C. Having two methods with the same name and different parameter lists. ✓
Correct Answer
D. Having two methods in different classes with the same name.
Correct Answer: C. Having two methods with the same name and different
parameter lists.

Q7: What is the purpose of the 'super' keyword in Java?


A. To call the current class's constructor.
B. To call the parent class's constructor or access its members. ✓ Correct Answer
C. To create a new instance of a class.
D. To delete an object from memory.
Correct Answer: B. To call the parent class's constructor or access its
members.

Q8: Which interface must be implemented to enable sorting of


custom objects using `[Link]()`?
A. Serializable ✗ Your Answer
B. Iterable
C. Comparable ✓ Correct Answer
D. Cloneable
Correct Answer: C. Comparable

Q9: What is the difference between an interface and an abstract


class in Java?
A. An interface can have concrete methods, while an abstract class cannot. ✗ Your
Answer
B. An abstract class can have multiple inheritance, while an interface cannot.
C. A class can implement multiple interfaces but can only extend one abstract
class. ✓ Correct Answer
D. Interfaces can have instance variables, while abstract classes cannot.
Correct Answer: C. A class can implement multiple interfaces but can only
extend one abstract class.

Q10: What is the role of the Garbage Collector in Java?


A. To allocate memory for new objects.
B. To manage threads and concurrency.
C. To automatically reclaim memory occupied by objects that are no longer in
use. ✓ Correct Answer
D. To compile Java code into bytecode.
Correct Answer: C. To automatically reclaim memory occupied by objects
that are no longer in use.

Q11: Which of the following is a checked exception in Java?


A. NullPointerException
B. ArrayIndexOutOfBoundsException
C. IOException ✓ Correct Answer
D. IllegalArgumentException
Correct Answer: C. IOException

Q12: What is the purpose of the `transient` keyword in Java?


A. It makes a variable accessible from any class. ✗ Your Answer
B. It prevents a variable from being serialized. ✓ Correct Answer
C. It makes a variable immutable.
D. It declares a variable as constant.
Correct Answer: B. It prevents a variable from being serialized.

Q13: What is a Singleton design pattern?


A. A pattern that creates multiple instances of a class.
B. A pattern that ensures only one instance of a class is created. ✓ Correct Answer
C. A pattern for managing multiple threads.
D. A pattern for creating immutable objects.
Correct Answer: B. A pattern that ensures only one instance of a class is
created.

Q14: What is the purpose of the `instanceof` operator in Java?


A. To create a new instance of a class.
B. To check if an object is an instance of a particular class or interface. ✓ Correct
Answer
C. To compare two objects for equality.
D. To determine the data type of a variable.
Correct Answer: B. To check if an object is an instance of a particular class
or interface.

Q15: Which of the following collection classes implements the Map


interface?
A. ArrayList
B. LinkedList
C. HashSet
D. HashMap ✓ Correct Answer
Correct Answer: D. HashMap

Q16: What is the difference between `String`, `StringBuilder`, and


`StringBuffer` in Java?
A. `String` is mutable, while `StringBuilder` and `StringBuffer` are immutable. ✗ Your
Answer
B. `String` is immutable, `StringBuilder` is mutable and not thread-safe, and
`StringBuffer` is mutable and thread-safe. ✓ Correct Answer
C. `String` and `StringBuffer` are mutable, while `StringBuilder` is immutable.
D. They are all immutable and thread-safe.
Correct Answer: B. `String` is immutable, `StringBuilder` is mutable and not
thread-safe, and `StringBuffer` is mutable and thread-safe.

Q17: What is the purpose of the `@Override` annotation in Java?


A. To create a new method in a subclass.
B. To indicate that a method is being overridden from a superclass or interface. ✓
Correct Answer
C. To define a method as abstract.
D. To prevent a method from being overridden.
Correct Answer: B. To indicate that a method is being overridden from a
superclass or interface.

Q18: Which of the following is NOT a core concept of Object-


Oriented Programming (OOP)?
A. Encapsulation
B. Inheritance
C. Polymorphism
D. Compilation ✓ Correct Answer
Correct Answer: D. Compilation

Q19: What is the output of `[Link](10 + "20");` in


Java?
A. 30 ✗ Your Answer
B. 1020 ✓ Correct Answer
C. 2010
D. Error
Correct Answer: B. 1020

Q20: What is the purpose of generics in Java?


A. To reduce the amount of code needed to write. ✗ Your Answer
B. To improve the performance of the program.
C. To provide compile-time type safety and eliminate the need for casting. ✓
Correct Answer
D. To allow multiple inheritance.
Correct Answer: C. To provide compile-time type safety and eliminate the
need for casting.

Go Back to Quiz Selection

Dapatkan $5 per jawaban Buka


Hasilkan uang dari menjawab pertanyaan sederhana. Kami membayar Anda secara tunai. MetroOpinion

DarkCode
Accelerate your coding journey with our comprehensive learning platform and developer resources.
Stay Updated
Your email Join

Learn
Programming Language
Web Development
AI & Data Science
AI & Machine Learning
Practice Quiz

Resources
Tutorials
Cheatsheets
Code Challenges
Developer Tools

Company
About Us
Careers
Contact
Privacy Policy
Terms & Conditions
© 2025 DarkCode. All rights reserved.

You might also like