A
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);
}
}
{
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);
}
}
- Correct Answer - Option(C)
- Views: 16
- Filed under category Java
- Hashtags:
Discusssion
Login to discuss.