Cherry Sta. Romana

Greenhorn
+ Follow
since Aug 08, 2001
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 Cherry Sta. Romana

Yes you are corret in saying that Amethod is not an overload since it is a method with a different name which would then allow it to be placed in the code without causing errors. The question does not refer to overloading.
Since method1() in the Parent() class is private, the method1() in the Child class is not overriding method1() in Parent class. Thus, even if the actual Object is a Child, method1() in parent still gets called from method2().
The explanation states that had method1()been public.. then it would have been the method1() in Child that would have been executed, this is because then, the method1() in Child will be overriding the method1() in Parent and so the actual object's method will be invoked.
I hope this helps.
I hope your scores are shifted to the left and not to the right.
Anyway, you have to be comfortable first with binary representation specifically two's complement representation so that you will know what happens when you shift.
Search the net for "two's complement". There are a lot of tutorials on it. Now once you are comfortable with it. It gets quite easy to do shifting operations or any bitwise operations for that matter.

Hi!
The first question I guess is about short circuit evaluation. So you have to know if the second test will be executed or not.
Now if s is null, the second expression ( i = s.length()) will throw an exception when evaluated.
The question states: Which of the following MAY throw an exception? There is a difference between MAY throw and WILL throw. (When I take mock exams, most of the time I get wrong answers because I sometimes mis-understood what the question is about.So when you take the exam you have to read the question very carefully.)
I think you were right about assuming that s might be NULL, in which case, 1,2,3 will throw exception.
With regards to the second question, I do not understand it very much.
I hope this helps.

Hi!
Aside from compareTo, you can also use the equals method.
if you have two strings s1 and s2
boolean equal = s1.equals(s2);// returns true if equal
// false otherwise
if the case does not matter, you can use equalsIgnoreCase method
boolean equal = s1.equalsIgnoreCase(s2);

17 years ago
Hi!
The first time I encountered this in Java, I was also very surprised because, i=i++ in C (in my compiler) gives a value of 1 to i.
However, in Java what happens I think is this -->
saying i++ or ++i on its own has no problem. Both of them would increment i.
However, saying i++ as part of the expression is different. What happens is that i++ is evaluated giving a value of 0 (since it is post-increment), which for some some reason is stored in a temporary variable. Next, increment is performed, setting i to 1. And then lastly, the assignment is performed, fetching the value (that was saved) which was 0 and storing it in i. Thus final value is still 0. If i is not used in the left hand side, then it is not so confusing -->

int x = 0;
int i = 10;
x = i++; // makes x 10 and i 11
I hope this helps.
Hi azaman,
I think you will do great in the exam. And you are correct, you really have to review threads and I/O. Those were also my weakest areas. But if you are good in fundamentals, I am sure you will do okey.
Thinking in Java has a sample program that uses most of the I/O classes. I think you should read that too. And practice programming using threads.
Actually, before I took the exam, I have a feeling that I will do okey because I know the fundamentals. I also know that I am weak in certain areas. But I do not have anymore time and I cannot postpone the exam forever. So I just went for it and just focused my attention on the concepts that I am confident about. However, since you still have the time to review, you have to focus on your weak area and I am sure you will get a high score.
Good luck.
I think it is because, arrays in Java start with 0.
[This message has been edited by Cherry Sta. Romana (edited August 15, 2001).]
Hi leena,
I think you were just confused about the question. The question refers to the argument following the case construct not the switch.
In the switch construct --> switch (expression) --> expression can be anything that is compatible to an int.
On the other hand, for the case construct, it has to be an int constant.
For example:
int a = 5;
int b = 10;
switch (a*2) // this is possible, value is evaluated
{
case 10: // should be a constant int
case b: // this is not possible since b is a var
}
I hope this helps.


Thanks to both of you. My friend was asking about this and I said that I don't think that it is possible. However, we both attended a training on Java and we both remember that our trainor said that it is possible using some form of super.super.. Anyway, we mis-understood it probably.
Thanks again.
Is it possible to call methods from the top of a class hierarchy using super?

Example:
class C1 {
public void method() {
System.out.println("C1");
}
}
class C2 extends C1 {
public void method() {
super.method();
System.out.println("C2");
}
}
class C3 extends C2 {
public void method() {
// can I also call the method in C1 here
}
}
Can I also call the method in C1 inside the method in C3?
Thanks.

bigCode was declared inside a block {}. Note that you declared it twice in diff locations -> inside if and inside an else block. The visibility is only inside the {}.
fs was also declared inside the try block.
You have to put your declarations for bigCode and fs outside the blocks.
17 years ago
Sorry about the term "I gathered", what I meant was that, the database that SUN has prepared "from what I heard" is quite large so we can not tell exactly whether there are technical questions in the exam that others will be taking.
Anyway, to share with you some tips on how I prepared:
1. I did the Rule's Round-up game.
2. I did Marcus' Mock Exams.
3. I downloaded JXam.
4. I read Jaworski Certification book.
Most of the materials/links I got from this site.
But prior to that, I was given a scholarship on the SL275 (Java Programming) training offered by SUN. But it was only for a week so it was quite fast, (not enough time for concepts to actually be absorbed) and so I also read the materials given to us. And I did a lot of sample programs.

Hello Kamil,
Let me try to explain,
the general format of a switch statement is
switch (expression)
expression here is anything that will evaluate to/will have a final value of an int. The final value of the expression will then be compared to the cases that follows the switch
Now, writing something like
int a = 1;
switch (a)
will make the variable a be evaluated, meaning the value of a will be fetched in memory and that value will be considered as the value of the expression.
If you write something like
switch (1)
the 1 there is a constant (it is an int literal) and the value of course of the expression when evaluated is the integer 1.
You can even write something like
int a=5;
switch (a * 2)
In this case, the value of the expression is 10.
Whatever is contained in the ( ) of the switch expression should have a final value of something that can be evaluated to an int.
The only reason why they give sample questions like that is to make it easy to evaluate the expression in the switch.
In practice, it is probably not being done.
Just remember that, you look at the expression, determine its value. It does not matter whether it is a constant or a variable. What matters is the final value of the expression.
I hope I did not add to your confusion.

Hi Farooq,
I am not exactly sure that there will be questions as "technical" as the one posted. What I know is that there are questions involving java.io package and that includes RandomAccessFile.
I have taken the exam last week and luckily I passed. From what I can remember, the questions regarding files are not as technical as this. I suggest that you read the API on java.io to familiarize yourself with the methods.
Since the database of questions I gathered is quite large, it is always best to prepare for the worst scenario.