ADP Interview Question
Developer Program EngineersCountry: United States
Let's actually format the code and see if it makes more sense:
class OdemoA
{
int i,j;
void function1(int i) {
System.out.println(i);
System.out.println("Inside function()");
}
void function2(Area a1) {
if(a1!=null) {
a1.i=203;
a1.j=115;
}
System.out.println(a1);
System.out.println("end of function2()");
}
public static void main(String args[]) {
OdemoA d1 = new OdemoA();
Area a2 = new Area();
d1.function2(a2);
System.out.println(a2.i);
System.out.println("end main");
}
}
What is an Area? Assuming that area is something like this:
then the code will operate just fine. It should execute and output the following
Given that you have ints i and j floating around in the OdemoA class which is unrelated to Area, that could be a problem. There's some sort of ambiguous relationship between OdemoA and Area that just isn't explained.
- zortlord July 14, 2015