Gazala Bohra

Greenhorn
+ Follow
since Oct 27, 2000
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 Gazala Bohra

A correction to my previous post, "goto" and "const" are KEYWORDS but they are just reserved and not used.
Sorry and thanks,
Gazala.
Hi Ramesh,
"null" is not a keyword but it is a "reserved" word in Java.Null along with "true" and "false" is a reserved word and const and goto are reserved words.
The difference between keywords and reserved words is I guess in the fact that keywords are used by compilers to undermine the action to be taken when it comes across those keywords.While reserved don't effect the compiler decisions.But both keywords and reserved words cannot be used in naming identifiers.
Yes Java does not use capital letters in its keywords and reserved words.
All the best.
Gazala.
Hi all,
Just wanted to thank the regular visitors and helpers on this forum who were a major help in my short term efforts.I made it with 89%!
Thanks Java Ranch,
Gazala.(Sun Certified Java Programmer. )
Hi all,
The war is over and the in two weeks that I spent on the battlefield, my constant companion was Java Ranch.
Hats off to you Java Ranch!!!
It took me two weeks of eating drinking and sleeping Java to get here but it was worth the effort.
The exam is not difficult, all it needs is concentration and careful thinking.Don't jump to conclusions, answers aren't always what they seem on the first look at the question!!!So think twice before you click on the answer and still at the end review it.
I lost the 90's because I was careless in the last question, being in a hurry to get it over with.It was a simple question on garbage collection which I got wrong.The only reason was that I did not do it carefully.But I am satisfied with the result, going by the amount of effort that I put in, I got more then what I deserved.
I am going to be a loyal Java Ranch visitor and shall try and help whenever I can like all others who helped me in my time of need.
Thanks again !!!
Gazala.(Sun Certified Java Programmer! )
21 years ago
Hi!
I used the link that Ajith had given and while reading this a doubt came into my mind.Can someone please enlighten me on this.It says:
"These words(i.e Keywords) are reserved--you cannot use any of these words as names in your Java programs. true, false, and null are not keywords but they are reserved words, so you cannot use them as names in your programs either."
Now my doubt is that functionally what is the difference between keywords and reserved words? We can't use either of them as names of identifiers in our programs, that is understood but what is it that distinguishes a keyword from a reserved word?Am I right in thinking that keywords are used by compilers to perform specific actions while compiling codes while it is not so with reserved words.Waiting for someone to confirm.
Thanks
Gazala.
Dear Snehal,
This is how I see it, somebody correct me if I am wrong,
when int i = givemeJ(); is executed the method givemeJ() returns a value 0.That is because any int member variable if not initialized explicitly ,is assigned 0.After this int j = 10; is executed which then has no effect on the value of i.
So (new AQuestion()).i gives 0.
Hope that helped.
All the Best.
Gazala.
Thanks Howard , I sure got the first one, but the second one is still not clear, can you elaborate on that.It does call the no arguement constructor of the super, that I understand but what is not clear is this statement of the answer
" must provide a constructor which must throw an IOException or one of its super classes"
Why so?
Thanks,
Gazala
Hey all,
Can someone please help me understand these two questions.
Question 72.
Read the following piece of code carefully.
import java.io.IOException;

public class Question72
{
public Question72() throws IOException
{
throw new IOException();
}
}
Assume that the defination of Question72E begins with the line
public class Question72E extends Question72
It is required that none of the constructors of Question72E should throw any checked exception.

1.It can be achived by placing the call to the superclass with a super keyword , which is placed in a try block with a catch block to handle the IOException thrown by the super class.
2.It can be achived by avoiding explicit calls to the base class constructor.
3. It cannot be done in the Java Laungage with the above definition of the base class.
-----------------------------------------------------------------The correct answer to this one is 3.I could not understand why the method in answer 1 will not work!!!
Question 73.
Read the following piece of code carefully. (This is an extention to question 72.)
public abstact class Question73 extends Question72
{
public abstract void method();
}
An attempt to compile the above class definition
1.will cause a compiler error - non-abstract classes cannot be extended to abstract classes.
2.will cause a compiler error - a constructor must be provided which may or may not throw an IOException
3.will cause a compiler error - a constructor must be provided
which must throw an IOException or one of its super types.
4. will not cause any compiler error. The class definition is perfectly legal.
-----------------------------------------------------------------
The correct answer is 3 again.But why?
Waiting for help.
Thanks,
Gazala.
Thanks Bill, that was sure a very silly mistake that I made.This will get me no where.Anyways you learn from mistakes!!!
Thanks again,
Gazala.
Hi all,
I could not get this question right in Abhilash's exam site.Can someone please tell me why the answer is what it is.
Question 36.

public class Base
{
public void aMethod() throws ClassNotFoundException
{
}
}
public class Derived extends Base
{
public void aMethod() throws RuntimeException
{
}
}
Assuming that the classes are in two seperate files, compilation of the Dervied.java causes

1.A compiler error because RuntimeException is not a subclass if ClassNotFoundException.
2.No compiler error.
The answer according to Abhilash is 2.Why?
Waiting for help.
Thanks
Gazala.
Dear Manfred,
Does this mean that I can never call this method setColor with a constant number small enough to fit into bytes as they will all be integer literals ? Which means I can only assign a value to a byte variable and then use that variable to make a call to the setColor method?
Waiting for a reply,
Thanks,
Gazala
Hey all,
I was just trying one of the new mock exam sites just posted after Maha's request.This question is from the enthuware link, the JQ+ exam.
I wonder if I am just confused or if really there is something funny in their explanation for the answer they say is correct.I can't even cut and paste the question, I have to type the whole thing, here it is:
Q.The follwong class will compile and print 30 twice.
class A {
void setColor(byte i){System.out.println(""+i);}
public static void main(String args[]){
A a = new A();
byte b = 30;
a.setColor(b);
a.setColor(30); //compiler error
}
}
a. true
b. false
They say answer is false.And the explantion is:
"Narrowing conversion happens for byte b = 30.As 30 is a constant and is small enough to be held by a byte.BUT narrowing conversion DOES NOT take place for method parameters ,and hence this code will not compile."
So what is it? Am I missing a very fine point here??? Bytes have a range from -128 to 127 so why this talk of conversions.Can someone please clarify this for me!!!
Thanks
Gazala.
Hi!,
Here is a question from Barry Boone, I wonder if soemone has already brought it up on this forum.I did not spend time looking that up, needed to know the correct answer fast, so please help.
Question 65: Which statements about garbage collection are true?
Select all valid answers.
a. You can directly free the memory allocated by an object.
b. You can directly run the garbage collector whenever you want to.
c. The garbage collector informs your object when it is about to be garbage collected.
d. The garbage collector reclaims an object´┐Żs memory as soon as it becomes a candidate for garbage collection.
e. The garbage collector runs in low-memory situations.
The correct answer according to the author is: b,c,e.
I am confused!!! Can someone please verify!
Thanks,
Gazala.
Dear Carol,
I think that the line
afancymethod();
in P2 is a call to the afancymethod method in P1 and not a method declaration.So there isn't a missing return type or a method body in this case.The only reason P2 does not compile because it is in default package and is trying to access a method in parent class which is not visible in this package.
Have Fun,:-)
Gazala.
Dear Mukti,
Can you please e mail those questions to me too!It would be great if you have the correct answers too.
My e mail id is gazalar@yahoo.com.
Thanks a lot and all the best to you!
Gazala