Java Quiz: Test Your Knowledge
Java Quiz: Test Your Knowledge is a core Java concept covering java Quiz: Test Your Knowledge: 1. What is the correct way to create This topic is essential for academic learning, board exam preparation, and developing optimized real-world code.
Part 1: Basics & Syntax
1. What is the correct way to create an object called myObj of MyClass?
- A)
class myObj = new MyClass(); - B)
MyClass myObj = new MyClass(); - C)
new MyClass myObj = MyClass(); - D)
class MyClass = new myObj();
Answer: B
2. Which keyword is used to create a class in Java?
- A)
class - B)
className - C)
MyClass - D)
struct
Answer: A
3. How do you insert COMMENTS in Java code?
- A)
# This is a comment - B)
// This is a comment - C)
/* This is a comment - D)
{/* This is a comment */}
Answer: B
Part 2: OOP & Collections
4. Which keyword is used to inherit a class in Java?
- A)
inherits - B)
implements - C)
extends - D)
base
Answer: C
5. Which method can be used to find the length of a string?
- A)
length() - B)
len() - C)
getSize() - D)
getLength()
Answer: A
6. Which class is used to create a resizable array?
- A)
Array - B)
ArrayList - C)
LinkedList - D)
List
Answer: B
Try to solve these without looking at the answers. These types of questions are common in board exams and junior developer interviews!