answer to question 31)
1) the default layout manager for an applet is flowlayout
4) the flowlayout manager attempts to honor the preferred size of any components
the default layout manager fror an application is borderlayout. an applet will use the default of flowlayout if one is not specifically applied
answer to question 32)
3) only one instance of a static variable will exist for any amount of class instances
option 1) is more a description of a final variable. option 2 is designed to fool visual basic programmers like me as this is how you can use the keyword static in vb. the modifier static can be applied to a class (only an innner class) , method or variable.
answer to question 33)
1) java uses a system called utf for i/o to support international character sets
3) an instance of fileinputstream may not be chained to an instance of fileoutputstream
4) file i/o activities requires use of exception handling
internally java uses unicode which are 16 bit characters. for i/o java uses utf which may be more thatn 16 bits per chamore thatn 16 bits per character.
generally inputstreams can only be chained to other inputstreams and outputstreams can only be chained to other outputstreams. the piped streams are an exception to this.
answer to question 34)
1) compile time error
it wil produce an error like "abstract and native method can't have a body. this is typical of the more misleading question where you might think it is asking you about the circumstances under which the finally clause runs, but actually it is about something else.
answer to question 35)
2) compilation and run with the output "running"
this is perfectly legitimate if useless sample of creating an instnace of a thread and causing its run method to execute via a call to the start method. the thread class is part of the core java.lang package and does not need any explicit import statement. the reference to a thread target is an attempt to mislead with a reference to the method of using the runnable interface instead of simply inheriting from the thread super class.
answer to question 36)
1) randomaccessfile raf=new randomaccessfile("myfile.txt","rw");
the randomaccessfile is an anomaly in the java i/o architecture. it descends directly from object and is not part of the streams architecture
answer to question 37)
2) public int amethod(int i, int j) {return 99;}
3) protected void amethod (long l){}
4) private void anothermethod(){}
option 1 will not compile on two counts. one is the obvious one that it claims to return an integer. the other is that it is effectivly an attempt to redefine a method within the same class. the change of name of the parameter from i to z has no effect and a method cannot be overriden within the same class.
answer to question 38)
1) code must be written to cause a frame to close on selecting the system close menu
2) the default layout for a frame is the borderlayout manager
4) the gridbaglayout manager makes extensive use of the the gridbagconstraints class.
you can change the layout manager for a frame or any other container whenever you like
answer to question 39)
4) the code will compile without error
there are no restrictions on the level of nesting for inner/nested classes. inner classes may be marked private. the main method is not declared as public static void main, and assuming that the commandline was java droitwich it would not be invoked anyway.
answer to question 40)
1) super.oak=1;
2) oak=33;
3) base.oak=22;
because the variable oak is declared as static only one copy of it will exist. thus it can be changed either through the name of its class or through the name of any instance of that class. because it is created as an integer it canot be assigned a fractional component without a cast.
责任编辑:小草