Already Passed
What will be the output of the following code?
```java
System.out.println("Java" + 3 + 2);
```
A. Java5
✔✔B. Java32
C. Java6
D. Compilation error
What is the purpose of a constructor in Java?
A. To destroy an object
B. To execute a method automatically
✔✔C. To initialize an object
D. To create a variable
Which keyword is used to create an object of a class?
1
,A. class
✔✔B. new
C. object
D. instance
What is the return type of a constructor?
A. void
B. Object
C. int
✔✔D. It has no return type
Which of the following is true about instance variables?
✔✔A. They belong to an object of a class
B. They must be static
C. They can only be final
D. They are always private
How can you call a method of another class?
2
,A. Using `this.methodName();`
B. Using `methodName();`
✔✔C. By creating an object of the class and calling `object.methodName();`
D. Methods of another class cannot be called
What does the `this` keyword represent in Java?
A. The superclass of an object
✔✔B. The current instance of a class
C. The class itself
D. A static reference
What will be the output of the following code?
```java
System.out.println(10 + 20 + "Hello");
```
A. Hello30
✔✔B. 30Hello
C. 1020Hello
3
, D. Compilation error
Which of the following is the correct way to define a method in Java?
✔✔A. `public void display() { }`
B. `method display() { }`
C. `void method display() { }`
D. `display() { }`
How do you access a static method in Java?
A. By creating an object of the class
B. By using `this.methodName();`
✔✔C. By using `ClassName.methodName();`
D. A static method cannot be accessed
What happens if a constructor is defined as private?
A. The object can only be created using `new`
B. It cannot be inherited
✔✔C. The object cannot be created from outside the class
4