Suresh Rajadurai

Ranch Hand
+ Follow
since Feb 22, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
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 Suresh Rajadurai

Hi Folks,

The following code


converts the string s to upper-case.
what is the formatter syntax to convert upper-case string to lower case?


Thanks in advance

Suresh.
15 years ago
Hi folks.

I have a program in the folder c:\javatest\p




I have compiled this program and it created a class file in the same folder.

I created another program in the folder c:\javatest




The second program gives compilation error:

cannot find symbol
symbol: variable i
location class parent.



Then I replaced the i with public variable j, assuming because it was declared protected it gave compilation error, but still for variable j, even though it was declared as public it gives the same compilation error. can anybody throw some light on it please.


much appreciated


thanks in advance


Suresh.
15 years ago
Hi Ernest,

So according to you,

the object returned by the statement t.getObject() is similar to object created by the statement
A obj = new B() ? Am I right?


for my explanation, please have a look at the following code:



Since my original program (my originial posting in this thread (far above) ) gives the output as 5 , I assume the object returned by the statement t.getObject() is similar to the object created in line //declaration Q above? Am I right?

I am realy confused.


Suresh.
15 years ago
Sorry,

I dont understand the explanation.

My question is,

if t.getObject() is returning "Object B", then t.getObject().x is supposed to return 6 and NOT 5.


thanks


Suresh.
15 years ago
Hi folks,

please have a look at the following code:




When I compiled and ran this code , the output is:

its B from subcovtest
5.

Even though its returning the B object , why its NOT returning x value from B, i.e 6?

Is the object being returned from "t.getObject()" (in line //*)
similar to the object created by the command "B b = new B()" ? or "A b = new B()" ?



much appreciated and thanks in advance.


Suresh
15 years ago
Exception in Thread "main" java.lang.ClassCastException: Car cannot be cast to Bus at test.main(gen13a.java:19).

The line number 19 is where the statement "for (Object obj : b)"


Please note that, in the forum, I did not type the import statement even though I had it in my program. Therefore if you add 2 to the lines of code above, the 19th line is the "for loop" line.


Suresh
15 years ago
Hi folks,

Please have a look at the following code:




Please see the line which I marked (A).
If I replace this line with "for (Object obj : c)" its giving run-time exception.

Could anybody please throw some light on it please.


much appreciated, many thanks,

Regards

Suresh.
15 years ago
Hi Folks,

I have a problem in the following code:




When I compiled this code and ran this, the output was
false, true, false.

But I expected to be false false false. Since when the primitives are wrapped, it become different objects. Can anybody throw some light on it PLEASE.

Much appreciated.

Regards

Suresh.
15 years ago
Hi Folks,

I have a confusion over the declaration of String & StringBuffer literals.

Statement 1: String s = "its a new string";
Statement 2: StringBuffer s = "Its a new string buffer";

Why , the 2nd statement gives compilation error?. But if I replace the statement with:

StringBuffer s = new StringBuffer("its a new string buffer");

it does not give compilation error.


Could anybody please throw some light on it.


much appreciated,

thanks

Suresh
15 years ago
Hi Folks,

Please see the following 2 programs. could you please explain me why program 1 is giving compilation errors(complaining that it is expecting catch block) while program 2 is working fine without the catch block.

Only difference is , method in program 1 is void return type, whereas method in program 2 is integer return type. Is it permitted to avoid having a catch block in the method if the return type of the method is NOT void? I am confused.

Program 1:



Program 2:




Much appreciated,

thanks in advance,

Suresh.
15 years ago
Thank you Ernest for the beautiful explanation. Now I got the idea.


Regards

Suresh.
15 years ago
Hi folks,

Could you please let me know the difference between the following 2 piece of codes please. If 1 is correct why should we write unnecessary additional codes in 2? What is the advantage of 2 over 1?

1:


2:



Thanks a lot,

Suresh
15 years ago
Hi Folks,

Please note the following program:


It is giving the following output:

S1 Before Append : Hello
S1 After Append : Hello How are you
S1 After S1=S2 : Doing
Final Output in Main Method : Hello How Are you.

Could you please explain me why it is NOT printing "Doing" in the last output (it has been changed to "doing" in the method myBuf() ?
In the statement "s1=s2", if s1 and s2 are local to the method myBuf(),
then why in the statement s1.append("how are you") , s1 is not local to the method myBuff().

I am a bit confused. A good explanation is GREATLY APPRECIATED.

Thanks in advance

Best Regards

Suresh
15 years ago
Hi Folks,

I dont know under which category I have to post this question.

Before I post a question, I usually search the forums to see whether there are any identical questions/discussions which already exists, so that I would not duplicate the post and also to save time.
However I am unable to search the word "Arrays.asList". It looks like it does not recognize the period in between "Arrays" and "asList". Is there any way I could search for this word "Arrays.asList". Not only this word, even I search some other words, it does not work if it comes with "()" or the period.


Regards

Suresh.
15 years ago