Karthik Subramanian

+ Follow
since Aug 23, 2000
Merit badge: grant badges
For More
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 Karthik Subramanian

Hi all,
Can somebody give me some useful url's having study notes on XML.I had been to some sites and it was not very helpful.Can Somebody give me the way to a very goo site
Thanks in advance

Hello friends,
I am quite new to swing.Can somebody refer me
some good books which are dedicated only to swing.
It would be of great help.
Thanks in advance.
23 years ago

Hello Friends,

Thanks to you all!!.
Doit, for strings you do not have to type the " "
(double quotes).
Class Declarations do not require the braces { }.
No statement should be ended with the semicolon ;
Thanks once again ,
Best of luck to you all.

Hello Friends,
I passed the SUN certification Exam for
programmers level yesterday securing 80%.i prepared for about
one and a half months for the exam.
My real name is Manjunath Subramanian and i have been following javaranch for the past two months.
I am happy and satisfied with the score.
Absolutely no regrets, considering the thought that it could have turned out BAD.A million Thanks to Javaranch without
whose help i couldn't have reached here .
Now About the exam.
The exam was definitely a little tougher than any of marcus's
exam but again that "MARCUS RULE" still hold's good, where your score in the exam is almost equal to the ones you got from marcus's exams.
I got 77% as an average from all Marcus Green exam which i took about 10 days ago.So it is +/- 3% to 4% deviation.
Coincidentally i had all the three famous questions on the exam.
They included s.append(),mediatracker and Sockets.I also
got a question on GridbagConstraints layout.They were quite easy.
Regarding the append() method for strings this is what i have
to say.
The question that was given was written in such a way that
as if there is really a method by that name in strings.
I initially thought of leaving the question empty but then
later i filled in the answer.AND TO MY SATISFACTION I SAW
so i would advise you guys to do the same.Just assume that
there is a append method in strings.
I don't remember exactly how many questions there where in
each topic.All that i remember is that there were
2 - Threads(Which includes waitForId())
2 - garbage collection
4 or 5 - IO
Lot of overriding and overloading
4 to 5 - Strings
2 - java.util
and the rest i am not able to recollect.
Also the some of the questions were very ambiguos.
Infact there was one question which i had earlier seen in one
of the mock exams which had checkboxes i,e to say among those list answers there were more than which was right but to my horror i saw the same question with radio buttons in the exam.There were three answers which were all equally correct and i wasted a lot of time.I don't know whether i got it right also!!??
Anyway the first phase is over and i guess it is SCJD now.
I would really appreciate if the ever ready moderators guide
me on this 'cos i really need their help.
Also i would like to help all my fellow greenhorns w.r.t
the exam.My mailid is javaman2@usa.net.I would try my best
in repling to you all individually.
All The Very Best for your exams.

Hello Friends,
I am taking the exam on the 4th os sept.
I wanted to know that if i pass the exam till when will
the certification be recognised/valid.I mean will it
be valid even after the next version of java is released??

hello friends,
This is from Abhilash's mock exam
Question 39.

import java.awt.*;
public class TestFrame extends Frame
Button bNorth = new Button("North");
Button bSouth = new Button("South");
Button bEast = new Button("East");
Button bWest = new Button("West");
Button bCenter = new Button("Center");
public TestFrame()
setLayout(new FlowLayout());
setLayout(new BorderLayout());
public static void main(String args[])
TestFrame tf = new TestFrame();

Attemping to compile and run the above code

1.Will cause a compilation error - a Layout cannot be set after a component has been added with a preset
Layout Manager.
2.Will cause a Runtime Exception - a Layout cannot be set after a component has been added with a preset
Layout Manager.
3.Will compile cleanly and throw no runtime Exception. Only the button with label "Center" is visible and
occupies the whole screen.
4.Will compile cleanly an throw no runtime Exception. All the buttons are arranged in a single line. Any other
component added in future will follow the rules of the BorderLayout Manager.
5.Will compile and run cleanly, but no component is visible.
6.Will compile cleanly and throw no runtime Exception. The buttons are arranged as listed below
Button Label Position

Center Center

North North

South South

East East

West West
The given answer is 5
Can somebody tell me how?

Hello Friends ,
This is from Abhilash's mock exam.
Question 9.

public interface AQuestion
void someMethod();
The class which implements AQuestion
1.Should have someMethod which must necessarily be public.
2.Should have someMethod which could be "friendly" or public
3.Should have someMethod which should not throw any checked exceptions.
4.Should have someMethod which cannot be sychronized as sychronized is not in the signature of the interface
The answers given are 1,3.
But my answer is 2,3.
1 is wrong, because the access modifier could be protected.
2 Though there is no keyword called friendly i assumed that he
was referring to friendly access specifier because he put
friendly word in double quotes("friendly").(What would you 0do?)
3. is right, because the super method is not throwing any
checked exceptions

Any takers,

Hi Deekasha,
I fully agree with your point that all operators, excluding = ,op=,Unary operators
operate from left to right but then doesn't the brackets i,e () sit on top of the operators precedence hierarchy.
Meaning to say that whatever operators are
present in an expression, the expression which is included inside the inner most
paranthesis is to be evaluated first.
Correct me if i am wrong.
Sorry to be so nagging!! but any replies??

Hello Sunita,
I hope you got how ,
System.out.println(s+ ","); is printing "inner,"
In the statement , System.out.println(O.this.s);
O.this refers to the inner
class object ,simply because the object that is invoking the method is of inner class type.
It is something like Outer.new Inner()
Hence it prints the string variable of th inner class. I hope it is clear.

Hello Ajith,
Thanks for the explanation.

But last night i did manage to get an answer for
Before that, you said that the subclass object
is able to call private function from the superclass.Yes that is true.But i feel that there is more than just that.
Please correct me if i am wrong.
My understanding is that whenever a class inherits from another class it inherits all
methods declared in the superclass.
But if the method is marked private then the
subclass cannot see this method because it
is hidden.
In this case because we have declared the subclass object in the superclass the subclass
object can see and invoke the method which it had inherited.Hence it is able to invoke the
method f() which is declared in the superclass

I may be wrong.Kindly clarify

Dear Ajith,
I am really thankful to you for pondering over this
But the concept is not crystal clear to me.
You had taken the help of function calling
technique to evaluate this.
But i have seen somewhere that if a piece of code
looks like this,
int a = func(i) * (i = i +2 (3 * 2));
then the func(i) is evaluated first ,even if we add
half a dozen () around the second part i,e
(i +2 (3 * 2)).

This is where i feel let down.
What i have learnt is that in any arithmetic expression irrespective of whether the
operators existing in the expression work
from left to right or from right to left,
the first part of the expression that gets to be
evaluated is the one that is put inside brackets()
From this understanding if i evaluate this expression,
int j = (i + (i = 4)) * (i = 3);
According to me ,
First Evaluation : (i = 4)//Now i is four and not 1
Second Evaluation : ( i + 4))// i, e (4 + 4) = 8
Third Evaluation : ( i = 3) // i = 3
lastly : 8 * 3 = 24, which is not the correct answer.

Therefore my question is that, why the expression
inside the brackets are not evaluated first??
Thanks Ajith,
Looking forward for your reply

I agree with wang.The answer is a,b,e

Hello Friends,
This Question is from Test your java Knowledge exam

Question 9:
Determine the result of attempting to compile and run the following code:
public class Tester {
static int x;
public static void main(String[] args) {
int i = 1;
int j = (i + (i = 4)) * (i = 3);//
int y = z() * (z() + z());
private static int z() {
return ++x;
Answer 9:
The output is:

My doubt is the evalution of the expression at line //.
Now in that marked expression the evalution occur from
left to right,but because (i = 4) is put in braces shouldn't it
be evaluated first.Doesn't the () have the highest priority??
But it is not happening here.
Could somebody explain??
Thanks a million

Hello friends,
This following question is from Test-your Java Knowledge mock exam, Question # 4.
Determine the result of attempting to compile and run the following code:
public class Tester {
public static void main(String[] args) {
System.out.println(new Sub().g());
private int f() {
return 2;
int g() {
return f();
class Sub extends Tester {
public int f() {
return 1;
ANS: The code above prints 2
But i fail to understand how??
There is no overriding happening here.
How is the subclass able to call the private method of the base
class when the object type is of it's own(i,e subclass).
can somebody throw some light??
Thankx a million

Hi KS,
If your Question is how to go about changing the values
of the local variables a,b and c by passing them to a method then i don't think it could be done.
But if you don't mind having them as instance variables
then the job becomes easy.You can do it too!!
anyway i hope i am answering your question with the following
code below
class A
int a = 10,b = 20, c=30;
public static void main(String [] args)
A x = new A();
void test()
System.out.println("Before a = " + a);
System.out.println("Before b = " + b);
System.out.println("Before c = " + c);
A y = calculate(this);
System.out.println("after a = " + y.a);
System.out.println("after b = " + y.b);
System.out.println("after c = " + y.c);
A calculate(A z)
z.a *= 2;
z.b *= 3;
z.c *= 4;
return z;