saravanan ragunathan

Ranch Hand
+ Follow
since Aug 02, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
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 saravanan ragunathan

thanks for your reply

so all arrays are considered to be a single object not an array of objects

Object[] objArray = new String[2][3];

objArray[0] refers to ?

13 years ago
get confused with this code

This compiles fine. because Object is a super class String is a sub class

but the following code produce errors
13 years ago
thanks for your answer and correction in my question...

but why the integer literals are automaticlly converted to int by default..why not byte,short,long
13 years ago
is there any difficulty for the compiler for matching
argument and parameter by providing casting..or is there any other reason

13 years ago


here b and c are byte but the expression (b+c) returns value as int
why the byte values are automatically converted to int..why not operate in
byte as well
13 years ago

here 7 is integer litearl representing int as default type so the compiler
converts this statement as

but when i pass the 7 to a method i am getting error why

13 years ago


how many objects are created in this program?

1: Dozens[] da=new Dozens[3]; (array is an object)
2 and 3:da[0]=new Dozens(); da[0] refers to an object(included as array dz (object)instance variable)
4 and 5: Dozens d=new Dozens(); d refers to an object(included as array dz(object)instance variable)

so the answer is 5:

but i think main(String[] args) here String[] array is also an Object

so the answer is 6:

this is correct or not?



thanks for sharing information ...

13 years ago
why the java developers avoids this
is there any performance degradation..any other reason
13 years ago


when i pass the primitive variables such as c or b with reference of int array
object(a) i am getting error ...why
13 years ago


when i use explicit casting without outer parantheses (Dog) animal.eat(); instead of ((Dog) animal).eat();
i am getting compilation error...what these parantheses tell to the compiler..how the compiler understand
this explicit casting with and without outer parantheses
13 years ago


If the rules of overriding are not followed- then it becomes method overloading and that will surely not participate in the kind of polymorphism we are talking when we consider overriding.



thanks for your answer...

Not really, static methods are class-wide methods, and not instance-wide methods. First you have to think of difference between a class and an instance of that class, thus instance methods are methods for instances of a class, and static methods are for class itself. For example this is the reason you cannot call instance methods inside static methods, because in static methods there is no instance, it is class-wide.



i know that static=class level
non static =instance level

my doubt is why they apply the same rules(can't mention
weaker privileges,can't mention different return types)
for method hiding as in method overridding...
thanks gentlemans...
i understand that static method can't be overridden because
jvm takes only reference type not an real object they refers

so static methods are used for method hiding..
but same rules are applied to method hiding as in overridding
like (can't mention weaker privileges,can't mention
different return type)

why?
we can declare only one public file in a source file and file name must match the public class name

is there any reason to this restriction....