Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Sivaram Ghorakavi

Ranch Hand
+ Follow
since Nov 30, 2000
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 Sivaram Ghorakavi

Does Java use native threads of the OS?? If not, is there a possible way to tell JVM to use these??? Using native threads of the OS boosts the performance.
Thanx
21 years ago
If you are sure about the destination platform (like Windows) use free tools available to conver the java application class files to EXE and distribute it as single file. NO JVM required I believe!!!
21 years ago
Go thro this and try to solve the problem you own!!! Have fun...
http://developer.java.sun.com/developer/TechTips/2000/tt1205.html#tip2

Originally posted by may leung:
class Base {
int i;
Base(){
add(1);
}
void add (int v){
i+=v;
}
void print(){
System.out.println (i);
}
}
class Extension extends Base{
Extension(){
add(2);
}
void add(int v){
i += v*2;
}
}

public class Test {
public static void main (String args []) {
bogo(new Extension());
}
static void bogo(Base b){
b.add(8);
b.print();
}
}
a. 9
b. 18
c. 20
d.21
e.22
the ans is 22 but I am quite confuse in this question, can anyone explain in detail?
Thanks~


Amit,
If two applets are in the same context they you can communicate using AppletContext. If they are two different applets then you have to have a kind of Manager/Server to communicate across. Infact this is how we did to keep all the applets in sync across client windows. Hope this helps.

Originally posted by amit sanghai:

Hi everybody,
How can I call an Applet from another Applet?


Floating point division never results in ArithmaticException, instead the value, here in this case is infinity. And if you cast it to byte yields to the max value (all bits set) FOR BYTE. Hence you see -1. Check out JLS 4.3.
Hope this helps.

Originally posted by balu gates:
Hi
Explain this..........
class Infinite {
public static void main(String args[]) {
double d1=1.0;
double d2=0.0;
int b=1;
d1=d1/d2;
b=(byte)d1;
System.out.println(b);

}
}
The answer is -1.
Explain.


Raukutam,
Thumb rule is the floating point division never raises ArithmaticException unlike integer division, the values is +/- Infinity instead. Check the JLS 4.2.3

Originally posted by Raukutam Sandeep:
hi everybody,

1) int a=10;
int b=0;
int c=a/b;
System.out.println(c);
2) double a=10.0f;
int b=0;
double c=a/b;
System.out.println(c);
The first program is giving an exception, however.
But the output of the second program is , i'm getting
'Infinity' on the console.
How is it happening?
Pls explain me.
regds,
Sandeep.


21 years ago
Angela,
I think you are wrong. Deafult(no access modifier) mean the class is accesseble with in the package, not protected. Protected mean class in different packages can extend this class which is not true for DEFAULT accessibility.
21 years ago
Angela,
I think you are wrong. Deafult(no access modifier) mean the class is accesseble with in the package, not protected. Protected mean class in different packages can extend this class which is not true for DEFAULT accessibility.
21 years ago

Originally posted by Stephen Peterson:
Exactly Sivaram! So is there a way to satisfy this requirement of the compiler?
Some dead-ends I went down. I setup an interface java file
BooleanResult.java
==================
import java.util.*;
interface BooleanResult { static boolean getResult(Vector v); }
But this did not work since the compiler tells me I cannot use
statics in an interface.
So I decided to try instantiating an object rather then just loading it and using it. I did the following:
(1) I took "static" out of my BooleanResult interface,
(2) I took "static" out of my TestClass2.java file, and added
"implements BooleanResult" to it
(3) I changed 2 lines in TestClass.java as follows:
BooleanResult o = new Class.forName(args[0]);
HasVector hasVector = new HasVector();
Now I cannot compile the TestClass.java because the Class.forName only works as a static:
$ javac TestClass.java
TestClass.java:17: Class java.lang.Class. forName not found in type declaration.
BooleanResult o = new Class.forName(args[0]);
^
1 error
$
By the way, I got that idea of trying an interface to solve this issue after looking at a very informative post by Peter Tran (his "personal example") posted to Object "Savvy" forum only a few minutes ago.



Yah... You can't make explicitly method declaration static in Interfaces, 'coz they are by default static, public and final. Neither you can instantiate the Class.forName(...) sinece it's static. The idea of implementing an interface is perfet. Did you try looking at Reflection...
21 years ago
This need very simple explanation. The
Object o = Class.forName(args[0]);
//1 System.out.println("Result: "+o.getResult(v));
o is an instance of TestClass2 at runtime. But the compiler does not know about this method, in Object, at compile time and it complains. If Object class had the same method, getResult(...),then compiler wouldn't complain.
21 years ago
Implementing Runnable interface is much lighter than extending Thread. Lighter in the sence the over head of Thread class members etc... More over if you extend Thread class you loose the option of extending any other calss. But implementing Runnable will give you this choice.
instanceof operator should only be used against the Reference of Object. If you really want to find what class time it try using isInstance(Object obj) method from class Class.
I would suggest to go thro' Collection. You definetly find atleast one question. But I bet that would be very fundamental question for ex: Which of the following would be best choice for unique sorted elements...
a)HashSet b)HashTable c)SortedSet ... some thing like this. It's not really that defficult if u understand the fundamentals of Collection interface.
BOL
'Coz '28378L' is a string literal and cannot be converted to Long value. Any character presence in such converstion would raise this exception.
I think this code does compile. My understanding of the explanation is there is no thread ever started on this class. Hence the run method nerver called and no output either.