Discussion, about this java code [message #1715351] |
Sun, 22 November 2015 16:36 |
Choi Hyeonil Messages: 1 Registered: November 2015 |
Junior Member |
|
|
This code or information are send me To Examcollection.com or avanset.com product.
It's legal To law or economic that.
Discussion please. or this sicuation understand please. because I not native speaking English. sorry.
class X{
){}
private void one(){}
}
public class Y extends X {
Y(){}
private void two(){one();}
public static void main(String[] args) {
new Y().two();
}
}
Question
What changes will make this code compile?
it's answer that two sentence.
They are,
Changing the private modifier on the declaration of the one() method to protected
Removing the private modifier from the two() method.
But, I think that two()method private word erase, not have effect.
Answer is what that?
A Adding the public modifier to the declaration of class x
B Adding the protected modifier to the ) constructor
C Changing the private modifier on the declaration of the one() method to protected
D Removing the Y () constructor
E Removing the private modifier from the two () method
and,
I to be confused riddle is,
public class Access {
private int x = 0;
private int y = 0;
public static void main(String[] args) {
Access accApp = new Access();
accApp.printThis(1,2);
accApp.printThat(3,4);
}
public void printThis(int x, int y){
x = x;
y = y;
System.out.println("x:" + this.x + "y: " + this.y);
}
public void printThat(int x, int y){
this.x = x;
this.y = y;
System.out.println("x: " + this.x + "y: " +this.y);
}
}
this Question.
Answer is,
x:1 y:2
x:0 y:0
but,
eclipse I run this code,
x:0 y:0
x:3 y:4
I think that, x=x and y=y this coding part is a into method that, 'The assinment variable has not effeting have.
this exclamation mar, is came out eclipse coding.
How a confuse. but interesting and fun.
|
|
|
Powered by
FUDForum. Page generated in 0.02806 seconds