Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

1. Which of the following is a correct definition of a class in Java?

View

2. What is an object in Object-Oriented Programming?

View

3. What is the keyword used to create an object in Java?

View

4. Which of the following is true about constructors?

View

5. Which of the following statements is correct regarding classes and objects?

View

6. What will be the output of the following code?

View

7. What is the purpose of a class in Java?

View

8. Which of the following is not a feature of Object-Oriented Programming?

View

9. How can we access the members of a class?

View

10. What is the default access modifier for members in a class in Java?

View

1. Which of the following is a correct definition of a class in Java?

A blueprint for creating objects.
A type of variable.
A runtime error handler.
A data type for storing multiple values.

2. What is an object in Object-Oriented Programming?

A function that performs an action.
An instance of a class.
A method inside a class.
A type of variable.

3. What is the keyword used to create an object in Java?

new
object
class
instance

4. Which of the following is true about constructors?

They can have a different name from the class.
They are called automatically when an object is created.
They return a value.
They are used to destroy objects.

5. Which of the following statements is correct regarding classes and objects?

A class is an instance of an object.
An object defines the structure of a class.
An object is an instance of a class.
A class and an object are the same.

6. What will be the output of the following code?

<p>class Car {<br>&nbsp; &nbsp; String brand;<br>&nbsp; &nbsp; int year;<br>&nbsp; &nbsp; Car(String b, int y) {<br>&nbsp; &nbsp; &nbsp; &nbsp; brand = b;<br>&nbsp; &nbsp; &nbsp; &nbsp; year = y;<br>&nbsp; &nbsp; }<br>}<br><br>public class Main {<br>&nbsp; &nbsp; public static void main(String[] args) {<br>&nbsp; &nbsp; &nbsp; &nbsp; Car c = new Car("Toyota", 2022);<br>&nbsp; &nbsp; &nbsp; &nbsp; System.out.println(c.brand + " " + c.year);<br>&nbsp; &nbsp; }<br>}<br><br></p>

Toyota 2022
Compilation Error
Runtime Error
null 0

7. What is the purpose of a class in Java?

To handle errors.
To execute a program.
To define the blueprint for objects.
To create variables.

8. Which of the following is not a feature of Object-Oriented Programming?

Encapsulation
Polymorphism
Procedural logic
Abstraction

9. How can we access the members of a class?

By creating an object of the class.
By importing the class.
By writing the class name.
By declaring the members as static.

10. What is the default access modifier for members in a class in Java?

public
private
protected
default (package-private)