Trap in the SCJP test

xiaoxiao2021-03-06  163

Original Ajith Kallambella

(1) Two public classes in The Same File (ILLEGAL)

(2) Main Method Calling a non-static method. (Illegal)

(3) Methods with The Same Name as the constructor (s). (This is often available)

(4) Thread Initiation with classes That Do Not Have a Run () Method.

(5) Local Inner Classes Trying to Access Non-Final Vars (ILLEGAL)

(6) Case Statements with value. Out of Permissible Range. (Byte, Int, Short, Chat)

(7) Math Class Being An Option for Immutable Classes !! (Totally Wrong!)

(8) InstanceOf is not Same as instanceof.

(9) Private constructors. (Legal)

(10) An Assignment Statement Which Looks Like a Comparison. (For example, if (a = true), it is bright to this question)

(11) System.exit () in try-catch-finally blocks. (Finally does not execute)

(12) Order of try-catch-finally block matters. (If you are wrong: error: no try before catch)

(13) main () can be declared final. (Ok)

(14) -0.0 == 0.0 IS true.

(15) a Class WITHOUT ABSTRACT METHODS CAN STILL BE DECLARED Abstract.

(16) RandomaccessFile Descends from Object and Implements DataInput and DataOutput.

(17) Map Does Not Implement Collection.

(18) Dictionary is a class, not an interface.

(19) Collection is an interface where as collections is a helper class. (I have never seen it, but it is really easy to see)

(20) Class Declarations can come in any ORDER. (That is: Class Child Extends PARENTS {} Class Parents {} This order is ok.)

(21) Forward References to Variables Gives Compiler Error.

(22) Multi Dimensional arrays can be sparce. (This sentence is: Multidimensional array) does not necessarily have a certain number of elements, such as we look into a matrix in a two-dimensional array, then in the column Elements can be incomplete, may not be aligned.)

(23) Arrays, WHETHER LOCAL OR Class-Level, Are ALWAYS Initialized.

(24) Strings Are Initialized to Null, Not Empty String.

(25) An Empty string is not The Same as a null string.

(26) a Declaration Cannot Be Labelled.

(27) "continue" must be in a loop (for, do, while). It can not appear in case constructs. (28) Primitive array types can never be assigned to each other, eventhough the primitives themselves can be assigned. (Also That is: Arrayoflongprimitives = ArrayofintegerPrimities will compile errors, but longvar = intvar is legal)

(29) a Constructor can throw any Exception.

(30) Initilializer Blocks Are Executed in the Order of Dectaration.

(31) Instance Initializer (s) Gets Executed Only The Objects Are Constructed.

(32) All Compaarisons Involving Nan and A Non-Nan Would Always Result False. (This is a blind spot for most friends)

(33) DEFAULT TYPE OF A NUMERIC LITERAL WITH A DECIMAL POINT IS DOUBLE. (I will write the Java member variable default initialization principle: member variable type Value Byte 0 Short 0 int 0 long 0l char '/ u0000' float 0.0 F Double 0.0D Boolean False All Reference Type NULLs

(34) Integer (and long) / and% can throw arithmeticexception while float / and% will never, even in case of division by zero.

(35) == Gives Compiler Error if The Operands Are Cast-Incompatible.

(36) You Can Never Cast Objects of Sibling Classes (Sharing the Same Parent), Even with an expected.

(37). Equals returns false if the object type area diffreent.it does not raise a compiler error.

(38) No Inner Class Can Have A Static Member. (But Static Inner Class CAN)

(39) File Class Has No Methods to Deal with The Contents of The File (Also The EXISTING DIRECTORY)

(40) InputStream and OutputStream is Abstract Classes, while DataInput and DataOutput Are Internet.

转载请注明原文地址:https://www.9cbs.com/read-128385.html

New Post(0)