public class Printer {
public void greet() {
System.out.print("Hi");
}
}
// ...
Printer p = new Printer();
int x = p.greet();What is the result?
- A
0
- B
null
- C
Hi
- Dcheck_circle
Compile-time error
Explanation
A void method has no return value, so it cannot be assigned to an int variable.