1.
Abstract class name {
PRIVATE STRING NAME;
Public Abstract Boolean isstupidName (String Name) {}
}
What is wrong with the heroes?
Answer: wrong. Abstract Method must end with a semicolon and do not bring a curly bracket.
2.
Public class something {
Void dosomething () {
Private string s = "";
INT L = S.LENGTH ();
}
}
Is it wrong?
Answer: wrong. No access modifiers (private, public, and protected) before local variables
. Final can be used to modify partial variables
(Final like Abstract and Strictfp
It is non-access modifier, and stricTFP can only modify Class and ME.
THOD is not a variable).
3.
Abstract class something {
Private abstract string dosomething ();
}
It seems that there is nothing wrong?
Answer: wrong. Abstract Methods cannot be modified with private
. Abstract Methods is to make subclass item IMPLEMEN
T (implementation) specific details, how can I use Private Abstract?
CT
What is the Method blocking? (Similarly, Final can't add Final before Abstract Method).
4.
Public class something {
Public Int Addone (Final INT X) {
Return x;
}
}
This is more obvious.
Answer: wrong. INT X is modified to Final, meaning X cannot be modified in Addone Method.
5.
script>
Public class something {public static void main (String [] args) {
Other o = new other ();
New Something (). Addone (O);
}
Public void addone (Final Other O) {
O.I ;
}
}
Class other {
Public INT I;
}
It is very similar to the above, it is about Final problem, is this wrong?
Answer: Correct. In Addone Method, the parameter O is modified into final. If we modified O's Reference in Addone Method
(Such as: o = new other ();), then the question is also wrong as the above example. But here is modified here is
MEMBER VAIRABLE
(Member variable), while the Reference Reference did not change.