mehrar

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

Recent posts by mehrar

The answer is correct. These kind of questions have been discussed a lot in passed. So advice for all is to redirect the discussion to something in the past. I dont remember the exact link but I have seen a lot of discussions on this past. Here two points are to be noted. One is the variable and the other is the method. The methods are always accessed by the "object type" and the varaibles are accessed by the "reference type". Now how to determine what is a object and what is a reference. Take this example :-
Base b = new Subclass()
This means that b is a reference of type Base class and is pointing to the object of type Subclass. So
b.variable will access the Base class variable which is 2 here beacuse the reference type is Base
b.method will access the Subclass method which will give 3 here, because the object type here is Subclass.
Thanks,
To stop the thread which is blocked waiting for I/O, use the
interrupt() method on the thead that is blocked (e.g. the Thread object created when the thread was started). This will cause the thread to throw an Interrupted exception. Note that if the I/O thread is NOT blocked waiting, the interrupt() method will NOT cause it to throw an exception or interrupt its sequence of execution; in this case the thread itself has to check using isInterrupted() and take action as appropriate. (There is no way in Java to interrupt the flow of execution of a running thread).
------------------
Raj
I think it should be like this:-
1. sleep -- The thread sleeps for sometime. Not a stop.
2. stop -- Stop the thread.
3. wait -- It is a wait to be notified. So not a stop.
4. yield -- It causes the currently executing thread object to temporarily pause and allow other threads to execute. Not a stop
5. interrupt -- yes it will stop the thread.
6. suspend -- No it will not stop the thread but will suspend it for sometime and resume it later.. These methods are deprecated now.
7. waitforId/waitforData
8. blocked for io
No the thread processes the rest of it once the blocked IO is complete. Like reading a file.
9. If the current thread starts the new thread
No this will not stop the thread as the new thread will run in as a seperate entity.
10. Thread with higher priority is in the pool.
Usually the HIGH Priority thread waits till CPU gets enough time for it to process this thread. It will not stop the running low priority thread.
Can someone put more thoughts to it...

------------------
Raj
3 Answer should be d. As in Encapsulation the idea is to change the implemenation keeping the interface same so that the other code doesnt require the code changes.
If a class can access the super class constructors and methods then why we say that this class can not inherit its super class constructors. I know you can not override a Constructor, which means you can not add a new feature to the constructor. But as long as you are able to access it can't we say we are inheriting it.
Can someone put more thoughts in it........
Congratulations!!!
------------------
Raj
Byte range is from -128 to 127. This means that 0x007f is the maximum number (equivalent to 127). If you add one to it JVM will take the two's compliment because the MSB becomes 1 which means negative. In this case 0x00f0 will be 1111 0000 in binary. Now Two's compliment of this is 0001 0000 and the sign bit is 1 which means negative number. Now the Decimal equivalent of (0001 0000) is 16 but with the sign bit on will be -16. So if you convert 0x00f0 into decimel you'll get -16. Similarly the double INFINITE is 0xffff which is 1111 1111 1111 1111 in binary. Two's compliment of it will be 0000 0000 0000 0001 with the sign bit on. Thus the binary equivalent will be -1. In case of 0x00ff it will be -1, and in case of oxfe it will be -2.
Another explanation to this is like this :-
0x00ff = 0000 0000 1111 1111
-128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = -1
Hope it helps.
------------------
Raj
As long as you have the method with the Object type arguement used with method with either StringBuffer or String type argument, it will compile. The idea here is that JVM will execute the method that is lower in the hierachy. But if you create an Object type first and then pass it to the method the JVM will call the method with the Object type arguement.
eg.
public class AQuestion
{
public void method(Object o)
{

System.out.println("Object Version");
}
public void method(StringBuffer sb)
{
System.out.println("String Buffer Version");
}
public static void main(String args[])
{
AQuestion question = new AQuestion();
Object obj=null;
question.method(obj);
}
}
The o/p in this case will be :-
Object Version
In Java there all the threads created start as user threads. You can convert the user threads to daemon threads by using the method setDaemon(). The benefits of the Daemon threads over user threads is while exiting the program, JVM looks for all the running threads and if only the daemon threads are running then JVM exits otherwise if there is any user thread than JVM waits for it to finish. Thhus typically when the programmer is sure that certain activities will not be affected if terminated in between, these can be run as daemon threads.
Hope this helps.
------------------
Raj
Typo I missed one f. It should be oxffff, oxfffe, oxfffd...
In this case d1 is infinite which means a hex equivalent of oxfff. This when converted to decimal will give you -1. Instead if hex equivalent is oxffe then the decimal equivalent is -2 and will be -3 for oxffd...so on.
The instanceof operator is takes the left hand side as the Reference and the RHS as the type. Here type can be a class type, an array type or an interface. In case of arrays the instance of operator returns only when the array is an instance of its primitive type. But since all arrays descended from object and object array instance of returns true when we check it against each of these.
Example :-
String[] str = new String[10];
now
str instanceof String[] ===returns true
str instanceof Object ===returns true
str instanceof Object[] ===returns true
str instanceof String ===Compilation Error
Similarly when you check :-
t instanceof Throwable[] ===returns true
whereas, t instanceof Throwable ===Compilation Error
Hope this helps..

------------------
Raj
It should be -2. Cause when you round a number if the decimal is greater then 5 then it number is converted to the one higher in the scale. In the scale the negative numbers decrease to zero and positive numbers increase from zero, which means that
for -2.5 the next higher will be -2. Hope this helps.

Originally posted by mehrar:
Inner classes have access to only the final local variables of the outer class. "Final local variables" are the outer class method variables declared as final. Since serialN is not declared as final so the inner class can not access it.


Here above the reference is in regard to the "outer class local variables". Otherwise inner class have access to all the variables of the outer class. I may sound incorrect above if "only" is interpreted for all outer calss variables.
Inner classes have access to only the final local variables of the outer class. "Final local variables" are the outer class method variables declared as final. Since serialN is not declared as final so the inner class can not access it.