shyam kumarK

Ranch Hand
+ Follow
since May 06, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by shyam kumarK

is there any online material/book for scwcd ?
not mock tests
[ June 22, 2007: Message edited by: shyam kumarK ]
Thanks John,


Anil said
I think ,when ever a thread is in a running state,then that thread can enter into waiting state.

to correct it,
when ever a thread is in a running state,then that thread can enter into Runnable state(if scheduler prefers to run another thread) and waiting state(only if it tries to enter a method or block which is synchronized on an object whose lock is owned by another thread unless you called wait on it)
i think
[ May 15, 2007: Message edited by: shyam kumarK ]


can someone tell me why thread execute concurrently
the numbers will be same on same line(i=1,j=1)

What I thought was because the run method is synchronized one thread must complete its run method before another thread begins.
sample output:
Thread-0 i 1,j 1
Thread-0 i 2,j 2
Thread-0 i 3,j 3
Thread-0 i 4,j 4
Thread-0 i 5,j 5
Thread-0 i 6,j 6
Thread-0 i 7,j 7
Thread-0 i 8,j 8
Thread-1 i 1,j 1
Thread-1 i 2,j 2
Thread-1 i 3,j 3
Thread-1 i 4,j 4
Thread-1 i 5,j 5
Thread-1 i 6,j 6
Thread-1 i 7,j 7
Thread-1 i 8,j 8
Thread-1 i 9,j 9
Thread-1 i 10,j 10
Thread-1 i 11,j 11
Thread-1 i 12,j 12
Thread-0 i 9,j 9
Thread-0 i 10,j 10
Thread-0 i 11,j 11
Thread-0 i 12,j 12
[ May 15, 2007: Message edited by: shyam kumarK ]
Hi

can someone tell me if there are any basic certifications for struts Like scjp 310-035 for java

Thanks and regards,
shyam
18 years ago
Hi
Thanks to all members of java ranch
special thanks to Chandra bhatt for his quick replies and answers to all my questions.

Thanks to Kathy Sierra and Bert Bates for wonderful book (It Grabs you !). The presentation of material in the book is really good and interesting. I dont read many books(not even stories/novels). But this one I found has a very different and interesting presentation style.

I scored very less in threads..... ,should have studied it more

Thanks to javaranch
18 years ago
class Boo {
Boo(String s) { }
Boo() { }
}
class Bar extends Boo {
Bar() { }
Bar(String s) {super(s);}
void zoo() {
Boo f = new Bar() { };
}
}

--------------------------------------------------------------------------------

here I asked:

the anonymous inner class created in line Boo f = new Bar() { }; is the sub-class of which class ? of Boo or Bar

the anonymous inner class is always a sub-class (or implementer class) of the object or instance type not the reference type.

and the problem arose by chandra's statement of a class declared inside a outer-class is always a subclass of outer-class which is wrong But it is always an inner class of outer-class.

Thanks,
I understand that the anonymous class is a sub-class of the class which is used with new keyword before the curly braces of the anonymous class.

a class created inside the Bar class, would be subclass
of Bar only.
this statement is not clear. inside the bar class means what?
Given the following,


the anonymous inner class created in line Boo f = new Bar() { }; is the sub-class of which class ? of Boo or Bar
For the default constructor, yes, we need to implement Comparable. However, we've also got the alternative of providing a Comparator object in the constructor.

can you tell me how to provide a Comparator object in the constructor.

and also is it same for TreeMap that we need to override compareTo for adding objects?
keith linn was absolutely correct
it was my stupidity to check if instanceof works with rhs being a reference variable ?!
Hi Barry Gaunt for your kind information the second code compiles and runs fine and prints false
Please check it
Thanks,
int y = 5;
int x = 2;
if ((x > 3) && (y < 2) || doStuff()) {
System.out.println("true");
}

here, as there is || operator used, the expression becomes
((x > 3) && (y < 2))|| doStuff()
and || operator will check the RHS if the LHS is false which is the case here
Note that y<2 is not evaluated
also Note that true||false&&false will result true and RHS of || will not be evaluated this is because the expression is evaluated as
true||(false&&false) and if LHS is true RHS wont be evaluated.
public class aa{
public static void main(String argv[]){
aa a = new aa();
bb b=new bb();
System.out.println(b instanceof a);
}
}
class bb extends aa{}


can someone tell me why the following code fails compilation saying class a cannot be found ?

public class aa{
public static void main(String argv[]){
aa a = new aa();
bb b=new bb();
System.out.println(a instanceof b);
}
}
class bb extends aa{}

when this code compiles and prints false why the first one wont compile ?
1) An anonymous inner class constructor can take argument in some situation
2) can anonymous inner class implement an interface ?
can someone explain me point 1 with an example and answer point 2
which exam do you want to give ?