Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!

Divya Eknath

Greenhorn
+ Follow
since Jul 27, 2006
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 Divya Eknath

Thankyou very much to ranchers.I studied from K&B & Khalid Mughal.I found the Dan's mock tests very useful.I think we need a lot of practice solving different types of questions from mock exams on each topic in order to understand the topic well.Anyway i am glad that my journey to SCJP is over.
15 years ago
ppp sup = new ppp();
ppp.aaa sub = sup.new aaa(){};

sub.mmm();
The abstract inner class's mmm() method cannot be called directly as abstract classes cannot be instantiated.You can extend the abstract inner class and call the method using the object reference of the subclass.
I am confused about the unreachable statements in java.It is said that to place assertions at the place which is unreachable is a good practice, but then again if assert statement is unreachable it gices compile-time error.I referred to JLS to understand the concept of unreachable statements, but sadly i don't have enough time to go through and understand everything as i have exam in few hours
Can anybody please tell me the precedence of bitwise/ligical operators:&,^ and |?
In some books its given as & ^ |, while in others it is & | ^.
I ran the program below and got option(C) as the output but is this the only possible output?Are the thread priorities guaranteed to be considered?


What are the possible outputs of above program?
Options:
a) A Done
b) B Done
c) A Done B Done
d) B Done A Done
e) java doesnt support this type....
[ July 29, 2006: Message edited by: Barry Gaunt ]
which of the following line causes a compiler error?

public static void main(String[] args)
{
method();
assert false;
assert false;
}
public static void method()
{
while(true)
{
assert false;
}
assert false;
}
What is the use of having timeout argument for the wait() method?
If i understand correctly, both when the
(1)thread is notifiied and when the
(2)time in the wait method expires,
the thread goes to Blocked-for-lock acquisition state.And when the lock on the object is released it goes to ready-to-run state and then to running state whenever it gets chance.

So the call to wait() method returns at the same time in both cases.

And also when the thread is interrupted, does the thread go to Blocked-for-lock acquisition state-->>Ready State-->>Running annd then throws the InterruptedException.Please correct me if i am wrong.
class B{}
class A{

private int x;
private int y;


public synchronized void amethod(){

x=4;
}

public void bmethod(){
B b = new B();
synchronized(b){

x=6;
y=7;
}
}

public void setValues(){

x=10;
y=12;
}
}

My question is if the synchronized method, amethod()uses a private variable of the class, then is it ok for other threads executing the synchronized block and the setValues methods to access the same variable and change its value?