Sunday, April 1, 2018

Simple Binary Tree Program

Simple Binary Tree:

In this blog we will see, how to create a simple binary tree. We will be using Queue data structure to store the last node inserted in the tree. This will prevent unnecessary traversal of tree for each new node insertion.

Time Complexity: O(n)
Space Complexity: O(n)


Monday, May 29, 2017

Salesforce Platform Developer 1 Questions

Recently I gave exam for PD1 and cleared it quite easily. Here are questions which I referred while preparing for it. Just go through it..!! Good Luck

1.       Why would a developer use Test. startTest( ) and Test.stopTest()

a)      To avoid Apex code coverage requirements for the code between these lines
b)      To start and stop anonymous block execution when executing anonymous Apex code
c)       To indicate test code so that it does not Impact Apex line count governor limits.
d)      To create an additional set of governor limits during the execution of a single test class.

2.       What must the Controller for a Visualforce page utilize to override the Standard Opportunity view button?

a)      The StandardSetController to support related lists for pagination.
b)      The Opportunity StandardController for pre-built functionality.
c)       A callback constructor to reference the StandardController.
d)      A constructor that intrializes a private Opportunity variable.Term

3.       A developer uses a before insert trigger on the Lead object to fetch the Territory__c object, where the Territory__c.PostalCode__c matches the Lead.PostalCode. The code fails when the developer uses the Apex Data Loader to insert 10,000 Lead records. The developer has the following code block:
      01 for(Lead l : Trigger.new){
      02    if(l.PostalCode != null){
      03        List TerrList = [select Id FROM Territory__c WHERE PostalCode__c =: l.PostalCod;
      04       if(terrList.size() >0){
      05           l.Territory__c = terrList[.Id;
      06       }
      07    }
      08 }
      Which line of code is causing the code block to fail?

a)      03: A SOQL query is located inside of the for loop code.
b)       01: Trigger.new is not valid in a before insert Trigger.
c)       02: a NullPointer exception is thrown if PostalCode is null.
d)       05: The Lead in a before insert Trigger cannot be updated

4.       What would a developer do to update a picklist field on related Opportunity records when a modification to the associated Account record is detected?

a)      Create a process with Process Builder.
b)      Create a workflow rule with a field update.
c)       Create a Lightning Component.
d)       Create a Lightning Component.

5.       Which requirement needs to be implemented by using standard workflow
instead of Process Builder?Choose 2 answersA

a)      Create activities at multiple intervals.
b)      Send an outbound message without Apex code.
c)       Copy an account address to its contacts.
d)      Submit a contract for approval.

6.       An org has different Apex Classes that provide Account related functionality. After a new validation rule is added to the object, many of the test methods fail. What can be done to resolve the failures and reduce the number of code changes needed for future validation rules? Choose 2 answers
a)      Create a method that creates valid Account records, and call this method from within test methods.
b)      Create a method that loads valid Account records from a Static Resource, and call this method within test methods.
c)       Create a method that performs a callout for a valid Account record, and call this method from within test methods.
d)      Create a method that queries for valid Account records, and call this method from within test methods.

7.       Which component is available to deploy using Metadata API? Choose 2 answers
a)      Case Layout
b)      Account Layout
c)       Case Feed Layout
d)      Console Layout

8.       In the code below, what type does Boolean inherit from? Boolean b= true;
a)      Enum
b)      Object
c)       String
d)      Class

9.       What is the preferred way to reference web content such as images, stylesheets, JavaScript, and other libraries that is used in Visualforce pages?
a)      By accessing the content from Chatter Files.
b)      By uploading the content in the Documents tab.
c)       By accessing the content from a third party CON.
d)      By uploading the content as a Static Resource.

10.   A company has a custom object named Warehouse. Each Warehouse record has a distinct record owner, and is related to a parent Account in Salesforce. Which kind of relationship would a developer use to relate the Account to the Warehouse?
a)      One to Many Many
b)      Lookup
c)       Master Detail
d)      Parent –Child

11.   A developer creates a Workflow Rule declaratively that updates a field on an object. An Apex update trigger exists for the object. What happens when a user updates a record?
a)      No changes are made to the data.
b)      Both the Apex Trigger and Workflow Rule are fired only once.
c)       The Workflow Rule is fired more than once.
d)      The Apex Trigger is fired more than once.

12.   What is true of a partial sandbox that Is not true of a full sandbox? Choose 2 answers
a)      More frequent refreshes.
b)      Only includes necessary metadata.
c)       Use of change sets.
d)      Limited to 5 GB of data.



13.   In which order does Salesforce execute events upon saving a record?
a)      Before Triggers; Validation Rules; After Triggers; Assignment Rules; Workflow Rules; Commit
b)       Validation Rules; Before Triggers; After Triggers; Workflow Rules; Assignment Rules; Commit
c)        Before Triggers; Validation Rules; After Triggers; Workflow Rules; Assignment Rules; Commit
d)       Validation Rules; Before Triggers; After Triggers; Assignment Rules; Workflow Rules; Commit


14.   When loading data into an organization, what can a developer do to match records to update existing records? Choose 2 answers
a)      Match an external Id Text field to a column in the imported file.
b)      Match the Id field to a column in the imported file.
c)       Match the Name field to a column in the imported file.
d)      Match an auto generated Number field to a column in the imported file.


15.   In an organization that has enabled multiple currencies, a developer needs to aggregate the sum of the Estimated_Value_c currency field from the CampaignMember object using a roll up summary field called Total_Estimated_Value_c on Campaign.How is the currency of the Total_Estimated_Value c roll up summary field determined?
a)      The values in Campaignmember.Estimated_Value_c are converted into the currency of the Campaign record, and the sum Is displayed using the currency on the Campaign record.
b)      The values in CampaignMember.Estimated_Value c are converted into the currency on the majority of the CampaignMember records and the sum Is displayed using that currency.
c)       The values in campaignmember.Estimated_Value_c are summed up and the resulting Total_Estimated_Value C field is displayed as a numeric field on the Campaign record.
d)      The values In CampaignMember_EstImated_Value_c are converted into the currency of the current user, and the sum is displayed using the currency on the Campaign record.

16.   A candidate may apply to multiple jobs at the company Universal Containers by submitting a single application per job posting, that application cannot be modified to be resubmitted to a different job posting. What can the administrator do to associate an application with each job posting in the Schema for the organization?
a)      Create a lookup relationship on both objects to a junction object called Job Posting Applications.
b)      Create a master detail relationship in the Job Postings custom object to the Applications custom object.
c)       Create a master detail relationship in the Application custom object to the Job Postings custom object.
d)      Create a lookup relationship in the Applications custom object to the Job Postings custom object.

17.   What is a characteristic of the Lightning Component Framework Choose 2 answers
a)      It has an event driven architecture.
b)      It works with existing Visualforce pages.
c)       It includes responsive components.
d)      It uses XML as its data format.

18.   What is a capability of cross object formula fields? Choose 3 answers
a)      Formula fields can reference fields from master detail or lookup parent relationships.
b)      Formula fields can expose data the user does not have access to in a record.
c)       Formula fields can be used in three roll up summaries per object.
d)      Formula fields can reference fields in a collect of records from a child.
e)      Formula fields can reference fields from objects that are up to 10 relationships away.

19.   A developer has a block of code that omits any statements that indicate whether the code block should execute with or without sharing. What will automatically obey the organization wide defaults and sharing settings for the user who executes the code in the Salesforce organization?
a)      Apex Triggers
b)      HTTP Callouts
c)       Apex Controllers
d)      Anonymous Blocks


20.   A developer created an Apex trigger using the Developer Console and now wants to debug code. How can the developer accomplish this in the Developer Console?
a)      Select the Override Log Triggers checkbox for the trigger.
b)      Add the user name in the Log Inspector.
c)       Open the Progress tab in the Developer Console:
d)      Open the logs tab in the Developer Console.

21.   Which data structure is returned to a developer when performing a SOSL search?
a)      A list of lists of sObjects.
b)      A map of sObject types to a list of sObjects
c)       A map of sObject types to a list oflists of sobjects
d)      A list of sObjects.

22.   Which code block returns the ListView of an Account object using the following debug  statement?system. debug (controller. getListViewOptions ( ) ) ;
a)      ApexPages.StandardSetController controller = new ApexPages.StandardSetController([SELECT Id FROM Account LIMIT 1]);
b)      ApexPages.StandardController controller = newApexPages.StandardController(Database.getQueryLocator('select Id from Account Limit ');
c)       ApexPages.StandardController controller = newApexPages StandardController ( [SELECT Id FROM Account LIMIT 1));
d)      ApexPages.StandardSetController controller = new ApexPages.StandardSetController(Database.getQueryLocator('select Id from Account Limit 1');

23.   How can a developer avoid exceeding governor limits when using an Apex Trigger? choose 2  answers
a)      By using a helper class that can be invoked from multiple triggers.
b)      By using the Database class to handle DML transactions.
c)       By using Maps to hold data from query results.
d)      By performing DML transactions on lists of SObjects.


24.   What is a correct pattern to follow when programming in Apex on a Multitenant platform?
a)      Apex code is created in a separate environment from schema to reduce deployment errors.
b)      DML is performed on one record at a time to avoid possible data concurrency issues.
c)       Queries select the fewest fields and records possible to avoid exceeding governor limits.
d)      Apex classes use the ''with sharing" keyword to prevent access from other server tenants.

25.   What should a developer working in a sandbox use to exercise a new test Class before the developer deploys that test production? Choose 2 answers
a)      The REST API and ApexTestRun method.
b)      The Apex Test Execution page in Salesforce Setup.
c)       The Test menu in the Developer Console.
d)      The Run Tests page in Salesforce Setup.


26.   A company that uses a Custom object to track candidates would like to send candidate information automatically to a third party human resource system when a candidate is hired. What can a   developer do to accomplish this task?
a)      Create an escalation rule to the hiring manager.
b)      Create an auto response rule to the candidate.
c)       Create a Process Builder with an outbound message action.
d)      Create a workflow rule with an outbound message action.

27.   What is the accurate statement about with sharing keyword?choose 2 answers
a)      Inner class do not inherit the sharing setting from the container class
b)      Both inner and outer class can be declared as with sharing
c)       Either inner class or outer classes can be declared as with sharing but not both
d)      Inner class inherit the sharing setting from the container class

28.   How can a developer refer to, or instantiate, a PageReference in Apex? Choose 2 answers
a)      By using a PageReference with a partial or full URL.
b)      By using the Page object and a Visualforce page name.
c)       By using the ApexPages.Page() method with a Visualforce page name.
d)      By using the PageReference.Page() method with a partial or full URL.

29.   Which standard field needs to be populated when a developer inserts new Contact records programmatically?
a)      Accountld
b)      Name
c)       LastName
d)      FirstName

30.   What is the minimum log level needed to see user generated debug statements?
a)      DEBUG
b)      FINE
c)       INFO
d)      WARN

31.   A developer creates a new Visualforce page and Apex extension, and writes test classes that exercise 95% coverage of the new Apex extension. Change set deployment to production fails with the test coverage warning: "Average test coverage across all Apex classes and triggers is 74%, at least 75% test coverage is required." What can the developer do to successfully deploy the new visualforce page and extension?
a)      Create test classes to exercise the Visualforce page markup.
b)      Select "Disable Parallel Apex Testing" to run all the tests.
c)       Add test methods to existing test classes from previous deployments.
d)      Select "Fast Deployment'' to bypass running all the tests.

32.   Developer needs to automatically populate the ReportsTo field in a Contact record based on the values of the related Account and Department fields in the Contact record. Which type of trigger could the developer create? Choose 2 answers
a)      before update
b)      after insert
c)       before insert
d)      after update

33.   Individual part can be used in different types of engines. What data model should be used to track  the data and to prevent orphan records
a)      Create a junction object to relate many engines to many parts though a master detail relationship.
b)      Create a master detail relationship to represent the one to many model of engines to parts
c)       Create a lookup relationship to represent how each part relates to the parent engine object.
d)      Create a junction object to relate many engines to many parts through a lookup relationship.

34.   To which primitive data type in Apex is a currency field automatically assigned?
a)      Integer
b)      Decimal
c)       Double
d)      currency

35.   Which resource can be included in a Lightning Component bundle? Choose 2 answers
a)      Apex class
b)      Adobe Flash
c)       Javascript
d)      Documentation

36.   A custom exception "RecordNotFoundException" is defined by the following code of block? public class RecordNotFoundException extends Exception()which statement can a developer use to throw an exception? choose 2 answers
a)      throw new RecordNotFoundException("problem occurred");
b)      throw new RecordNotFoundException();
c)       throw RecordNotFoundException("problem occured");
d)      throw RecordNotFoundException();

37.   When creating unit tests in Apex, which statement is accurate?
a)      Unit tests with multiple methods result in ail methods failing every time one method fails.
b)      Increased test coverage requires large test classes with many lines of code in one method.
c)       Triggers do not require any unit tests in order to deploy them from sandbox to production.
d)      System Assert statements that do not Increase code coverage contribute important feedback in unit tests

38.   Consider this is the apex class,

public class MyController{
    public String myString;
   
    public String getMyString() {
        return 'getMyString';
    }
   
    public String getStringMethod1(){
        return myString;
    }
   
    public String getStringMethod2(){
       if (myString ==null)
               myString='method2';
       return myString;
    }
}

{!mystring}, {!stringmethod1}, {!stringmethod2},{!Mystring}



a)      getMyString,
b)      Method2,
c)       Method2, getMyString
d)      getMyString„Method2, getMyString


39.   What is a valid Apex statement?
a)      Map conMap = (SELECT Name FROM Contact);
b)      Account[] acctList = new List
c)       Integer w, x, y = 123, z = 'abc';
d)      private static constant Double rate = 775;

40.   A developer has a single custom controller class that works with a Visualforce Wizard to support creating and editing multiple sObjects. The wizard accepts data from user inputs across multiple Visualforce pages and from a parameter on the initial URL. Which statement is unnecessary inside the unit test for the custom controller?
a)      Public ExtendedController(ApexPages.StandardController cntrl) { };
b)      ApexPages.currentPage().getParameters() put(input', 'TestValue);
c)       Test.setCurrentPage(pageRef);
d)      String nextPage = controller.save().getUrl();


41.   A developer wants to display all of the available record types for a Case object. The developer also wants to display the picklist values for the Case.Status field. The Case object and the Case Status field are on a custom visualforce pageWhich action can the developer perform to get the record types and picklist values in the controller? Choose 2 answers
a)      Use Schema.PIcklistEntry returned by Case Status getDescribe().getPicklistValues().
b)      Use Schema.RecordTypeinfo returned by Case.SObjectTypegetDescribe().getRecordTypelnfos()
c)       Use SOQL to query Case records in the org to get all the RecordType values available for Case.
d)      Use SOQL to query Case records in the org to get all value for the Status picklist field

42.   An Sobject named Application_c has a lookup relationsnip to another sOblect named Position c. Both Application _c and Position _c have a picklist field named Status c.When the Status _c field on Position c is updated, the Status _c field on Application _c needs to be populated automatically with the same value, and execute a workflow rule on Application_c.How can a developer accomplish  this?
a)      By changing Application c.Status c into a roll up summary field.
b)      By changing Application c.Status c Into a formula field.
c)       By using an Apex trigger with a DML operation.
d)      By configuring a cross object field update with a workflow.

43.   A developer wrote a workflow email alert on case creation so that an email is sent to the case owner manager when a case is created? When will the email be sent?
a)      Before Trigger execution
b)      After Committing to database.
c)       Before Committing to database
d)      After Trigger execution.

44.   Which code represents the Controller in MVC architecture on the Force.com platform? Choose 2 answers
a)      javaScript that is used to make a menu item display itself.
b)      StandardController system methods that are referenced by Visualforce.
c)       Custom Apex and JavaScript code that is used to manipulate data.
d)      A static resource that contains CSS and images.

45.   A developer needs to provide a Visualforce page that lets users enter Product specific details during a Sales cycle. How can this be accomplished? Choose 2 answers provide Product data entry.
a)      Download a Managed Package from the AppExchange that provides a custom Visualforce page to modify.
b)      Create a new Visualforce page and an Apex controller to provide Product data entry.
c)       Copy the standard page and then make a Visualforce page for product data entry
d)      Download an Unmanaged Package from the AppExchange that provides a custom Visualforce page to modify.

Simple Binary Tree Program

Simple Binary Tree: In this blog we will see, how to create a simple binary tree. We will be using Queue  data structure to store the las...