Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!

Neha Monga

Ranch Hand
+ Follow
since Mar 13, 2007
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 Neha Monga

Hello all!

I want to write a java program that will open a new browser and launch the specified URL and will sign in.

While I was able to write a program to open a browser and launch the URL, I am not able to sign in using the program.

Any help in this regard is highly appreciated!

Thanks!
Neha M
12 years ago
Hello all,

I am having trouble gaining connection to two different pools in the same method. I need to query two tables which reside in different data sources. The output from one query is the input for the second query. The second query gets executed for as many times as there are rows in the output of first query.

I am getting this exception when trying to access different connection pools using two different connection objects -->

"java.sql.SQLException: Connection has already been created in this tx context for pool named myPool. Illegal attempt to create connection from another pool: ccPool"

Please assist.

Thanks!
Neha M
Hello all,

I am stuck with a program. I want to write a program in Java that outputs the day for any date that user inputs.

Kindly help me with the logic!

Thanks,
Neha
13 years ago
Thank you everyone for your wishes.

Good luck to all those who are planning to take exam.

Regards
Neha
13 years ago
Hello Ranchers!
I took SCJP 1.4 exam today and scored 95%. I want to thank all of you for your support. Javaranch forum really helped me in this exam...several of my doubts/questions were answered here.

Once again Thanks a bunch all!

Regards Neha Monga
13 years ago
Yes Chandra, the code provided by you compiles fine and runs...

Would you know why an inner class with private constructor can be subclassed?

Thanks!
Neha Monga
Hello Rupika!

If a class has both private and public constructors then that class can be extended. But private superclass constructor should not be called from sub class as its not visible in subclass. In order to get your code compiled correctly, you need to make sure that you chain constructors appropriately such that private superclass constructor is not called from sub class though it can very well be called from another super class constructor.

But if a class has just one explicit default/non-default constructor declared as PRIVATE, then that class cannot be extended.Compiler will complain if you extend that class. Such a class is known as 'Singleton'.

Hope the above explanation suffices.

Ranchers, pls correct me if I am wrong.

Thanks
Neha Monga
Hello Ranchers!



ouput --> Hello
Default

Pls explain why the output is NOT -->
Default
Default

Appreciate your help!

Thanks
Neha Monga
Hello Barry!

In your above code snippet, interface I is being instantiated. As far as I know, interfaces cannot be instantiated. Am I missing something? Pls correct me if I am wrong.

Thanks!
Neha Monga
Hey Sasha!

This all is very confusing....
Hello Anil!

With the help of above example do you intend to say that the instance variables in a class will be initialised to their default values only when the constructor of the top most class i.e. Object has completed. Even if the constructors of intermediate classes haven't completed, the variables in the subclass(which is being instantiated) will be initialised to default values.

Pls confirm!

Thanks Neha
Okay..I got it right...

Thanks all!
Hello All,

public class Test {
float f;
Test() {
this(f);//line 1
f=3;
}
Test(float f) {
System.out.println(f);
}
public static void main(String args[]) {
Test t = new Test();
}
}


Compiler error at line 1 - Cannot reference 'f' before supertype constructor has been called.

Why does the compiler complains for the above code? Per my understanding, 'f' is initialised to 0.0 before any statement in any of the constructors is executed.

Pls explain.

Thanks in advance!
Neha
Thanks Pravin, Krishnan, Sergio, Zhao and Dan for clarifying!

Neha Monga
Hello Ranchers!

class C {

public static void main(String args[]) {
Boolean b1 = Boolean.valueOf(true);//line 1
Boolean b2 = Boolean.valueOf(true);//line 2
Boolean b3 = Boolean.valueOf("TrUe");
Boolean b4 = Boolean.valueOf("tRuE");
System.out.println((b1==b2)+",");//line 3
System.out.println((b1.booleanValue()==b2.booleanValue())+",");
System.out.println((b3.equals(b4));
}
}

The output is - true,true,true

Per my understanding, valueOf method takes a String argument so the above code should not compile as String is not passed as argument to valueOf method at line 1 and line 2.

Even if String is passed as argument to methods at line 1 and line 2, line 3 should yield 'false' as 'valueOf(String s)' method returns an object.Hence, b1 and b2 are two different objects. Therefore, b1==b2 should give false.

Pls explain.

Thanks
Neha Monga