1. Abstract class name {private string name; public abstract boolean isstupidName (String name) {}} heroes, what is wrong? 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. Any access modifier (private, PUBLIC, and Protected) cannot be placed before the local variable. Final can be used to modify local variables (Final is like Abstract and Strictfp, all non-access modifiers, Strictfp can only modify Class and Method rather than variable). 3. Abstract class something {private abstract string dosomething ();} It seems that there is nothing wrong? Answer: wrong. Abstract Methods cannot be modified in private. Abstract Methods is the specific details of the subclass item, how can I use Private to block Abstract Method? (Similar to the confstract method, Final cannot be added). 4. Public Class Something {Public Int Add (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. Public class something {public static void main (String [] args) {other o = new other (); new thing (); public void addone (Final Other O) {O.I ;} } Class Other {public Int i;} is very similar to the above, is about Final's 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 (for example: o = new other ();), then this question is also wrong. But this is modified here that the MEMBER VAIRABLE (member variable) of O, while the REFERENCE does not change. 6. Class Something {Int i; public void dosomething () {system.out.println ("i =" i);}} Is there anything wrong? Can't see it. Answer: Correct. The output is "i = 0". INT i belongs to Instant Variable (instance variable, or a member variable). Instant variable has default value. INT's default value is 0.
7. Class Something {Final Int i; public void dosomething () {system.out.println ("i =" i);}} Only one place is only one place, that is, there is a final. Is this wrong? Answer: wrong. Final INT i is a Final's Instant Variable (instance variable, or a member variable). Final Instant Variable No default value must be given a clear value before the constructor ends. Can be modified to "Final INT I = 0;". 8. Public class something {public static void main (String [] args) {something s = new something (); system.out.println ("s.dosomething () returns" DOSMETHING ());} public string dosomething ) {Return "Do Something ...";}} It looks perfect. Answer: wrong. It seems that there is no problem in main dosomething in main, after all, two Methods are in the same class. But look carefully, main is static. Static Method can't directly call Non-Static Methods. It can be changed to "S.DOSMETHING () Returns" S.DOSomething ()); ". Similarly, Static Method cannot access Non-Static Instant Variable. 9. Here, the file name of the Something class is OthersHing.java Class Something {Private Static void main (String [] Something_to_do) {system.out.println ("do something ...");}} This seems to be obvious. Answer: Correct. No one has said that the Java's Class name must be the same as its file name. But the name of the public class must be the same as the file name. 10. Interface A {int x = 0;} class b {int x = 1;} Class C Extends b IMPLEments A {public void px () {system.out.println (x);} public static void main (String [] args ) {New c (). Px ();}} answer: error. Errors occur when compiling (Error Description Different JVMs have different information, means that the unclear X call, two X matches (just like IMPORT JAVA.UTIL and Java.sql two packages Date Date) The same). For the variable of the parent class, you can use Super.x to explicit, and the attribute of the interface is implied as public static final. So you can clear it through AX.