I am prepping for my PD1 cert and am doing questions with the following link: https://www.proprofs.com/quiz-school/quizshow.php?title=developer-i_18b7&q=102
I have come across questions below which I am sure why the answers are correct. Please could someone advise me on the following 6 questions.
Q1.
Which three statements are accurate about variable scope? Choose 3 answers
A. A sub-block can reuse a parent block's variable name if it is static
B. A sub-block can reuse a parent block's variable name if it is not static
C. Parallel blocks can reuse the same variable name
D. A variable can be declarated at any point in a block
E. A variable must be declared before it can be referenced in a block
Website correct answers: B, C, D
I am sure E should be correct. Cannot think of an instance where you can reference a variable without declaring it first.
Q2.
A developer wants to display all of the picklist entries for the opportunity stagename field and all of the available record types for the opportunity object on a visualforce page. Which two actions should the developer perform to get the available picklist values and record types in the controller? Choose 2 answers
A. Use schema.recordtypeinfo returned by recordtype.sobjecttype.getdescribe().getrecordtypeinfos()
B. Use schema.picklistentry returned by opportunity.sobjecttype.getdescribe().getpicklistvalue()
C. Use schema.recordtypeinfo returned by opportunity.sobjecttype.getdescribe().getrecordtypeinfos()
D. Use schema.picklistentry returned by opportunity.stagename.getdescribe().getpicklistvalue()
Website correct answers: B, C
Just want to confirm if this is correct. So for picklist and record types you query through: object.sobjecttype.getdescribe().get…
Q3.
A developer created a visualforce page using a custom controller that calls an apex helper class. A method in the helper class hits a governor limit. what is the result of the transaction?
A. All changes made by the custom controller are saved
B. The custom controller calls the helper class method again
C. All changes in the transaction are rolled back
D. The helper class creates a savepoint and continues
Website Answer: B
I would say C as governor limit exceptions are unrecoverable
Q4.
A developer creates a custom controller and custom visualforce page by using the code block below:
public class mycontroller{
public string mystring{ get{ If(mystring ==null){mystring='a';} return
mystring; }
public string getmystring(){ return 'getmystring'; }
public string getstringmethod(){ if(mystring==null){ mystring='b'; }
return mystring; }
}
<apex:page controller="mycontroller"> {!stringmethod},{!mystring},
{!mystring} </apex:page>
What can the user expect to see when accessing the custom page?
A. A,a,a
B. A,b,b
C. B,a,getmystring
D. A,b,getmystring
Website Answer: A
Can someone explain this to me? Not sure about this one
Q5.
The account object has a custom percent field, rating, defined with a length of 2 with 0 decimal places. An account record has the value of 50% in its rating field and is processed in the apex code below after being retrieved from the database with SOQL
public void processaccount(){
decimal acctscore = acc.rating__c * 100;
}
What is the value of acctscore after this code executes?
A. 50
B. 5000
C. 5
D. 500
Website Answer: D
I tested this and got 5000. Am I incorrect?
Q6.
Given the code below, which three statements can be used to create the controller variable?
Public class accountlistcontroller{
public list<account>getaccounts(){ return controller.getrecords(); }
}
Choose 3 answers
A.
Apexpages.standardcontroller controller= new
apexpages.standardcontroller([select id from account]);
B.
Apexpages.standardsetcontroller controller=new
apexpages.standardsetcontroller(database.getquerylocator('select id from
account'));
C.
Apexpages.standardcontroller controller= new
apexpages.standardcontroller(database.getquerylocator('select id from
account'));
D.
Apexpages.standardsetcontroller controller = new
apexpages.standardsetcontroller (database.getquerylocator([select id
from account]));
E.
Apexpages.standardsetcontroller controller = new
apexpages.standardsetcontroller (database.query('select id from
account'));
Website Answers: A, D, E
Not sure why C is incorrect. If you want a list of records you need StandardSet.