nirvan sage

Greenhorn
+ Follow
since Feb 20, 2000
Merit badge: grant badges
For More
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 nirvan sage

So finally you took it but I was excepting to see you get a 90+
after all the questions you posted and the effort you must have put in, but what the heck learning will always be productive congratulations and see you around
Hey congratulations maha thats a great score but I thought you were already certified
Any way I do hope you will stick around
regds
nirvan
What is the purpose of this dll file in the bin directory
Congratulations great job.
could you present us with some statistics on the no of
mock exams you took and how much you scored on those etc etc
One thing beautiful about computer processors is that they do not have hardware to perform subtraction then how do they perform it through addition

confused???
check this out
==============
performing computation 8 - 2
-- 1) Find binary of 8 0000 1000 (no of bits depends on hardware)
-- 2) Find binary of 2 0000 0010 (no of bits depends on hardware)
-- 3) Find Twos complement of 2 1111 1101
+ 1
-----------
1111 1110
-- 4) Add binary of 8 and 2's complement of 2 0000 1000
1111 1110
-----------
0000 0110
--5) 0000 0110 is the binary representation of 6 which is the result of 8 - 2
Subtraction made possible through addition


The main methods should be ofcourse in different classes.This
makes all the classes executable.This could be helpful in debugging the code.
Hi I took the SCP today and passed with 92%.The questions were
of course of average kind I didnt find ambiguous question of
any sort couple of good questions on threads One question on collection and GridbagLayout.Nothing on painting A question with an anonymous class inside a main method and the usual stuffs.
I think SUN dosent ask you API's that are nt discussed by R&H.
well I am not sure about it.
I had prior programming knowledge in C I used to tinker around hardware in college with it.When I graduated six months ago I tried my hands on C++ just to get an overview of the oops concept.It took me 2 and a 1/2 months to prepare for the SCP but I consider going deep into the subject is much more productive I used three books for absorbing the fundamentals 'Thinking in Java','R and H' and a book from Sun educational services
'Thinking in Java' is my fav.
Apart from JAVA I have cosiderable knowledge in JavaScript and CSS
I would say Javaranch helped me upto 30% in getting the fundamentals right for which I thank the moderators in a big way.

Will be sticking around and one more thing I scored only 54% on the Rammussen test
yes It does compile.Try what has maha has pointed out.One more thing the compiler points out an error at the method call not at the method declaration.

a) If I create a thread (Assume I use runnable interface) and want to perform some function. The entire function should reside inside public void run() method. Correct or Wrong?

I would say that is wrong you could always define new methods inside your class and call the method with the instace of the class which incidently becomes the instance of the Thread class
I think the the actual question you meant to ask was if the functionality of the threads are supported here which I think
is No.
consider the code below
<pre>
class thre extends Thread
{
public void IcanCall()
{
for(int i=0;i<=10;i++)
{
System.out.println("i can be called");
}
}
public void IcanCall2()
{
for(int i=0;i<=10;i++)
{
System.out.println("i can be called2");
}
}
public static void main(String args[])
{
thre t = new thre();
thre t1 = new thre();
//t1 and t2 instaceof Thread,Runnable and as
//and thre
t.IcanCall();
t1.IcanCall2();
}
}
</pre>
This causes the statement in method IcanCall() to be printed 11
times after which statement in IcanCall2() is executed 11 times
which proves I guess that the Threading behaviour is absent
In a windows enviroment we expect the cpu to switch between the two statement which it does not.
putting it shortly I think to obtain the functionality of threads
you need to invoke the run method
I think the directory structure ought to be
c:\package\p\p2
and the code C1 should be executing from the directory p2
in which case
you should add ;c:\package\ to your classpath.I think 'Thinking in JAVA' is an excellent reference for this topic.
I have some really big doubts about this but do allow me to state my reasonings
Lets begin with the main method it has brought thread t1 into a runnable state,now that does not necessarily causes its immediate execution. The program execution continues within the main method which eventually causes thread t2 to be made runnable. The execution ofcourse continues with the main thread unless you put it to sleep which hasnt been done and so it encounters a for loop and jumps into it and causes the

function to be executed which prints out

and returns back to the call and goes to sleep for 1 second so now the other threads get a chance and jump into action
and thus printing

I presume these two threads are thread1 and thread2 By now the main thread will have switched from its Block to ready state after
which control switches to it thus causing the statement below to be printed out

after which it goes to sleep for 1 second following which it must exit but in the later stages we see the presence of a Thread-2 which I believe is the main Thread waiting for its exit. I would like to point out one more thing thread1 and thread2 only gets to call

4 times Thread-0 has already occured 4 times so it must have exited by the time Thread-1 gets to call printAllThreads...()
and there is no chance for it be present.So I think the presence of the Thread-1 and Thread-2 in the last set of statements are actually the non daemon threads and the main thread
Besides causing an infinite loop inside the run method will cause the presence of 5 activecounts as long as the program runs
How is that possible ?Please do help in this regard

[This message has been edited by nirvan sage (edited April 22, 2000).]
I would like to add one more thing.It would be sufficient that the RunHandler extend the Thread class and override the run method for the code to run .But this does not necessarily qualify 'b' as answer because extending the Thread class is not a compulsion but impementing the interface and defining the run method is.
I think dre didnt notice that 'that' refers to an object.The code should work fine.
Since the 'equals' method is not overriden by the StringBuffer class the required functionality of the method is not avaliable with the StringBuffer objects like the one present with String class objects.
But if generating 'true' value is the thing that counts I think the following code will do

class strng
{
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("1234");
StringBuffer s2 = s1;
if(s1.equals(s2))
{
System.out.println("equals");
}
}
}

As for the first question
[This message has been edited by nirvan sage (edited March 20, 2000).]
There is some rumour about SUN introducing Swing and servlets into the SCJP exam.Could someone come up with a clarification on this.If this is true I guess that calls for a postponement of my exam.Hope not..