This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!

Chris Wash

+ Follow
since Aug 23, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Wash

weblogic actually edits the script, so it's probably not a good idea to put anything in there. setDomain.env is a good spot to put your check, you can also put your reference in the /bea/user_projects/domains/wls/_cfgwiz_donotdelete/startscript.xml, which gets merged at runtime as well, ie:

13 years ago
When I was in school, we used jasmin a lot to explore how the JVM behaved and class files were structured. We ran into a number of unexpected behaviors that didn't make sense until you understood how the bytecode got to be the way it was, and then how it was being interpreted.

Did you run across any puzzlers that no good explanation outside of "that's how it gets compiled/interpreted"? If so, are the implications for these types of puzzlers more profound after writing this book than you considered them to be beforehand?

Thanks -- look forward to checking out the book,


PS - I saw you worked for Google -- do they put Ajax in the cafeteria food there? =]
13 years ago

Originally posted by Smriti Katyal:
I totally agree with you about your opinion on compiler generated error questions. I think "the missing semi colons at the end of anonymous class declaration" and such syntactical errors are not something that prove your understanding of Java.
But I know the exam is valued and has its own merits!
All the best and congratz once more!

Thanks. Yeah... all I'm trying to say is what is the point of agreeing with and arguing for all of the high level merits of Java, and then denying the fact that the compiler is robust enough to rely upon under most circumstances. I think most people can agree with that, and even if they don't admit it, see this test as a right of passage.
14 years ago

Originally posted by Christopher Gabijan:

Don't worry you got higher than my score..

I've been developing a lot of JAVA Based System and Application and I always don't get compiler errors cause I've used great IDE's like JBuilder and Forte(now SUN ONE), but it is also a challenge to pass SCJP on how good our compiler understanding is (to prove and to improve), and to know also the tricky/unique/out of this world class implementations (like on the SCJP Examination) that can also gives us overviews on programmers/developers/architects that do this exotic codes .

Congrats Again! what's next?

[ September 04, 2004: Message edited by: Christopher Gabijan ]

thanks! i'm not sure what's next. maybe the SCBCD because that's one that would be useful at work.
14 years ago

Originally posted by chowdary Thammineedi:
There Are No Traffic JAMS on the extra MILE.

- Roger Staubach

(Was he the GB Packers Coach?. F'r gimme I am not American)

Nobody wants to be a compiler. But if you think like one, you are only going to be a better programmer.

He was a QB for the Cowboys.

You have the potential to be a more efficient programmer. But then again, the more and more time you devote to learning the innards of the compiler, the less time you spend writing progressive and meaningful code.
14 years ago
well i passed. it wasn't pretty, but neither were my study habits. i just wanted to prove to the world if you work with java for four years then you can pass this test without months of studying. i studied a total of about 24 hours over the past five days, primarily by reading chapters on topics that i was rusty with from mughal's book. i didn't make it a third of the way through even one mock exam due to interruptions, but i think that 11 questions is a big enough buffer to say that it wasn't all luck... and i was surprised that i got what seemed like 10 questions on threads.

i don't think it's a huge accomplishment because i didn't invest that much time in it, but i am glad that i passed. it is definitely a thorough test, but i think knowledge of semantics and syntax, in such a high level language, is the domain of the compiler. if you have experience working with the language, and spend time learning best practices, i think it's much more valuable than learning what the compiler is going to accept or reject... but don't get me wrong, that knowledge is cool in its own right. i just think it's far less practical. and after all, the test, in the end, is pass/fail.
14 years ago
sorry for the confusion... here is an answer that works. i had totally forgotten about this until re-reading some of my old school notes.

this is actually an example of shadowing. the string s is declared in both the superclass, base, and the subclass, derived; whenever you're trying to access a shadowed variable using an object reference, the type of the reference determines which of the variables is used. since b is declared as of type base, the reference type is a base, although the actual class of the object is derived. variable shadowing does not work exactly like overriding methods -- whereas overriden methods are looked up dynamically using the class of the object, shadowed instance variables are looked up by the type of the reference!

i'll post a little blurb from the brogden/green book i have:

Can You Override a Variable?

Yes, you can override a variable. This is the short answer. A subclass can have a variable with the same name as a variable in the parent class. In this case, if the parent class variable is not private, the subclass variable is said to shadow the parent class variable. However, there is a significant difference between the way the Java compiler treats methods and the way it treats variables. Because of the way variables are stored in the memory allocated to an object, references to variables can be computed at compile time based on the type of the variable.

Suppose that the BookElement class defines a variable named lineCt and the subclass Chapter defines another variable named lineCt. Which value would the following code fragment print?

Chapter ch = new Chapter() ;
BookElement b = ch ; // casting to the parent class
System.out.println( b.lineCt ) ;

If you guessed that the compiler would use the lineCt variable found in the BookElement class because b is a BookElement reference, you are correct.

Remember that references to member variables are computed at compile time using the type of the reference. References to member methods are resolved at runtime using the type of the object.

[ August 23, 2004: Message edited by: Chris Wash ]

Originally posted by Doyle Matt:
Hi All,

All this techy terms are getting me confused. Anyway just to simplify things the code int i = 1/2 generates a compile time constant plus both "1" and "2" are integers. so at runtime/or compile time (which ever is correct) will produce and output of 0 (an integer) and not a double 0.5.
Clear enough? Or did I add additional mistakes and confusion?

that is the way it works. i thought you were looking for an explanation of why it worked like that, so i was just saying the compiler has an instruction set that it works off of. it sees 2 integer operands and decides to use the integer division instruction, which returns an integer. even if you were try to cast this value as a floating point type and store it in a float, it would still be zero. the instruction it uses it does division like you used to do back in 3rd grade with remainders, only the remainders get thrown away or truncated. if you wanted to get a 0.5 you would need to use floating point operands.

this is the only way i've ever dealt with casting object references in a narrowing sense:

like ken said -- when you are dealing with a general object reference that you're sure refers to a specific subclass. i'm not sure, but i think this is the only type of a narrowing cast that you can perform on a reference that has any meaning. anyone want to verify that??

but basically to answer your question directly, what was there before was a case where you were sure you had an element, e, and you were sure that you had a point, p -- but you can't cast a point into an element unless you're sure that it's already a point... that's the only way you can do a narrowing conversion on object references, and whenever you do it you have to use a cast.
[ August 23, 2004: Message edited by: Chris Wash ]

Originally posted by Peter Warde:
I'm not sure about this compile time constant. I don't think the code below is a compile time constant as the value of y would only be determined at runtime.

class Test {

int i;

Test(int y) {
i = y/2;

public static void main( String args[]) {

Test t = new Test(1);

Ps does anybody know a good explanation of what is determined at compile time versus runtime

the way it works, with any arithmetic operations, and for that matter almost any statement that you can point out in a line of source, is there is an instruction for the specific operation that gets determined at compile time, based on the number of operands and their types, and then values are given to that instruction at runtime, which determines the result. so based on the types and numbers of operands you have in your source file, the compiler will determine a specific instruction that should be executed for that. in this case, it's an integer division, which truncates.
correct me if i'm wrong, but...

all inner classes are nested classes, but not all nested classes are inner classes. from the book java 2 programmer exam cram, by brogden and green, "Generally speaking, a nested class is a member of another class. However, it is common to speak of the static members as nested and the nested classes that are members of instances of the enclosing class as inner classes. Indeed, you are most likely to read about inner classes only, but the more general term is nested classes." the thing is, static member classes are pretty rare, so it seems like they are nearly inter-changable when technically they're not.

hope that helps.
[ August 23, 2004: Message edited by: Chris Wash ]

Originally posted by Swati Udas:
class Leg{}
class Fur{}
abstract class Pet {
public abstract void eat();
public abstract void sleep();
class Dog extends Pet {
Leg leftFront = new Leg(), rightFront = new Leg();
Leg leftRear = new Leg(), rightRear = new Leg();
Fur fur = new Fur();
public Fur shed() {return fur;}
public void eat() {}
public void sleep() {}
class Cat extends Dog {
public void ignoreOwner() {}
public void climbTree() {}

Which of the following statements is not a true statement?

a. A Cat object inherits an instance of Fur and four instances of Leg from the Dog superclass.
b. A Cat object is able to sleep and eat.
c. A Cat object is able to climb a tree.
d. The relationship between Dog and Pet is an example of an appropriate use of inheritance.
e. The relationship between Cat and Dog is an example of an appropriate use of inheritance.
f. None of the above.

The answer is given e and explainetion is as follows:

An appropriate inheritance relationship includes a subclass that "is-a" special kind of the superclass. The relationship between the Dog subclass and the Pet superclass is an example of an appropriate inheritance relationship, because a Dog "is-a" Pet. The relationship between the Cat subclass and the Dog superclass is not an example of an appropriate use of inheritance, because a Cat is not a special kind of a Dog. The goal of the OO paradigm is to develop software models that are accurate and reusable. If the software model is not accurate, then it probably is not reusable and the goals of the OO paradigm are not achieved. Code reuse and maintenance becomes increasingly difficult when inheritance is used to model inappropriate relationships. For example, suppose that somebody implements a herdSheep method in the Dog class. The Cat subclass would inherit the method and suddenly each instance of Cat would acquire the unwanted capability to make an attempt to herd sheep. It is difficult to imagine that a Cat would perform well in that role, so additional maintenance would be required to resolve the problem.

i think the xplaination and answer do not conform to each other the answer shud be D according to the above theory.Please clarify!

Make sure you read the question and answers carefully:

Which of the following statements is not a true statement?

The question is asking which one is not true, or false. a dog is-a pet, so it can't be D because that is true. a cat is-a pet would be an appropriate use of inheritance, but having an is-a relationship between a dog and a cat is not appropriate.

Try reading the answers first, then the question, and then the code they provide. Usually if you read the code first, you start thinking of an answer before you even read the question and don't really think twice about re-reading the question to make sure it's correct.
Yeah I'm guessing the question is geared towards testing how much you know about implicit default constructors and inheritance. Take a closer look at how those constructors get generated and it should make a little bit more sense.
If you don't have 6-12 months of experience tinkering with the Java platform, you probably don't have enough knowledge of the intricacies involved to pass the exam. That doesn't mean you need to have had a job in the industry for 6-12 months to take the exam. It's pretty hard to find an entry level job now that doesn't require a SCJP cert!

Originally posted by Sandya Bhaskara:
what is this private protected modifier?is it same as default modifier?

private and protected are two different accessibility modifiers. private and protected are similar in that they apply only to members. private means that the member is not accessible from any other class -- even subclasses (nested classes can access private members in their top-level class). it is usually applied to fields and helper methods for classes. protected is not as restrictive, as it allows for access by classes that are either in the same package, or subclasses of that class.

[ August 23, 2004: Message edited by: Chris Wash ]