Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!

Anthony Roy

Greenhorn
+ Follow
since Oct 08, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anthony Roy

Thanks people! I know I didn't post much, but I've been searching the forum for the past couple of weeks, and generally found the answer to any questions I had!
Thanks to Dan Chisholm in particular, whose mock exams and topic sets made the exam seem a little dull...
[ October 22, 2003: Message edited by: Anthony Roy ]
[ October 22, 2003: Message edited by: Anthony Roy ]
17 years ago
This is designed to not only tell you the precedence of the operations, but also how many operators at each level (count the letters in each word of the mnemonic). Well, it helped me :-):
Leave On Undies About Sad Couples Bed So TAntalizingly.
Language(5): . (method/instance invocation)
() (Parameters to a method)
[] (Array index)
-- ++ Pre inc/dec
Object(2): (cast), new
Unary(6): +,-,!,~,++,-- (post inc/dec)
Arithmetic(5): *,/,%,+,-
Shift(3): >>, >>>, <<
Comparison(7): <,>,<=,>=,==,!=, instanceof
Bitwise(3): &, ^, |
Shortcut(2): &&, ||
Ternary(1): ? :
Assignment(12): =, +=, -=, *=, %=, /=,
&=, ^=, |=, >>=, >>>=, <<=

You're more than ready for the exam


Cool - it's on Tuesday
The JLS says this:
15.28 Constant Expression
ConstantExpression:
Expression
A compile-time constant expression is an expression denoting a value of primitive type or a String that is composed using only the following:
* Literals of primitive type and literals of type String
* Casts to primitive types and casts to type String
...
i.e. Objects cannot be constant expressions, and new String("abc") is an Object (and not merely a string literal).
It seems to me that a good way of thinking about strings is somewhere between primitives and Objects, String objects seem to me to be a sort of wrapper around a string literal, much like Integer is a wrapper around int, but with automatic wrapping and unwrapping enabled (much as the Integer and other wrapper classes will behave in J2SDK1.5).
Of course the technical details may be much different to this, but I find it a good way to understand what is going on in these cases.
Exam 17, Q2
import java.util.*;
class I {
public static void main (String[] args) {
Object i = new ArrayList().iterator();
System.out.print((i instanceof List)+",");
System.out.print((i instanceof Iterator)+",");
System.out.print(i instanceof ListIterator);
}}
Are we really expected to know *how* the Collection classes are implemented?
The result of i instanceof ListIterator returns false in this case. However, if the collection was instead a LinkedList, it would return true! (LinkedList simply forwards its iterator method to its listIterator method.
I think a fairer question would be based merely around the Iterators themselves assuming that it wishes to test knowledge of which of the iterators is a subinterface of which.
Thanks to Dan BTW for creating so many questions which really make you think! I've been scoring in the 90-100% mark in most of the other test exams I've taken - it's been down to 60-75% on average on Dan's questions...
Whoops! Cut and paste error I'm afraid...
There are loads of diffrent Open source licenses out there, but the GNU ones essentially say this:
GPL (General Public License): You can use this software, modify it, sell it or what ever you want, as long as you make the source code of your modification freely available and license it under the same license.
LGPL (Lesser GPL): You can use or modify this software and incorporate it in your own code, as long as you make the source code for this software (and any modifications to this software) freely available and licensed under the LGPL.
The LGPL is usually used for libraries which may be used inside proprietary code (but the LGPL'ed code must remain open source). The GPL prohibits any software using the code to be anything other than GPL'ed (ie. no use for proprietary software).
This is the jist of the licences as far as I am aware.
I have seen quite a few threads on this topic. The Java Language Specification notes that Identifiers cannot match any keyword, true, fals or null. In addition, the following requirements are enforced:
Starting character: Must be a Java Letter.
Other Characters: Must be a Java Letter or a Java Digit.
The definitions of Java Letter and Java Digit are suitably vague! It seems that the only sure way of knowing is by using the Character.isJavaIdentifierStart(char c) and Character.isJavaIdentifierPart(char c) methods.
On my (UK) English system, this equates to JL: [a-zA-Z_$�]; JD: [0-9]
The following program may aid those with international keyboards:
import java.util.TreeSet;
public class JavaIdentifiers{
public static void main(String[] args){

String chars = (args.length > 0) ? args[0] :
"1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"+
"`��\\|!\"�$%^&*()-_=+[]{};:'@#~,.<>/?";
char[] charArray = chars.toCharArray();
TreeSet javaLetters = new TreeSet();
TreeSet javaDigits = new TreeSet();
TreeSet other = new TreeSet();

for (int i=0; i<charArray.length; i++){
char current = charArray[i];
if ( Character.isJavaIdentifierStart(current) ) {
javaLetters.add(new Character(current));
} else if ( Character.isJavaIdentifierPart(current) ){
javaDigits.add(new Character(current));
} else {
other.add(new Character(current));
}
}
System.out.println("Allowed in Identifiers:");
for (Iterator it = javaLetters.iterator(); it.hasNext(); ){
System.out.print(it.next().toString());
}
System.out.println("");

System.out.println("Allowed in Identifiers (but not as first character):");
for (Iterator it = javaDigits.iterator(); it.hasNext(); ){
System.out.print(it.next().toString());
}
System.out.println("");

System.out.println("Not Allowed in Identifiers:");
for (Iterator it = other.iterator(); it.hasNext(); ){
System.out.print(it.next().toString());
}
}
}