Sarang Gurao

Greenhorn
+ Follow
since Mar 14, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Sarang Gurao

Hello
Congrates On Clearing The Exams
All The Best For Ur Future .

With Regard
Sarang
22 years ago
Hello Ian,
I think There need some modification in ur question 1 on which will make three statment true,
a) int a[] = new int[5];// valid
b) Double d = new double[4]; // Not Valid
c) Char []c = "Element"; // Not Valid
d) Object obj = new double[8]; // Here space should not be present then it is valid
e) int ab[][] = {0,1,2} {1,5,6} // Not Valid
f) int []q = {1,2,3};// Semicolon will make it valid

2) What can the throw statement throw? (select 4)
a) Error
c) RunTimeException
e) Exception
f) Throwable

[This message has been edited by Jim Yingst (edited March 31, 2001).]
Hello ,
U can refer K.mughal for this topic. The answer 2 and 3 are right answer as far as i think.
the truth abt graphic.fillRect(2, 3, 10, 20); is as follows:
1. its top left position will be 2,3
2. it will have a side of 10-1 which is 9 and the other side of 20-1=19 .that is the rectangle which will be fill with rectangle with forground will have area of (9*19). with the actual rectangle will have a area of 10*20. which will have a color of background color.
so the actual rectangle if have forground color red and background black will fill the rectangle with the red color having area 19*9 and it will have a borderline of black of 1 pixel.
i hope u get it. and clarify ur doubt.
Hello Friend
The unary operator implictly do conversion from byte to int.
so
byte b=1;
b=++b; will not give error
b=b+1; will always give u error because + operator
cannot do conversion.
in ur problem the loop will continue till the value of b becomes 127 and then value of b will -128 which becomes less than 0 hence it comes out of the loop and prints lady.
23 years ago
Hello
the casting rule does not give the compiler error but always give runtime error.
refer to RHE(Roberts , Heller and Ernest) 16 rules for casting in chapter conversion and casting.
23 years ago
Hello
the break outer statement terminates the loop with outer label
and comes out of the loop while continue outer terminates the
current iteration and start with the next iteration till the for loop conditional statement returns true.

23 years ago
Hello Friend,
Hope i can help u in this.
Overridden is done to override the method of the base class and overridden with exception have certain rule.
1. if the base class method has thrown any exception the overridden method can throws that exception or subclass of that exception. this rule apply to only checked exception and not to unchecked exception.
2. If the base class method had throws more than one exception like class xyz throws A,B,C then overridden method can throws anyone of these set of exception in subclass.
1. A
2. B
3. C
4. A,B
5. B,C
6. A,C
7. it can neither throw any exception.
i hope i am right and ur doubt is also clear upto certain limit.
23 years ago
Hello Friend,
Its a nice question. this is really a tricky to assign a value by giving a integer value to it. u know this can be done in three ways. following way i do the assignment and i got the following result.
char c1=65;
System.out.println(c1); //Give Value A
System.out.println(+ c1);//Give Value 65 (Ascii Value A)
char c2='A';
System.out.println(c2);//Give Value A
System.out.println(+ c2);//Give Value 65
char c3=65;
System.out.println(c3);//Give Value A
System.out.println(+ c3);//Give Value 65
char c4='\65';
System.out.println(c4);//Give Value 5 (65 is octal value of decimal 5 )
System.out.println(+ c4);//Give Value 53(Ascii Value of decimal 5)
char c5='\u0041';
System.out.println(c5);//Give Value A
System.out.println(+ c5);//Give Value 65
char c6='A';
System.out.println();
System.out.println(c6);//Give Value A
System.out.println(+ c6);//Give Value 65

// char c7="A";
Will not compile because String cannot assign to char.
23 years ago
Thank For kind response but i am still confuse that having a private constructor can only satisfy the condition that the class having private default constructor cannot be subclass as well as the class cannot have instance in subclass then why Math class is made final plus the constructor is also made private.
only the constructor made private and class not defined final can
also do the thing.
Hello Friends
I had some problem regarding the private constructor and having the final class. according to Robert Heller the Math class is final (so that it cannot be subclassed) and the constructor is private(so that it cannot have instance).
class A
{
private A(){}
}
class B extends A
{
}
According to RHE Math class is final class and also had a private constuctor.
Having only a private constructor and not having the class final could also make the in inability to make subclass and to have the instance of that class. then why Math class is made final.
Hello Nitin,
Nice Question:
it is true that Math class doesn't have something like
double max(double d1, int i1) but it has max function of type
double max(double d1, double d2).
then also expression double max(11.90d,119) is valid as
119 will be impicitly converted to 119.0d by widening rule
of conversion. which in turn will invoke method of max
of type double max(double,double) which will give the output 119
which will of type double. even any this will work
double max(11.90d, 119.0f)
double max(11.90f, 119.0f)
double max(11.90f, 119.0d)
double max(11.90,119)
as float can be converted to double implicitly by the compiler.

Hello Tushar,
its nice to see ur problem on javaranch. as u know that the command given is continue
it will break the current iteration and continue with the next iteration. as continue
is written as "continue outer" so it will search for the loop which has "outer :". and
continue for the next iteration till the loop returns true.
as in the example u will i<3 and j<3 so one thing is clear that i and j will never
have a value three. hence 4 option is discarded.
then the condition of if which is "if(j==2) continue outer" says that if the value
of j is 2 break the current itertion and continue with the next iteration of loop having
"outer " which is the loop having i. from this we can say that value j=2 will never be
printed as s.o.p is after the continue outer and the programme will never rich that line
if j is 2. hence option 3 is also discarded.
so finally we can that from above that i=1,2 and j=1 are the only valid values which will
be printed hence option 1 and 2 are the right answer.
iteation wise the value will be
for iteration
1 :- i=1
j=1 so the value will be printed
2 :- i=1
j=2
this will not be printed
as continue outer will execute and it will force to stop the inner loop
and then increment the value of i by 1.
3 :- i=2
j=1
so the value will be printed
4 :- i=2
j=2
this will not be printed
as continue outer will execute and it will force to stop the inner loop
and then increment the value of i by 1.
then i will be 3 but as condition is that i<3 it will beark the loop and come out
of it.

Hello Friends,
i am giving interseted to give SCJP2 and i have one problem
hope u will be able to solve.
The problem is what is the actual size of boolean value
as in Roberts and Heller old edition the size specified is 8- bits in new edition they specification is of 1- bits and in khalid mughal the had said that the size is not applicable.
so i am bit confused to decided which is true.

from
Sarang Gurao
sarang_ag@yahoo.com
@rediffmail.com
@hotmail.com
------------------