Why no compiler error?
I thought we have 2 constructors of
Process8(int x) // cons 1
and
Process8(short s) .
When we pass new Process8('J') from line aa I thought....
Implicit promotion of char to int and it will get in to cons 1.
I also thought that it may be confused between cons 1 & 2 as short s can also be seen as one possible thing for promotion to int type...
(Am I Right.. Appears to be bit confused here)
Sooooo I thought for long & inferred that it will show compiler error.
But the program compiles fine.. Help me in walking through the code.
Ques No 2.
The line marked //cc passes V in to the constructor; But no o/p. Why.
Thanks in advance.
tvs sundaram
------------------------
code
------------------------
<ubb>
class Process8
{
boolean b;
public Process8(int x)
{
System.out.println((char)x);
}
public void Process8(char c)
{
if(b = java.lang.Character.isJavaIdentifierStart(c))
System.out.println(b);
}
public Process8(short s)
{
System.out.println((char)s);
}
}
public class Test8
{
Process8 p3 = new Process8('V'); // cc
public static void main(
String[ ] args)
{
Process8 p4 = new Process8('_');
}
static Process8 p1 = new Process8('J'); // line aa
static Process8 p2 = new Process8('$');
}
</ubb>
---------------------------------------------