lstrite

Greenhorn
+ Follow
since Jul 10, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by lstrite

I just took the exam and passed with 98%. I spent 8 weeks studying (I already knew some java prior to this). I studied RHE, Exam Cram and Jaworski. I think RHE was the most helpful. I also took 20+ mock exams. The ones closest to my actual score were: JQuest, Javaprepare.com, RHE exam (on CD with book) and Jval. I think the RHE is the best mock exam because the questions are most like the real exam and you don't have to worry about mistakes (most mock exams I found on the web had several mistakes).
My exam had the following types of questions (other than fundamentals):
I/O 4 (including 1 about sockets)
Thread 4-5 (including 1 about media tracker)
Garbage collection 2
Layout Managers 4 (including 1 about grid bag)
Surprisingly, I also had 8 questions that were fill in the blank!!
The focus is on fundamentals rather than constructors/methods for particular classes although you will get a few like that.
Thanks to everyone here who answered my questions!
[This message has been edited by lstrite (edited August 07, 2000).]
24 years ago
++ and -- can be used on all integral types: byte, short, int, long and char. Executing x++ is different from doing x=x+1 in that for (x+1), each operand is promoted to int and thus the result is an int. When you use ++ and --, the operand is not promoted. So there is no need to cast back.
Ex:
byte b=1;
b++; //Valid
b=b+1; //Compiler error
b=(byte)b+1; //Valid
I didn't see anything listed in Sun's objectives yet a lot of the mock exams that are supposedly for java 2 have questions about it. I have seen questions about extending Applet as well as about the html tags needed to put an applet on a web page and pass parameters in. Can anyone help me out here and let me know if this is something I need to know?
Thanks!
From what I've heard, you don't need to know it in great detail. I found this web page that explains it very nicely and should be enough detail: http://pandonia.canberra.edu.au/java/xadvisor/gridbag/gridbag.html
Please send it to me too!
[email protected]
Thanks,
Another Lisa!
Answers 1 & 3 were not supposed to be relational, they are supposed to be shift,it just did not print them right.
For interfaces, they cannot be instantiated, but you can create a reference and it can hold any object that implements the interface such as this:
Runnable r = new myClassThatImplementsRunnable();
But the interface is self cannot be instantiated:
Runnable r = new Runnable; //Wrong
Here is the actual question:
Given the following variables which of the following lines will compile without error?
String s = "Hello";
long l = 99;
double d = 1.11;
int i = 1;
int j = 0;
1) j= i << s;
2) j= i << j;
3) j=i << d;
4) j=i << l;
1) Wrong- because the shift cannot be a String
2) Correct- int can be used for both operands
3) Wrong- because the shift cannot be a double
4) Correct- the shift can be a long, the actual shift will be l%32 since the type of i is int. The type of the result depends on the type of the first operand. So if it had been j=l>>i; that would not compile because it would result in a long whereas j is an int.
[This message has been edited by lstrite (edited August 05, 2000).]
The question says:
Which of the following statements about threading are true
1) You can only obtain a mutually exclusive lock on methods in a class that extends Thread or implements runnable
2) You can obtain a mutually exclusive lock on any object
3) A thread can obtain a mutually exclusive lock on a method declared with the keyword synchronized
4) Thread scheduling algorithms are platform dependent
I knew that 2 & 4 are correct but it also says 3 is true. I thought locks are obtained for objects. If you put the synchronized modifier in front of a method doesn't it mean to synchronize on the class (object)??
thanks!
What is the correct way to add components to a container with BorderLayout? The book I read said the method was:
add(Component, String) where the string is like "North" etc.
But on a couple mock exams I took they had the parameters switched around and the question/answer indicated that it was the correct way to add to a Border Layout.
Can someone clarify this for me, are both of them correct ways to do it?
Chamya,
A loop is not required to have an increment statement.
The following code is valid and results in an infinite loop:
w=5
while (w>0)
{ System.out.println(w);
}
THe issue being discussed here is a problem with certain implementations of java not handling infinite loops correctly.
maha,
Thanks for the detailed explanation, I understand it much better now. Thanks for your time!
I seem to get hung up on these type of questions, and not really understanding what the question is asking. I hope the exam questions are clearer!
Thanks,
Lisa
So is Jaworski's statement "Since local inner classes are not class members, they are not tied to an instance of the outer class" untrue then? I understand why my code works, but I don't understand his statement.
I also took the khalid exam and failed it with a 64. I have been doing like 20 points higher on other exams. Does anyone know where the answers are for that exam? After I took it, it wouldn't even show which questions I missed. Was I doing something wrong?
In the Jaworski book it states:
"Since local inner classes are not class members, they are not tied to an instance of the outer class"
If that is the case, then why are they able to access nonfinal instance variables such as in this example, which compiles fine?
I would think that they have to be associated with an instance of the outer class in order to access outerNonfinalVar.
class Test{
final int outerFinalVar=1;
int outerNonfinalVar=1;
static int outerStaticVar=1;
final static int outerFinalStaticVar=1;
void aMethod() {

class Inner {
void innerMethod() {
int r;
r=outerFinalVar;
r=outerNonfinalVar;
r=outerStaticVar;
r=outerFinalStaticVar;
}
}
}
}
Also remember the correct order for logic and bitwise is:
Highest...lowest:
& And
^ Xor
| Or
&& And short circuit
| | Or short circuit