Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Discussion, about this java code (java coding)
icon8.gif  Discussion, about this java code [message #1715351] Sun, 22 November 2015 16:36
Choi Hyeonil is currently offline Choi HyeonilFriend
Messages: 1
Registered: November 2015
Junior Member
Razz

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{

Dead){}
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 Dead) 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.















Previous Topic:Overview Tab for Custom XML Configuration
Next Topic:Bindings are lost after copying subtree with ASTNode.copySubtree(...)
Goto Forum:
  


Current Time: Fri Apr 26 01:15:26 GMT 2024

Powered by FUDForum. Page generated in 0.02806 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top