© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

Home Placements Interview Questions Java Interview Questions And Answers Java Interview Questions On Operators ▼

Java Interview Questions On Operators

28. What is the result of the following code?
public class MyTest {
int x = 30;
public static void main(String args[]) {
int x = 20;
MyTest ta = new MyTest();
ta.method(x);
System.out.println("The x value is " + x);
}
void method(int y){
int x = y * y;
}
}
[a] The x value is 20.
[b] The x value is 30.
[c] The x value is 400.
[d] The x value is 600.

Answer

[a] The x value is 20

29. What is the output of the following program?
public class TestArg {
int x = 100;
public static void main(String args[]) {
TestArg ta = new TestArg();
ta.method(ta);
}
void method(TestArg ta){
int x = 30;
System.out.println("The x value is " + ta.x);
method1(ta, x);
System.out.println("The x value is " + ta.x);
}
void method1(TestArg ta, int i ) {
ta.x += i;
}
}
[a] The x value is 100.
[b] The x value is 30.
[c] The x value is 130.
[d] The x value is 70.

Answer
[a] The x value is 100.
[c] The x value is 130.

Previous End
1 2 3 4 5 6 7
SLogix Student Projects
bottom