Q.1.
The 8859-1 character code for the uppercase letter A is 65. Which of these code fragments declare and initialize a variable of type char with this value?
a. char ch=65;
b. char ch='\65';
c. char ch='A';
d. char ch="A";
Answer is given only (d) .But wht. is the problem with option (a) !!
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Q.2.
Which statements concerning the effect of the statement
gfx.drawRect(5, 5, 10, 10)
are true, given that gfx is a reference to a valid Graphics object?
a. The rectangle drawn will have a total width of 5 pixels.
b. The rectangle drawn will have a total height of 6 pixels.
c. The rectangle drawn will have a total width of 10 pixels.
d. The rectangle drawn will have a total height of 11 pixels.
My choice is (c) , BUT ,the answer is given (d) !! W H Y !!!
Pls..explan me this answer. as per dawRect constructor the width should be 10 . then..where I am going wrong ?
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Immutable? You can't even instantiate the Math class!Another Question(not related to above) I was thinking to ask that IS MATH CLASS IS IMMUTABLE like String or Wrapper class ?
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Originally posted by Thomas Paul:
Q.1.
The 8859-1 character code for the uppercase letter A is 65. Which of these code fragments declare and initialize a variable of type char with this value?
a. char ch=65;
b. char ch='\65';
c. char ch='A';
d. char ch="A";
Answer is given only (d) .But wht. is the problem with option (a) !!
Not only is there nothing wrong with a but d is incorrect. You can't initialize a char with a String. The correct answers are a and c.
Legal? yes it is. The slash-6 is being taken as an escape character. However, the question specifically states which code fragments will "declare and initialize a variable of type char with this value [ i.e. uppercase 'A' ]". So b is not a correct choice.Originally posted by Avinash Rai:
Answer b is also correct.
I compiled it and the output was 5.
But I don't know why ch= '\65' gives output 5 ??
So option b is legal.
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Originally posted by ratul banji:
BUT..Thomas .
The answer of q. 2 is little bit surprising.I am declearing the width as 10 ,,then
[This message has been edited by ratul banji (edited May 11, 2001).]
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog