• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

KHALID >> MOCK

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
These Questions r 4rm KHALID's MOCK >>>>

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) !!

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 ?

Another Question(not related to above) I was thinking to ask that
'IS MATH CLASS IS IMMUTABLE like String or Wrapper class ? '

pleze,help me.
Thanks in advance.

 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
------------------
Co-Moderator of the Programmer Certification Forums
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ?


According to the API, "The left and right edges of the rectangle are at x and x + width. The top and bottom edges are at y and y + height."
So let's say x and y are 0 and the width and height are 10. Then the starting pixel of the rectangle will be 0 and the ending pixel will be 0 + 10 = 10. Counting from 0 to 10 gives 11 pixels.
------------------
Co-Moderator of the Programmer Certification Forums
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Another Question(not related to above) I was thinking to ask that IS MATH CLASS IS IMMUTABLE like String or Wrapper class ?

Immutable? You can't even instantiate the Math class!

------------------
Co-Moderator of the Programmer Certification Forums
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.



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.

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
James Roddy
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THANKS Thomas
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

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.
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).]


Yes, and strangely if you create a Rectangle object then width and height actually represent the width and height!
 
reply
    Bookmark Topic Watch Topic
  • New Topic