A

Admin • 828.70K Points
Coach

Q. What is the output of the below Java program with a "this" operator?

Code:
public class TestingMethods4
{
int cakes=5;
void order(int cakes)
{
this.cakes = cakes;
}
public static void main(String[] args)
{
TestingMethods4 t4 = new TestingMethods4();
t4.order(10);
System.out.println("CAKES=" + t4.cakes);
}
}
  • (A) CAKES=5
  • (B) CAKES=0
  • (C) CAKES=10
  • (D) Compiler error
  • Correct Answer - Option(C)
  • Views: 16
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.