Assignment Statements – Exercises
Quiz Summary
0 of 10 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 10 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
-
Unfortunately, your results in the simulator were not up to the desired standards. 😔
However, take advantage of your unlimited access and continue to practice.
Remember, persistence and dedication will lead to mastery. 😎 -
Congratulations! 🎉
You have successfully passed the simulator and are now one step closer to achieving your certification.
We hope you will consider joining us again in your future certification journey.Wishing you the best of luck with the upcoming exam. Keep up the great work! 💪
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- Current
- Review
- Answered
- Correct
- Incorrect
-
Question 1 of 10
1. Question
You are designing a basic inventory management system. Set up variables for the name of a product, the quantity of that product in stock, and a list to gather all product codes from the database.
Complete the assignment statements:
-
String productName;
Integer stockQuantity;
List productCodes;
= ‘Laptop’;
= 15;
= [SELECT Code FROM Product];
CorrectIncorrect -
-
Question 2 of 10
2. Question
You are creating a CRM for a startup. Begin by initializing variables for the name of a lead, their potential monthly revenue, and a list to gather all lead emails.
Complete the assignment statements:
-
String leadName;
Decimal potentialRevenue;
ListleadEmails;
= ‘Michael Scott’;
= 1500.50;
= new List();
CorrectIncorrect -
-
Question 3 of 10
3. Question
You need to create a string variable named
productNameand assign it the value “Laptop”. Additionally, create an integer variablestockCountand assign it the value 100. Finally, concatenate the productName with the string ” in stock: ” followed by the stockCount value to form a complete sentence.Store this concatenated string in a variable named
stockMessage.-
String productName = ;
Integer stockCount = ;
String stockMessage = ;
CorrectIncorrect -
-
Question 4 of 10
4. Question
You are tasked to declare an Integer variable named
totalSalesand assign it the value of 500. Additionally, you need to declare a double variable nameddiscountRateand assign it a value of 0.05. Then, calculate the discount amount by multiplying totalSales with discountRate and assign this value to a double variable nameddiscountAmount.-
Integer totalSales = ;
Double discountRate = ;
Double discountAmount = ;
CorrectIncorrect -
-
Question 5 of 10
5. Question
In a game application, you need to assign the initial score of the second player to 10 and update the level of the fourth player to 5.
Fill in the blanks to perform these tasks:
-
List players = [SELECT Score, Level FROM Player LIMIT 6];
players[ ].Score = ;
players[ ].Level = ;
CorrectIncorrect -
-
Question 6 of 10
6. Question
You have a list of
Employeerecords, and you need to update theTitleof the third employee to “Manager” and theDepartmentof the second employee to “HR”.Fill in the blanks to make the necessary updates:
-
List
empList = [SELECT Title, Department FROM Employee LIMIT 5];
empList[ ].Title = ;
empList[ ].Department = ;
CorrectIncorrect -
-
Question 7 of 10
7. Question
You have a list of
Contactrecords, and you want to update theLastNameof the second contact to “Smith” and theEmailof the fourth contact to “[email protected]“.Fill in the assignment statements:
-
List
contactsList = [SELECT LastName, Email FROM Contact LIMIT 5];
contactsList[ ].LastName = ;
contactsList[ ].Email = ;
CorrectIncorrect -
-
Question 8 of 10
8. Question
A manager in a sales company is setting up client meetings. Each client meeting is represented using the
ClientMeetingobject. After setting up the meeting details, the manager makes a copy for their assistant and adds it to a meetings list.Fill in the blanks:
-
ClientMeeting meeting = new ClientMeeting();
ClientMeeting assistantCopy;
List<ClientMeeting> meetingsList = new List<ClientMeeting>{};
meeting.Subject = ‘Product Discussion’;
= meeting;
.add(meeting);System.assertEquals(assistantCopy.Subject, ‘Product Discussion’);
System.assertEquals(meetingsList[0].Subject, ‘Product Discussion’);
CorrectIncorrect -
-
Question 9 of 10
9. Question
As part of an initiative to mark certain clients as VIP, you need to set the
Descriptionfield of the firstAccountin an array to the value'Very Important Client'.Complete the following Apex snippet to achieve this:
-
Account[] clientList = new Account[]{new Account()};
;
System.assert(clientList[0].Description == ‘Very Important Client’);
CorrectIncorrect -
-
Question 10 of 10
10. Question
In a new project, you are building a platform to keep track of a hospital’s patient records. You first populate a list with a single patient’s record. For backup and disaster recovery reasons, you decide to keep a reference of this patient list in another list.
After setting the diagnosis for the patient in the initial list, you intend to ascertain that this update is also available in the backup list.
-
Patient[] primaryRecord = new Patient[]{new Patient()};
Patient[] backupRecord = ;
primaryRecord[0].Diagnosis = ‘Flu’;
// Verify if the ‘backupRecord’ displays the updated diagnosis.
System.assertEquals(backupRecord[0].Diagnosis, ‘Flu’);
CorrectIncorrect -