This week's book giveaway is in the iOS forum.
We're giving away four copies of Classic Computer Science Problems in Swift and have David Kopec on-line!
See this thread for details.
Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

M Srilatha

Ranch Hand
+ Follow
since Aug 27, 2008
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 M Srilatha


Encapsulation says that none of the instance variables should be public so that the variable values cant be changed directly accessing those variables. Instead all instance variables should be private and the class needs to have public methods to modify the value of private variables.

in your example, the length property of array is a final variable and one cant modify the value of a final variable. So even if the property is public, it doesnt violate the encapsulation concept.
So its also well encapsulated.

Hope this is clear!

Hello Satish,

Congratulations on the release of your book!
At present, we are working on flex with ABAP WedDynpro.
Even though we are not using JAVA to integrate flex UIs, I hope your book will be helpful for general flex concepts.

We were facing issues with large mxml application file due to lot of actionscript code inside script block.
We cant extract classes out of that code also.
And couldnt find much appropriate samples on the net on how we can split the file into multiple actionscript files.
We just know that we can use "include" tag to point to an external actionscript file. But havent understood it well.
Could you please explain the same if possible with an example?
and could you please let me know whether you will be covering this kind of coding practices in your book?

Thanks in Advance,
8 years ago

It seems the combination of '-' and '0' is illegal.
Got to know from the API documentation.

Its given:
If both the '-' and '0' flags are given then an IllegalFormatFlagsException will be thrown.

Even i am not sure why this combination is illegal.

Refer to java API doc of Formatter class for more info!

Hope this helps!

Why are you thinking that its 1 based?
StringBuilder's insert method uses zero based index.

If we take the above example, the result would be 01hello234.
When we call insert(2,"hello") on str, it inserts "hello" at index 2(means 3rd character).

Refer to the Java API documentation for more information!

At line 3, it will give compiler error as sb and s are of different types(StringBuffer and String respectively).
Operands of == operator should be type compatible.

Refer to JLS for more info!

And StringBuffer class doesnt override the equals() method. So when you use equals() method on StringBuffer object, it checks if both are referring to the same object or not. (not meaningful equivalence).

Hope this helps!


please refer to the java API documentation of getInstance(Locale loc) method in NumberFormat class.


Compile time errors(not exceptions) will come due to incorrect syntax.
Runtime Exceptions will be thrown if the usage is wrong at runtime like invoking a null object.

First we should know the correct syntax so that we would be able to find out if there are any compiler errors.
If there are no compile time errors, then we have to follow the logic in the program to find out if there can be any runtime exceptions.

IN your example, as DateFormat class is an abstract class, you cant instantiate it! so it will give compiler error!

hi rouven,

Yeah you are right!
when i saw the code before reading your view, i thought there wont be any objects available for GC.
But as you said, there will be one available for GC (array object of length 0 which was previously referenced by bc.ob[1].ob).

This looks like a tricky question. I guess as the constructor accepts var-args as parameter, when there is no parameter passed, its creating an array of length 0.

Lets see what others have to say!

For option C to be correct we need munch(Plant p) method instead of munch(Grass x)!

Because when you replace E with Plant in Interface Herbivore, method's signature would become

void munch(Plant p);

But in the implementation of Sheep, method is overloaded as Grass is used as input parameter instead of Plant.

Since there is no implementation given in Sheep for munch(Plant x), code wont compile!

For this code to compile, either Sheep class has to be abstract or we have to add implementation for method munch(Plant x).

Hope you get it!


Please refer to the following link:
how Regex works

Explanation is given very clearly!

Hi Amit,

java -ea will enable assertions in all classes except system classes.

java -da will disable assertions in all classes except system classes.

java -ea -dsa will enable assertions in all classes and disable for system classes.

-esa can be used to enable assertions for system classes where as -dsa for disabling the assertions for system classes.

Hope this is clear!


The explanation given is right only!
As fas as i know, it shouldnt give any warnings at line 2.
What warning are you getting at line 2?

all of the statements above will result as the following statement after removing generic type information:

hence the compiler will report them as duplicate method declaration!

Always remember that generic type information is only valid at compile time. when the code is compiled, all generic type information is removed from the code.

Hope this helps!

Reg 1st question: How can this be when the join method has no parameter??

First of all:
t1 and t2 are created two different objects of R. So they wont block each other.

And there is a call t1.join() just after starting t1. That means main thread waits till the time t1 finishes its task. So run() method will be executed once and prints 123. After run() method is executed, main thread resumes and starts t2. As t2 is created with a different object of R, run() method will print 123. Hence the output is: 123123.

I am not sure why you are confused with join() with no parameters.
if you call join() with no parameters, the waiting thread will become runnable just after the other thread has finished.
if you specify the maximum time that a thread can wait for another thread to finish its task, the waiting thread will become runnable after the time has elapsed if the other thread has not finished before that.

Hope this is clear!