Nothing to do much .... atleast today
but can avoid this ranch .. so ..
Suggestions :
1. first read RHE then take mocks, after each mock make a list of quetions which were wrong ... and WHY? clear the concept or topic... best place for discussion.... I won't tell
2.between mocks give some break.
3. Read Khalid... without it u will feel something is missing ... and yes it helps you to revise the concepts.
4. again mocks ... repeat step 2.
5.JQ+ is good as it gives real simulation and lot of que. on ur desktop. BUT do not take them for there gaurantee.... it is good as you get lot of questions together... AND NEVER start with JQ+... Keep it for last 10-15 days... never trust it's answer blindly(I found lot of them to be , if not wrong, then not with correct explanation.).... It's good means you get lot questions at one place, that's all.
6.
]http://www.javaranch.com/maha/_Mock_Exams/_mock_exams.html] Do visit this page[/URL]
I have myself noted down some points(I think 99.99% they are correct, some I copy/paste from sites) .. but still plz correct me if u find any point wrong.
so here goes list ...
==================================
* We can declare array of element ZERO.
* Java do not have any operator like &&=
* instanceof operator always return false for null value.
* null value can be casted but do remember it is of no use to cast null value
* you can not use more than '4' digits in case of character constant.
* You can give char constants value between 0-255.
* Char constant '\101' is valid as it is representing the value in "octal", which is equivalent to 65.
* Values for char constant '\u000A' and '\u000D' is not valid as they represent line breaks.
* CODE:
while(false)
{
System.out.println("Hello");
}
will give you error " Unreachable statement ".
* We cannot declare a static variable inside a non-static inner class but static final variable is allowed as the compiler will treat it as a constant.
* Class H and class G has no relation(i.e if two class has no relation) with each other so both instanceof and == operator will give you compile time error.
* Interface methods can not be native, static, synchronized, final, private, or protected.
* Interface fields can't be private or protected. They are by default public static final. The final variable must be initialized
* transient variables can't be members of interfaces.
* Volatile variables can't be final or members of interfaces.
* Math.abs() will return the argument itself, if it is equivalent to Integer.MIN_VALUE or Long.MIN_VALUE. Exa Math.abs(-2147483648) return -2147483648. if litral is less than MIN_VALUE then compile time error will occur "Decimail must be in the range of so and so".
* We can use negative argument in indexOf() and lastIndexOf() method of String class. In such case it will start searching from zero.
* In switch statement case: arg
arg can be either Integer LITRAL or variable which is CONSTANT or expression which is CONSTANT.
* Methods can not have static variable. mehod1() { static int I ; } won't compile.
*
Also from Vel's notes as provided by Ajith Kallambella
- Two public classes in the same file.
- main() method calling a non-static method.
- Methods with the same name as the constructor(s).
- Thread initiation with classes that don't have a run() method.
- Local inner classes trying to access non-final vars.
- case statements with values out of permissible range.
- Math class being an option for immutable classes !!
- instanceOf is not same as instanceof
- Private constructors
- An assignment statement which looks like a comparison if ( a=true)...
- System.exit() in try-catch-finally blocks (if before finally, finally would not execute).
- Uninitialized variable references with no path of proper initialization.
- Order of try-catch-finally blocks matters.
- main() can be declared final.
- -0.0 == 0.0 is true.
- A class without abstract methods can still be declared abstract.
- RandomAccessFile descends from Object and implements DataInput and DataOutput.
- Map doesnot implement Collection.
- Dictionary is a class, not an interface.
- Collection is an Interface where as Collections is a helper class.
- Class declarations can come in any order ( derived first, base next etc. ).
- Forward references to variables gives compiler error.
- Multi dimensional arrays can be sparce ie., if you imagine the array as a matrix, every row need not have the same number of columns.
- Arrays, whether local or class-level, are always initialized,
- Strings are initialized to null, not empty string.
- An empty string is NOT the same as a null string.
- A declaration cannot be labelled.
- continue must be in a loop( for, do , while ). It cannot appear in case constructs.
- Primitive array types can never be assigned to each other, eventhough the primitives themselves can be assigned. ie., ArrayofLongPrimitives = ArrayofIntegerPrimitives gives compiler error eventhough longvar = intvar is perfectly valid.
- A constructor can throw any exception.
- Initilializer blocks are executed in the order of declaration.
- Instance initializer(s) execute ONLY IF the objects are constructed.
- All comparisons involving NaN and a non-Nan would always result false.
- Default type of a numeric literal with a decimal point is double.
- integer (and long ) operations / and % can throw ArithmeticException while float / and % will never, even in case of division by zero.
- == gives compiler error if the operands are cast-incompatible.
- You can never cast objects of sibling classes( sharing the same parent ), even with an explicit cast.
- .equals() returns false if the object types are different.It does not raise a compiler error.
- No inner class can have a static member.
- File class has NO methods to deal with the contents of the file.
- InputStream and OutputStream are abstract classes, while DataInput and DataOutput are interfaces
* Always see carefully overLOAD OR overRIDE
* In switch statement case: arg
arg can be either Integer LITRAL or variable which is CONSTANT or expression which is CONSTANT.
Hi ,
I got messages regarding information on the exan Here it goes.
The changes in the code were made last year in October not this year.The rules are the same :
2 hours, 59 questions, 61% to pass. I could get 51 questions correct of 59 questions.
I started with around 7 questions on threads.
You should know how to work with threads running together and calling synchronized or non- synchronized methods or methods having synchronized blocks.
In IO you need to be clear with the constructors.....can i put OutpuStream in FileOutputStream ??? like this.
Be clear with the operators and loops and how the continue , switch, break behave in all the different ways. Putting default in a switch in the beginning, middle or at the end when the passed integer is there as a case....or not there....
You should know the main methods of the StringBuffer, String, Math Class....with their return types.
You should know in awt how different layouts would place things... their defaults - alignment, positions, etc,
On the whole its cool,
take lots of mock tests,
cheers,
* Careful about final var... they can not be changed....
* main() can not access member var directly ... if member is not static.... As main() is static method......
List all the things that you want to remember during the exam such as
All awt event listeners and their methods and the arguments to that method. Next to each event listener, write down the awt component that can generate that event.
Write down all the collections interfaces and their features.Then next to each interface, write the name of the class that implements that interface.
Write down the names of all stream readers/writers
Write them down accoring to their inheritance hierarchy
Write down all the methods available in the File class- along with their signature.
Write down the constructors of the thread class and the mehods- at least the one's covered in RHE.
Write down all the methods of the Object class.
Write down all the methods of the String and StringBuffer class- one has append and the other has concat - both do the same thing.
You can add anything else you want. But make this on your own. Go through the books, go through the API and compile this.
* Read options very clear fully ... give weightage to each
word.
* Always see the no of correct answer.
* The moment see the constructor with arguments.... See the extending class can be created or not ... in all prob...
* See the ; as the end of statement.
* Static method .. check it out .. accessing any instance variable or calling any member method... it CAN NOT do so .
I had 6 questions on threads. so at least remember api of Thread and Runnable.
collection: list, set, map, vector, arraylist, their constructors/methods and characteristics
IO: constructors for InputStream, FileInputStream etc.
* While checking range +tive range should be odd and -tive range should be even number.
* If package stmt is there ... then make sure that access is public .. if that thing is going to be accessed outside the package.
*
* The genral rule is that ~i = -i-1 (Exa: ~3 = -3 - 1 = -4)
* Rules are the layout manager (GridLayout) adds another column when
necessary and rearrange all the element again. One
exception to it is when there are only one column,
extra element will be added to the same column.
* \u000a and \u000d are line terminators. So they should not be used in java source program.
* Singaniture for finalize() method is:
protected void finalize() throws Throwable
You can override it as protected or public and can throw any exception.
* When you add an object to HashSet object using add(Object obj) method then if object is equal to some object inside the HashSet, the operation just failed and return false.
* HashSet allows null.
* Null can not be assigned to primitive data type.
* Math.ceil(-0.5) = -0.0
* Math.round(-5.5) = -5
* Math.round(5.5) = 6
* Math.round(5.49) = 5
* Math.round(-5.49) = -5
* GridLayout always ignores components preferred size.
* getCanonicalPath() = C:\java\12345.msg
* getAbsolutePath() = C:\java\dir1\..\12345.msg
* Non static inner classes can not have static members.
*
Applet can not have menu as it is not subclass of Frame.
* File class method renameTo( ) takes File object as param.
* System.out.println(null) will not compile.
1. ExamCram -
* Wrapper classes are immutable.
* Equals() never throw Exception... it will return false.
*
2. JQ+ Demo
* Object has two protected methods finalize() and clone()
* If method is static then see if it is accessing any non static member variable.(it can not access non static-member var)
* Evalution of operand is Left to Right.... Note it ... a[i][i=3][i] = a[4][3][3] if I = 4.
*
2. Kahild
* methods are public by default in interface, but not in class, so make sure if any class is implementing any method from any interface then it has a access modifier as public in class.
3. JQ+
* if any sub class is in different package then baseClassObject.memVar can not be accessed in class body of subclass, that can be accessed by subClassObject only . [IMP]
* compiler checks whether if(arg) arg returns boolean or not .. if not then compile time error.
* About clone( ) it is protected and may throw CloneNot SupportedException
x.clone() != x will be true, means they are not pointing to same memory
and that the expression:
x.clone().getClass() == x.getClass() will be true, as they are object of same class
but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x) will be true.
In cloning constructor is not called while creating object.
4. JavaCaps Mock Exam
* Boolean is valid identifier ... do not assume it to be keyword... only KEYWPRD/RESERVED words can not be valid identifier.
* Import statement CAN not appear any where
* If Parent class default constructor throws Exception then derived construtor must either catch it or thorw it again(include throws clause).
* byte ver's binary arithmetic operation can not be assigned to LHS byte var as they are promoted to integer. Cast is needed.
*
5. JQ+ Test 2
* List does not have setRows() method i.e. once no of items can be displayed set in the CONSTRUCTOR then it can not be changed.
*
6. JQ+ Test3
* Inner classes do not have same name as enclosing classes.
* If ther is no stmt after try/catch/finally ........ then all blocks can return .
* Flow layout: .. flow of putting componenet is left to right ... and in the center of screen.
* To extract (positive num) byte from int & with 0xff.
* hashCode() returns a int.
* nearly all Hashtable methods are synchronized
* BitSet has nothing to do with sets or collections.
7. JQ+ Test 4
* Non-static inner classes can contain final static fields (but not methods), without final won't compile.
* NOTE: static classes can have static member which are not final.
* Anonymous classes cannot have explict constructors, since they have no names.
* Every interface is implicitly abstract.
* Every field declaration in the body of an interface is implicitly public, static and final.
* A field in an interface must not include any of the modifiers synchronized, transient or volatile, or a compile-time error occurs.
* A method in an interface cannot be declared static, because in Java static methods cannot be abstract.
* A method in an interface cannot be declared native or synchronized, However, a method declared in an interface may be implemented by a method that is declared native or synchronized in a class that implements the interface.
* Member Variable will always be accessed by the Type of class.. not by the object that TypeVar is holding.
* >>> operators result can be negative if RHS is multiple of 0,32,64... as no shift will be there.
8. JQ+ Test 5
* If f1 represents +0.0f while f2 represents -0.0f, or vice versa, the equal test has the value false, even though 0.0f==-0.0f has the value true.
* If f1 and f2 both represent Float.NaN, then the equals method returns true, even though Float.NaN==Float.NaN has the value false.
* A NaN is not equal to NaN. So Float.NaN != Float.NaN is true.
* A break statement with no label attempts to transfer control to the innermost enclosing switch, while, do, or for statement; this statement, which is called the break target, then immediately completes normally. If no switch, while, do, or for statement encloses the break statement, a compile-time error occurs.
* A break statement with label Identifier attempts to transfer control to the enclosing labeled statement that has the same Identifier as its label; this statement, which is called the break target, then immediately completes normally. In this case, the break target need not be a while, do, for, or switch statement.
* A continue statement with no label attempts to transfer control to the innermost enclosing while, do, or for statement; this statement, which is called the continue target, then immediately ends the current iteration and begins a new one. If no while, do, or for statement encloses the continue statement, a compile-time error occurs.
* A continue statement with label Identifier attempts to transfer control to the enclosing labeled statement that has the same Identifier as its label; that statement, which is called the continue target, then immediately ends the current iteration and begins a new one. The continue target must be a while, do, or for statement or a compile-time error occurs. If no labeled statement with Identifier as its label contains the continue statement, a compile-time error occurs.
* Can not over ride static method with non-static method... compiler error .
* processEvent () and dispatchEvent () are methods of Component class
* setSize() and setBounds are for adjusting the size of componenet.... No method is like setDimensions()..
* When RandomAccessFile is opened in "rw" mode then filePointer is at start.
* Only InputStreamReader is for customizing the Encoding.
* Make sure all var are initialized .... And not in if block as it might not initialized so compiler error ...
* '\uoooa' should not be used anywhere in java source file .
* ClassName.this.varName = this.varName
* continue with/out label but has to be with loop.
* break without label only with loop, outside loop needs label else compile time error.
JQ+ Test 6
* Objects passed to the method are never garbage collected in that method.
* FileOutputStream if opened as true (for append mode).. then it creates file if it does not exist or append the text in end.
* notify() is supposed to do notify one of the threads that were waiting on this object.
* If null is passed as parameter than most specific down to the hierarchy class param method will be called. BUT if two methods which are not form the same hierarchy are present than compiler will raise error.
* for loops mid stmt has to be boolean, first stmt should either declation(can declare & init more than 1 var BUT type should be same and written only once) or stamt. In Third you can not declare any variable.
* (long) by/d*3 => ( (long) by ) / d * 3;
* A column in TextArea is an approximate average character width that is platform-dependent.
* The Writer class has no write() method with a parameter of type char.
* Abstract Writer class's subclass must implement are write(char[], int, int), flush(), and close(). Most other methods are defined .. or are overridden by subclasses.
* Remember : variables are SHADOWED and methods are OVERRIDDEN. In Shadowing .... methods will use there class's member var(though they are shadowed).... till it is not directly accesses by using refName.VarName
* All numeric wrapper classes namely, Byte, Short, Integer, Long, Float and Double extend the Number class.
* A constructor can not be final, static or abstract.
* round(2. 5) = 3 => trunc(j + 0.5) NOTE: round(-2. 5) = -2
* suspend(), resume() and stop() are deprecated methods because they don't give the Thread a chance to release shared resources which may cause deadlocks.
* Main thread created by JVM is not deamon thread.
* ClassName.this.varName = this.i for that class.
* String String = ""; //This is valid.
String : for(int i = 0; i< 10; i++) //This is valid too!
* To convert it to base 8:
668/8 => 83 and Remainder = 4
83/8 => 10 and Remainder = 3
10/8 => 1 and Remainder = 2
1/8 => 0 and Remainder = 1 So it is 1234 !
* If f1 and f2 both represent Float.NaN, then the equals method returns true, even though Float.NaN==Float.NaN has the value false.
* If f1 represents +0.0f while f2 represents -0.0f, or vice versa, the equal test has the value false, even though 0.0f==-0.0f has the value true.
JQ+ Test 7
* Abstract class can have final or static method.
* Interface ... while defining methods of interface .... Make them public else compile time error .
* Classes do not extend interfaces
* ========================= FROM JQ+ ===================================
* Remember these rules for primitive types:
1. Anything bigger than an int can NEVER be assigned to an int or anything smaller than int ( byte, char , short) without explicit cast.
2. CONSTANT values up to int can be assigned (without cast) to variables of lesser size ( eg. short to byte) if the value is representable by the variable.( ie. fits into the size of the variable).
3. operands of mathematical operators are ALWAYS promoted to ATLEAST int. (ie. for byte * byte both bytes will be first promoted to int.) and the return value will be ATLEAST int.
4. Compound assignment oprators ( +=, *= etc) have strange ways so read this carefully:
A compound assignment expression of the form E1 op= E2 is equivalent to E1 = (T)((E1) op (E2)), where T is the type of E1, except that E1 is evaluated only once.
Note that the implied cast to type T may be either an identity conversion or a narrowing primitive conversion.
For example, the following code is correct:
short x = 3;
x += 4.6; // no compilation error / runtime error ... data may be lose .. i.e byte b = 127 ; b += 50;// NO ERROR
and results in x having the value 7 because it is equivalent to:
short x = 3;
x = (short)(x + 4.6);
=======================================================================
* No trim() method in StringBuffer.
* In GridbagConstraint ..... give notice to X , Y as they decide .. hori or verti..
JQ+ Test 8
* Always see if there is no stmt ... then there will no compile error of non-Reachable stmt.
* while(false){ }
* RAF throws EOFException if not returning int as -1.
JQ+ Test 9
* If catch throws any exception still finally will be executed.
* method prototypes in interfaces can never be static
==============================================
in last JQ+ test I got 85%.....
thats all one I have
Thanks to all Rancher for there help
Specially to bartenders
and yes if you have TIME then first try to search and write a program .. Most the time I did not post que. as I got the ans and PLUS lot of extra knowledge through search.
ALL THE BEST TO ALL
[ February 06, 2002: Message edited by: ravish kumar ]