aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Miscellaneous Doubts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Miscellaneous Doubts" Watch "Miscellaneous Doubts" New topic
Author

Miscellaneous Doubts

Gari Jain
Ranch Hand

Joined: Jun 29, 2009
Posts: 100
QUESTION 1:


Which are true? (Choose all that apply.)
A. The output could contain 30
B. The output could contain @bf73fa
C. The output could contain DIAMONDS
D. Compilation fails due to an error on line 6
E. Compilation fails due to an error on line 7
F. Compilation fails due to an error on line 8

Ans: A and B
But on line 13 points is accessed wch is private then

shudnt the code fail to compile?


OCPJP 6-100%; Preparing for GATE11
Gari Jain
Ranch Hand

Joined: Jun 29, 2009
Posts: 100
QUESTION2:




What is the result?
A. 5 7
B. 5 8
C. 8 7
D. 8 8
E. Compilation fails
F. An exception is thrown at runtime

Ans: E

The parameter declared on line 9 is valid (although ugly), but the variable
name ouch cannot be declared again on line 11 in the same scope as the declaration on
line 9.

but isnt ouch declared inside for inside another scope?
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

First of all QuoteYourSources.

About question 1. The main method is in the same class thus has access.
About question 2. No that is not true. Because the method parameter ouch is still visible in the for loop and cannot be hidden.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

Also, please post individual questions in their own topics with appropriate subjects.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sumit kothalikar
Ranch Hand

Joined: Apr 15, 2010
Posts: 91

Question 1:here we are accessing the private variable of the class from te class itself thus it has access

as explained bu Wouter Oet
About question 1. The main method is in the same class thus has access.


Thanks & Regards
Sumit Kothalikar
Gari Jain
Ranch Hand

Joined: Jun 29, 2009
Posts: 100
Thankyou All...

The question are from(K&B)
 
Consider Paul's rocket mass heater.
 
subject: Miscellaneous Doubts