JAVAÈÏÖ¤¸ñÁÖÄ£ÄâÊÔÌâÈý´ð°¸¼°½âÎö
À´Ô´£ºÓÅÒ×ѧ  2009-11-28 15:49:08   ¡¾ÓÅÒ×ѧ£ºÖйú½ÌÓý¿¼ÊÔÃÅ»§Íø¡¿   ×ÊÁÏÏÂÔØ   ITÊéµê
ÎÄÕÂÒ³ÄÚ²¿300*250¹ã¸æλ

answer to question 11)

2) compilation and no output at runtime

because the method in base called base has a return type it is not a constructor and there for does not get called on creation of an instance of its child class in

for more information on this topic go to

answer to question 12)

4) compilation and output of hello

this type of question is particularly calculated to catch out c/c++ programmers who might expect parameter zero to be the name of the compiler.

for more information on this topic go to

answer to question 13)

1) if a class has any abstract methods it must be declared abstract itself.
3) the final modifier means that a class cannot be sub-classed
4) transient and volatile are java modifiers

an abstract class may have non abstract methods. any class that descends from an abstract class must implement the abstract methods of the base class or declare them as abstract itself.

for more information on this topic go to


answer to question 14)

2) public static void amethod(){}
4) static native void amethod()

1lQ

option 1 is not valid because it has braces and the native modifier means that the method can have no body. this is because the body must be implemented in some other language (often c/c++). option 3 is not valid because private and protected contradict themselves.

for more information on this topic go to


answer to question 15)

4) constructors are not inherited

constructors can be marked public, private or protected. constructors do not have a return type.

for more information on this topic go to

answer to question 16)
 

2) compile time error

an error occurs when the class severn attempts to call the zero parameter constructor in the class base because the base class has an integer constructor java does not provide the "behind the scenes" zero parameter constructor.

for more information on this topic go to

 

answer to question 17)

1) static methods do not have access to the implicit variable called this
2) a static method may be called without creating an instance of its class
3) a static may not be overriden to be non-static

the implicit variable this refers to the current instance of a class and thus and by its nature a static method cannot have access to it.

for more information on this topic go to


answer to question 18)

1)

char c='1';
system.out.println(c>>1);

4)

int i=1;
system.out.println(i<<1);
 

be aware that integer (not the upper case i) is a wrapper class and thus cannot be treated like a primitive. the fact that option 1 will compile may be a surprise, but although the char type is normally used to store character types, it is actually an unsigned integer type. the reason option 3 does not compile is that java has a >>> operator but not a <<< operator. ;>> operator but not a <<< operator.

for more information on this topic go to


answer to question 19)

2) an event listener may be removed from a component
3) the actionlistener interface has no corresponding adapter class

a component may have multiple event listeners attached. thus a field may need to respond to both the mouse and the keyboard, requiring multiple event handlers. the actionlistener has not matching adapter class because it has only one method, the idea of the adapter classes is to eliminate the need to create blank methods.

for more information on this topic go to


answer to question 20)

3) transient
4) volatile
 

option 1, sizeof is designed to catch out the c/c++ programmers. java does not have a sizeof keyword as the size of primitives should be consistent on all java implementations. although a program needs a main method with the standard signature to start up it is not a keyword. the real keywords are less commonly used and therefore might not be so familiar to you.

for more information on this topic go to

answer to question 21)

3) the default constructor takes no parameters
4) the default constructor is not created if the class has any constructors of its own.

option 1 is fairly obviously wrong as constructors never have a return type. option 2 is very dubious as well as java does not offer void as a type for a method or constructor.

for more information on this topic go to


answer to question 22)

1) all of the variables in an interface are implicitly static
2) all of the variables in an interface are implicitly final
3) all of the methods in an interface are implictly abstract

all the variables in an interface are implicitly static and final. any methods in an interface have no body, so may not access any type of variable


answer to question 23)

2) the + operator is overloaded for concatenation for the string class

in java strings are implemented as a class within the java.lang package with the special distinction that the + operator is overloaded. if you thought that the string class is implemented as a char array, you may have a head full of c/++ that needs emptying. there is not "wrapper class" for string as wrappers are only for primitive types.

if you are surprised that option 4 is not a correct answer it is because length is a method for the string class, but a property for and array and it is easy to get the two confused.PqfGFk?3\OE*€h B[±¾×ÊÁÏÀ´Ô´ÓÚ¹óÖÝѧϰÍø http://www.gzu521.com]PqfGFk?3\OE*€h B


answer to question 24)

1) a method in an interface must not have a body
3) a class may extends one other class plus many interfaces

a class accesses an interface using the implements keyword (not uses)


answer to question 25)

3) the following statement will produce a result of zero, system.out.println(1 >>1);

although you might not know the exact result of the operation -1 >>> 2 a knowledge of the way the bits will be shifted will tell you that the result is not plus 1. (the result is more like 1073741823 ) there is no such java operator as the unsigned left shift. although it is normally used for storing characters rather than numbers the char java primitive is actually an unsigned integer type.

and for information on the size of primitives see


answer to question 26)

2) arrays elements are initialized to default values wherever they are created using the keyword new.


you can find the size of an array using the length field. the method length is used to return the number of characters in a string. an array can contain elements of any type but they must all be of the same type. the size of an array is fixed at creation. if you want to change its size you can of course create a new array and assign the old one to it. a more flexible approach can be to use a collection class such as vector.

answer to question 27)

2) output of "hello crowle"

this code is an example of a short circuited operator. because the first operand of the || (or) operator returns true java sees no reason to evaluate the second. whatever the value of the second the overall result will always be true. thus the method called place is never called.


answer to question 28)

4) none of the above;

you may access methods of a direct parent class through the use of super but classes further up the hierarchy are not visible


answer to question 29)

2) a method with the same name completly replaces the functionality of a method earlier in the hierarchy

option 3 is more like a description of overloading. i like to remind myself of the difference between overloading and overriding in that an overriden method is like something overriden in the road, it is squashed, flat no longer used and replaced by something else. an overloaded method has been given extra work to do (it is loaded up with work), but it is still being used in its original format. this is just my little mind trick and doesn't match to anything that java is doing.


answer to question 30)

2) the / operator is used to divide one value by another
3) the # symbol may not be used as the first character of a variable

the % is the modulo operator and returns the remainder after a division. thus 10 % 3=1
the $ symbol may be used as the first character of a variable, but i would suggest that it is generally not a good idea. the # symbol cannot be used anywhere in the name of a variable. knowing if a variable can start with the # or $ characters may seem like arbitrary and non essential knowlege but questions like this do come up on the exam.

ÉÏÒ»Ò³  [1] [2] [3] [4] [5] ÏÂÒ»Ò³

ÔðÈα༭£ºÐ¡²Ý

¼ÆËã»úÎÄÕÂÒ³µ×²¿500*200¹ã¸æ
ÎÄÕÂËÑË÷:
 Ïà¹ØÎÄÕÂ
¼ÆËã»úµ×²¿580*90¹ã¸æ
ÎÄÕÂÒ³ÓÒ²àµÚÒ»330*280¹ã¸æ
¼ÆËã»úÎÄÕÂÒ³×ÊѶÍƼö
ÎÄÕÂÒ³330³ß´ç¹È¸è¹ã¸æλ
ÈÈÃſγÌÅàѵ