What is the syntax for creating a new object in Java?
ClassName objectName = new ClassName();
What is the purpose of constructors in Java?
Constructors are used to initialize objects and allocate memory.
What is the difference between a class and an object in Java?
A class is a blueprint or template for creating objects, while an object is an instance of a class.
What does the 'new' keyword do in Java?
The 'new' keyword is used to create a new instance of a class and allocate memory for it.
What is method overloading in Java?
Method overloading is the practice of defining multiple methods with the same name but different parameters.
How does method overloading differ from method overriding in Java?
Method overloading involves defining multiple methods with the same name but different parameters in the same class, while method overriding involves creating a new implementation of a method inherited from a superclass in a subclass.
What is the return type of a void method in Java?
A void method does not return a value.
How do you call a void method in Java?
You simply write the name of the method, followed by parentheses and a semicolon.
Can a void method have parameters in Java?
Yes, a void method can have parameters in Java.
What is the purpose of calling a non-void method in Java?
Calling a non-void method allows you to retrieve a value or perform an action.
How do you call a non-void method in Java?
You write the name of the method, followed by parentheses and a semicolon if it's a method without parameters. If it has parameters, you pass the values inside the parentheses.