Chitra AP

Ranch Hand
+ Follow
since May 25, 2005
Merit badge: grant badges
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 Chitra AP

No, finalize() method will be called by the Garbage collector only once, for an object.
Why K&B's mock exam allows only 90 minutes for 65 questions???
In the real exam, I think the allowed time 120 minutes for 61 questions, correct??
[ June 23, 2005: Message edited by: Chitra AP ]


I understand the expression (b1 = i1 == i2) gives you false here.
So, if (false) System.out.println("true") and it should print true, right??
But it prints false, why??? :roll:

Thanks
One of my friend used to score only around 70% with the mock exam, and with JQPlus, he was scoring 60 to 65%. But, he passed with the real exam.


I thought the answer would be "It will be printing the same value for x and y incrementing by 1 on each line".

But, the correct answer is "You cannot say anything about the values".
They are saying the reason is that there are two different objects and both threads are acquring lock for their own.

So, in order to see the result I put sleep() (which is commented above now). It shows the result as I expected. How come it is the wrong answer.
Please explain. Thanks.

(got rid of smily)
[ June 17, 2005: Message edited by: Barry Gaunt ]


why do I get the compiler error at p.c = p.i
Instance var i is final, so compiler should know the variable type and this case you can assign int value to char var because the value is < 65536.

Please let me know why do I get the compile error? Thanks.
Hi Swetha,

I didn't get it correctly. Could you please explain? Thanks.
Hi All,

K&B book says ceil(), floor() and round() all return integer equivalent floating-point numbers. But the following code prints

System.out.println(Math.round(1.1)); //prints 1
System.out.println(Math.ceil(1.1)); // prints 2.0

The first line should print 1.0, correct? Thanks.
I got it. Thanks.

By the way, you can find free mock exams at www.witscale.com
I am kind of confused here. Here is the program:



It prints A1B0A0B1A0B2. I understood until how it prints A1B0 , after that I thought it would print A1B1A1B2, but it prints A0B1A0B2. How?
When a1.m2() executed, A.this.name would be A1, correct ? I don't understand when it became A0. Please help me to understand the code correctly.

Thank you so much.
[CODE]
class SuperClassA {
protected int superValue;
public SuperClassA() {
System.out.println("Constructor in super classA");
this.doValue();
}

public void doValue() {
this.superValue = 911;
System.out.println("SuperValue: " + this.superValue);
}
}

class SubClassB extends SuperClassA {
private int value = 800;

public SubClassB() {
System.out.println("Constructor in SubClass B");
this.doValue();
System.out.println("SuperValue: " + this.superValue);
}

public void doValue() {
System.out.println("Value: " + this.value); // doubt ???
}
}

public class ObjectInitialization {
public static void main(String[] args) {
new SubClassB();
}
}

{/CODE]

I have a doubt where I place "doubt ???". This line prints 800. As I understand the instance variable gets initialized after the base constructor completes the execution. In that case how is it printing 800 before the constructor completes?

Thanks
for (byte bv = 0; bv < (byte)255; bv++) {
System.out.println(bv);
}

When I execute this block of within the main(), it is not printing anything. Please let me know the reason for it.

I thought it will narrow the value and print from 1 to 127.

Thanks
public class Oper1 {
public static void main(String[] args) {
int x = 0;
int y = 0;
x = x++ + y;
System.out.println("x = " + x);
System.out.println("y = " +y);
}

}

Please let me know why it prints 0 0. I thought it would print 1 0.

Thanx
It is because you have overridden the fun() method in the subclass.

---------------
Test t=new T();
------------------

So, when you instantiate the subclass, it instantiate the parent class first. At that time it runs fun() (overridden in sub class which prints B)
and when the sub class instantiates again it prints B.

Hope it clears your doubt.
Thank you. It clears my doubt.