SCJP MATERIAL
  <<Back To SCJP Material Main Page
Page: 16

8. OOPs

67. Given:
1. class Zing {
2. protected Hmpf h;
3. }
4. class Woop extends Zing { }
5. class Hmpf { }
Which is true? (Choose all that apply.)
A. Woop is-a Hmpf and has-a Zing.
B. Zing is-a Woop and has-a Hmpf.
C. Hmpf has-a Woop and Woop is-a Zing.
D. Woop has-a Hmpf and Woop is-a Zing.
E. Zing has-a Hmpf and Zing is-a Woop.

Answer:
->  D is correct, Woop inherits a Hmpf from Zing.
->  A, B, C, and E are incorrect based on the preceding.

68. Given:
1. class Programmer {
2. Programmer debug() { return this; }
3. }
4. class SCJP extends Programmer {
5. // insert code here
6. }
Which, inserted at line 5, will compile? (Choose all that apply.)
A. Programmer debug() { return this; }
B. SCJP debug() { return this; }
C. Object debug() { return this; }
D. int debug() { return 1; }
E. int debug(int x) { return 1; }
F. Object debug(int x) { return this; }
Answer:
->  A, B, E, and F are correct. A and B are examples of overriding, specifically, B is an
example of overriding using a covariant return. E and F are examples of overloading.
->  C and D are incorrect. They are illegal overrides because their return types are
incompatible. They are illegal overloads because their arguments did not change.

69. Given:
class Uber {
static int y = 2;
Uber(int x) { this(); y = y * 2; }
Uber() { y++; }
}
class Minor extends Uber {
Minor() { super(y); y = y + 3; }
public static void main(String [] args) {
new Minor();
System.out.println(y);
} }
What is the result?
A. 6                                B. 7
C. 8                                D. 9
E. Compilation fails.      F. An exception is thrown.
Answer:
-> D is correct. Minor’s constructor makes an explicit call to Uber’s 1-arg constructor,
which makes an explicit (this) call to Uber’s no-arg constructor, which increments y,
then returns to the 1-arg constructor, which multiples y * 2, and then returns to Minor’s
constructor, which adds 3 to y.
->  A, B, C, E, and F are incorrect based on the preceding.

70. Which statement(s) are true? (Choose all that apply.)

A. Cohesion is the OO principle most closely associated with hiding implementation details.
B. Cohesion is the OO principle most closely associated with making sure that classes know
about other classes only through their APIs.
C. Cohesion is the OO principle most closely associated with making sure that a class is
designed with a single, well-focused purpose.
D. Cohesion is the OO principle most closely associated with allowing a single object to be seen as having many types.
Answer:
->  Answer C is correct.
->  A refers to encapsulation, B refers to coupling, and D refers to polymorphism.

Page: 16

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
  <<Back To SCJP Material Main Page



freshers jobs | fresher jobs | freshers job | fresher job | fresher it jobs | sap fresher jobs | jobs for fresher | jobs for freshers | it jobs for freshers | abap fresher jobs | net jobs for freshers | net fresher jobs | net freshers jobs | freshers job sites | fresher job openings | software jobs for freshers | fresher jobs bangalore | hr jobs for freshers | software testing jobs for freshers | fresher jobs india | fresher jobs chennai | fresher it job | freshers it jobs | mba fresher jobs | hr fresher jobs | fresher jobs in india | networking jobs for freshers | testing jobs for freshers | job for fresher | oracle fresher jobs | mca fresher jobs | sap freshers jobs | jobs for mca freshers | fresher jobs hyd | freshers software jobs | it job for freshers | fresher job sites | jobs for mba freshers | freshers job it | hot jobs for freshers | job for freshers | testing fresher jobs | mainframe fresher jobs | jobs for freshers sap | fresher jobs at | fresher jobs usa | jobs for freshers at | jobs for freshers usa | freshers jobs at | freshers jobs usa | tech freshers jobs | net freshers job | software fresher jobs | job opportunities for freshers | jobs for freshers in usa | job vacancies for freshers | jobs mumbai fresher | it jobs for fresher | freshers job openings | job openings for freshers | it jobs for freshers in | freshers jobs bangalore | freshers job india | freshers jobs india | jobs in pune for freshers | jobs for fresher in | fresher jobs in usa | net fresher jobs in | fresher jobs in | fresher job in usa | jobs for freshers in | qa jobs for freshers | fresher jobs in dubai | freshers jobs in usa | job opening for freshers | hr freshers job | freshers job in usa | job openings for freshers in | fresher it jobs in | freshers it jobs in | job for fresher in | job for freshers in | testing jobs for freshers in | sap jobs for freshers in | sap freshers jobs in | sap fresher jobs in | mba freshers jobs | jobs for freshers in delhi | jobs for freshers in mumbai | freshers jobs in delhi | fresher jobs in mumbai | fresher jobs in bangalore | fresher jobs in delhi | net jobs for freshers in | fresher jobs in hyderabad | mba freshers job | freshers job in bangalore | fresher hr jobs in | fresher job in | jobs freshers in | finance jobs for freshers | hr jobs for freshers in | jobs in dubai for freshers | fresher it jobs in bangalore | freshers job in india | freshers job in | software jobs for freshers in | mba fresher job | fresher software jobs in | software testing jobs for freshers in | freshers jobs in mumbai | fresher jobs in chennai | mba fresher jobs in | mba finance fresher jobs | jobs for mba freshers in | jobs for mba fresher | mba freshers jobs in | fresher jobs hyderabad | hr freshers jobs | fresher jobs in pune | freshers jobs in pune | freshers jobs in chennai | jobs for mba finance fresher | freshers job in chennai | jobs for mba finance freshers | finance fresher jobs | jobs for freshers in hyderabad | freshers jobs in hyderabad | jobs for freshers in bangalore | freshers jobs in india | jobs for freshers in chennai | jobs for freshers in india | instrumentation jobs for freshers | freshers jobs in bangalore | engineering jobs for freshers in | job for mba fresher | mechanical fresher jobs | mca freshers jobs | jobs for bca freshers | b tech freshers jobs | sap jobs for fresher | sap abap fresher jobs | job sites for freshers | fresher | jobs | bpo jobs | freshers | careers freshers | freshers it | it jobs | fresher world | mba jobs | j2ee jobs | fresher recruitment | call center jobs | testing jobs | finance jobs | call centre jobs | networking jobs | wipro jobs | hyderabad jobs | chennai jobs | fresher opening | pune jobs | telecom jobs | fresher openings | banglore jobs | bangalore jobs | mca jobs | tcs jobs | kolkata jobs | it fresher | mba fresher | fresher india | gurgaon jobs | hr jobs | noida jobs | india jobs | mumbai jobs | fresh graduates | delhi jobs | freshers recruitment | consultant jobs | engineer jobs | engineering jobs | sap jobs | parttime job | walkin jobs | internet jobs | data entry jobs | jobs career | local jobs | online jobs | parttime jobs | online part time job | technical support jobs | net jobs | jobs at | software jobs | website jobs

Home   |   About Us   |   Contact Us
Copyright @ durgasoft.com