Win a copy of Kotlin for Android App Development this week in the Kotlin forum!

prakash chandra

+ Follow
since Aug 14, 2007
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by prakash chandra

You can use 30-35 static final variables in a class. But make sure you don't repeatedly use the same String literal in the values. You can collect all the String literals that are to be used repeatedly in values. Then declare a static final variable for that repeating literal and use the variable instead of literal. For e.g.

In the above code use of "config/" literal is avoided in CONFIG_PATH and CONFIG_FILE.
8 years ago
Method local inner class should not be allowed to access method local variable because method local variables are stored in a stack, where as method local inner class object is stored in a heap. Scope of method local variables are limited to that method only. But your method can pass the reference of the method local inner class object to some other method which can keep the method local inner class object live even if method gets over.

So, if method local inner class object is used by any other method, then that object will explode if the access to method local variables are allowed, as those local variables are already out of scope.
The best book is Kathy Sierra's and Bert Bates' "Sun Certified Programmer Guide to Java". I cleared the exam with 93% because of this book only.
enum Color{

public class TestJava{
Color c;

public static void main(String [] args) {
TestJava tj = new TestJava();;

public void fun(){
System.out.println("value of c = "+c);
System.out.println("check null = "+(c == null));
System.out.println("Using c as reference "+c.RED);


value of c = null
check null = true
Using c as reference RED
ok.. got it...

the only thing i missed was that the overridden concept stands true during object construction also. Hence the overriden method will be called even if its object creation is still in process. thanks Henry....
Its clear that the the run time object's method will be called. But in the code above the super class object creation and subclass object creation is not yet complete. So during run time how come the subclass method is called ( the object itself is not yet created) .

If we assume that ok.. the method will be called.... then how come the test() method of superclass A is not called... (the subclass method test() is called ) . Because from superclass constructor , we are calling the method test() .
public class Test extends A{

public static void main(String [] args){
Test t = null;
t = new Test();
}catch(Exception e){
System.out.println("Object t = "+t);

void test(){
System.out.println("test Test");
class A{
throw new NullPointerException("null");
void test(){
System.out.println("test A");

test Test
Object t = null

In the above program, constructor of super class A is calling a method test() and throwing NullPointerException hence construction of object of subclass Test is not possible. But then how come overridden member method test() of subclass Test is called before its object is created successfully?
i think this cannot be solved in java... still then i am trying to find a solution...
Why you need to open another command window? Same command window will work.
Write the following in a new .bat file.

cd \APS_Development\ABC\deployment\deployicicibank
start rmiregistry 51099
java qdicicibank.DManager ABC_Bankserver_ser.dmanager

Let the file name be test.bat.
You have to save this file. Let's say in c:\new location.
You have to open a command window.
Goto the c:\new location.
Type test press<enter>.

everything will be executed and window will remain open.
[ September 06, 2007: Message edited by: prakash chandra ]
11 years ago
If the .java file and images folder is inside the same folder then no need to give any path. Just

File file = new File("images\\xyz.jpg");

will automatically takes relative.
11 years ago
Another way is there to convert a char to int.

char c = '5';
int i = c; // char can be easily assigned to int.
i = i - 48; // ascii of zero is 48.

i = 5;
11 years ago
Here your problem is not clear. Still I will try to answer. I hope you will understand. Following examples will make you clear how join() works.

Lets say,
three threads main, Thread1 and Thread2 .
main thread starts a thread Thread1 and Thread1 starts another thread Thread2.

join() method always makes the parent thread to wait till the child thread ends. After child thread terminates parent thread resumes.

main is parent of Thread1.
Thread1 is parent of Thread2.

if you invoke join() in main() then program will run normally, it will not show any effect, because main() is started by JVM.
11 years ago
Here is the simple general solution. Just modify the value of SIZE variable in the code to print different size of X with *. But the value must be an odd number.
11 years ago
When a class implements Serializable, its constructor is not called when deserialized. If a super class does not implements Serializable then its constructor is called when deserialized.