Archana Nair

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

Recent posts by Archana Nair

Hi Percy,
Great !Congratulations,good job!
Archana
23 years ago
Hi everyone,
I passed the exam today.Not a great score though only 65%.Still iam so glad i made it.Hey!thanks a lot guys for all ur help.It really helped as i got all my doubts cleared through javaranch.i had 4 questions on i.o constructors.then 3 on thread.The areas i did badly where operators and flow control.
thanx a lot again
regards Archana
23 years ago
Congrats!Bogden
Archana
23 years ago

Hi

In the question below the answer is 3.But i was under the notion that transient variables cannot be serialized.then how come the answer is 3.please do explain.thanks
Archana
import java.io.*;
public class TransientWriter implements Externalizable
{

private transient String s = "Hope I can ever be persistant!";
public void writeExternal(ObjectOutput oOut) throws IOException
{
oOut.writeObject(s);
}

public void readExternal(ObjectInput oIn) throws IOException, ClassNotFoundException
{
s=(String)oIn.readObject();
}
public String toString()
{
return s;
}
}
class K
{
public static void main(String args[]) throws IOException, ClassNotFoundException
{
TransientWriter tw = new TransientWriter();
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("tw.out"));
out.writeObject(tw);
ObjectInputStream in = new ObjectInputStream(new FileInputStream("tw.out"));
TransientWriter tw2 = (TransientWriter) in.readObject();
System.out.println(tw2);
}
}
Attempting to compile and run the above code

1)will cause a compiler error due to the attempt to write a transient object.
2)will cause a runtime exception when an attempt is made to write a transient object.
3)will not cause any runtime error and the transient object is writen to the file named "tw.out".
4)will not cause any runtime error and the transient object is not written to the file named "tw.out". The program prints a blank line on the screen.
23 years ago

Hi
Q1)public class AQuestion
{
private int i = j;
private int j = 10;
public static void main(String args[])
{
System.out.println((new AQuestion()).i);
}
}
Answers
a)Compiler error complaining about access restriction of private variables of AQuestion.
b)Compiler error complaining about forward referencing
c)No error - The output is 0;
d)No error - The output is 10;
answer b
Q2)public class AQuestion
{
private int i = giveMeJ();
private int j = 10;
private int giveMeJ()
{
return j;
}
public static void main(String args[])
{
System.out.println((new AQuestion()).i);
}
}
Answers

a)Compiler error complaining about access restriction of private variables of AQuestion.
b)Compiler error complaining about forward referencing.
c)No Compilation error - The output is 0;
d) No Compilation error - The output is 10;
Answer c
these are 2 questions i found in one of the mock exams.The first once answer is b.i thgt the second onces answer would also be b.But its c.Please do explain why the answer for the 2nd question is c.
Archana
23 years ago
Hi

Even i didnt notice the line double b=method(a);
Anyway now my doubt is cleared with Asma's explanation.Thanx guys!
Archana
23 years ago
Given this code snippet: double a = 14.9;
double b = method(a);
System.out.println(b);

If this snippet displays 15.0 in the standard output, what Math method(s) could method() have invoke?
Select the one right answer.

a)ceil() and round()
b)floor() and round()
c)ceil() only
d)floor() only
e)round() only
Answer a
This a question in barry bones mock exam(q no 31)
the answer is given as a .But i thgt the answer is c) and not a) because when ceil and round is used then the answer should me 15L and not 15.0.please explain.
23 years ago
Hi Percy
Oh!Ya!it worked like magic after i changed the moniter resolution which u mentioned.Thankyou once again.
regards Archana
23 years ago
Hi Leena
THanks for the help.
Archana
23 years ago
Hi
I wrote to the forum regarding barrybones exam a few days back.Percy had helped me regarding it-that it was 15-17 in the mockexams list.But still iam unable to access the page with the answers.can u please tell me where i can find the answers.
Archana
23 years ago
Hi
I would like to know which are the access modifiers that can be used for constructors and why!
Archana
23 years ago
Hi Percy
Thanx a lot for ur help.i found the questions but i guess theres problem with that page ,i am unable to access the page with the answers.Anyway thanks.
Archana
23 years ago
Please tell me where i can find the questions to Barry bones question papers in the java ranch mock exam list
23 years ago