V. Potluri

Ranch Hand
+ Follow
since Mar 29, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by V. Potluri

Hi,

I would be thankful if anyone explain why "ob3 is equal to ob4" is not part of output?



Thanks In Advance,
Gopal

Hi,

I would be thankful if any one clears my doubt:

Exact purpose of volatile access modifier?

Why the abc(long...x) method is not executed in the below code?

As per my knowledge, overloaded method with widening paramter(s) has highest priority than autoboxing and var-arg parameters. According to this rule why abc(long...x) is not executed?

Regards,
Gopal
Hi,



Can any one please explain, why can't we access method local variable b inside method of Inner class

Thanks in advance.

Have a wonderful day ahead!

Regards,
Gopal
Hi Bob,

Thanks for clearing my doubt. Thanks for your detailed explanation.
Have a wonderful day ahead!

Regards,
Goapl
Hi,

The following sentences are from SCJP K&B book, page no:543

When using HashSet or LinkedHashSet, the objects you add to them must override hashCode().


If they don't override hashCode(), the default Object.hashCode() method will allow multiple objects that you might consider "meaningfully equal" to be added to your "no duplicates allowed" set.

I would be very thankful,if any one explains the concept in above sentence with detail example.

I wrote the program to understand above concept. The code is as follows:



Can I assume that, because I didn't override the hashCode() of Object class in Employee class, LinkedHashSet is allowing duplicates.

Please correct if I am wrongly understood the above concept?

Thanks in advance?

Have a wonderful day ahead!

Regards,
Gopal
Hi,

As I know that market interface doesn't contain any methods or variables.
But JVM provides extra capability to the class that implements marker interface. For example, we can create clone of an object if it's class implements Clonable interface. Otherwise we cannot create clone of an object. Violating above rule raises runtime exception called CloneNotSupportedException.

Can we call Comparator interface as an marker interface eventhough it is having abstract method called compare. The signature of comapare in Comparator interface is as follows:



1. Can we call Comparator interface as marker interface?
2. Is any interface in java ,with methods called as marker interface?

Waiting for reply. Thanks in advance!

Have a wonderful day ahead!

Regards,
Gopal
Hi Ankit,

Thanks for your excellent explanation. BTW...Could you please guide me how to answer the question with the help of diagrams, as you explained for the above mentioned question?

Have a wonderful day ahead!

Regards,
Gopal
Hi,

I am really confused in order to determine whether particular exception is thrown by JVM or programatic exception.

How can we say that below specified exceptions are thrown by JVM?

StackOverFlowError
NullPointerException
ClassCastException
NoClassDefFoundError
ArrayIndexOutOfBoundsException

How can we say that below specified exceptions are thrown Programatically?


IllegalArgumentException
NumberFormatException
AssertionError
IlegalStateException

Can any one help me to know entire Exception classes hierarchy ?

Why start() in java.lang.Thread is not final?

Because if we override the start() of java.lang.Thread class in custom thread class, then if we call start() on that custom thread object then that custom thread object will not behave as a thread because start() in java.lang.Thread is being overriden in custom thread class.

I will be very thankful if some one clears my doubts with reasoning.

Thanks in advance.

Have a wonderful day ahead!

Regards,
Gopal
Hi,

Whether it is checked exception or unchecked exception, it will be raised during execution of program.

Unchecked exception may raise because of logical problems. But certain exceptions are raised because of environmental problems. For example: in case of I/O operations with file, there is a chance that file may be moved to some other location / may not be accessable. Program fails to execute because of these problems which are not because of program code. So compiler will take extra care, what extra efforts we have taken in order to handle the environmental problems. That is why certain exceptions are checked by compiler at compile time. Because those exceptions which are checked by compiler are known as checked exceptions.

ex: IOException and it's sub classes.

Regards,
Gopal.
Hi,

static members can partcipate in inheritance. But static method cannot be ovverriden. But the rules for overriding a method and hiding a method is same.

Please let me know if my understanding is wrong?

Have a nice day ahead!

Regards,
Gopal
Hi,

Thanks a lot for each of you for spending your precious time for clearing my doubt.

Have a wonderful day ahead!

Regards,
Gopal
Hi Sudarshan and Vijitha,

First of all I will be thankful for spending your valuable time for claring my doubt.

Still I am not clear about above code?


According to my knowledge, above code will be checked at compile time and time time.

During compile time:
Is-A relation exists between type of x(here i.e. I) and J?

But IS-A relation is not satisfied in case of

According to my Knowledge, compile time error should be genereated because there is no IS-A relationship between type of x and J

If the compile time check passes, then at runtime actual object class referenced by x is same or subtype of J.

If above two cases satisfies, then
output will be printed.

Please correct me if my understanding is wrong? Waiting for reply!

Thanks in advance.

Regards,
Goapl
Hi,

Under what circumstances, we can declare constructor of a class as a protected?



According to my knowledge, constructor never participate in inheritance, then under what circumstances we have to declare constructor as protected?

Thanks in advance,

Regards,
Gopal
Hi,


Ans] a




Why x instanceof J is true? Because x is of type I. And there is no IS-A relation between I and J.

Above code prints the output : I J C D in different lines.

It would be great if someone explains why if(x instanceof J) is true?

Thanks in advance.

Regards,
Gopal