Use VCE Exam Simulator to open VCE files
Get 100% Latest Salesforce Developer Practice Tests Questions, Accurate & Verified Answers!
30 Days Free Updates, Instant Download!
CRT-450 Premium Bundle
Download Free Salesforce Developer Exam Questions in VCE Format
File Name | Size | Download | Votes | |
---|---|---|---|---|
File Name salesforce.test-king.crt-450.v2024-10-17.by.jude.160q.vce |
Size 1.78 MB |
Download 67 |
Votes 1 |
|
File Name salesforce.braindumps.crt-450.v2021-09-01.by.holly.137q.vce |
Size 1.04 MB |
Download 1199 |
Votes 1 |
|
File Name salesforce.certkiller.crt-450.v2021-04-30.by.michael.137q.vce |
Size 1.04 MB |
Download 1323 |
Votes 2 |
Salesforce Developer Certification Practice Test Questions, Salesforce Developer Exam Dumps
ExamSnap provides Salesforce Developer Certification Practice Test Questions and Answers, Video Training Course, Study Guide and 100% Latest Exam Dumps to help you Pass. The Salesforce Developer Certification Exam Dumps & Practice Test Questions in the VCE format are verified by IT Trainers who have more than 15 year experience in their field. Additional materials include study guide and video training course designed by the ExamSnap experts. So if you want trusted Salesforce Developer Exam Dumps & Practice Test Questions, then you have come to the right place Read More.
In this lecture, we'll talk about the Apex datatypes that can be used by the Apex variables. This is a two-part lecture. Part one will have the String Data Types, integer and long, decimal and double dates, date time, end time, Boolean IDs, and object objects. And part two will have the collection data types, which are the list, the set, and the map. Let's start with the primitive data type. Let's start with the String Data type. The string is used to hold any character. It can be a letter, it can be an integer, it can be any kind of character. It is declared with a single quote, not with double quotes.
And it uses escape sequences to denote special characters like one quote, like double quote, like for a new line and so on. Apex strings support using the comparison operators like equal, like not equal, like less than, and so on. And this is an example of a String Data type variable. The string data type is used in many salesforce fields. It is used in the text and pick list fields, the auto number, the email, and the phone fields. And it has many methods. To check these methods, I will go to the Apex Developer Guide and from there I will open the reference section, and then I will go to the system namespace, from which I can choose the String class. There you can find all the methods supported by the String class. And then you can click on any of these to see an example. So let's say I will click on that. You can see the return type of this method and you can also see an example. The second data type is the Integer. An integer is used to hold a number without any decimal places. It is 32 bits and has a minimum value and a maximum value. This is an example. And this data type is used in many salesforce fields. It is used in any number field without any decimal places and it has these methods. And again, to check the methods, I will go to the Developer Guide and I will go to the Integer class.
So it has these three methods. Next, we'll talk about Long. Long is exactly the same as an integer, but it is 64 bit, which means that the minimum and maximum values are bigger. It is used when you need a wider range than Integer. This is an example of a long And Long is used in any field with a wider range than Integer. And finally, it also has methods that you can check in the Salesforce Apex Developer Guide. Then we'll talk about decimals. A decimal is used to hold a number with one or more decimal places. It is of 32 bits, which means that it has a minimum and a maximum. This is an example of a decimal declaration. Notice the decimal places, the field type, or any number of fields that have one or more decimal places. And one important thing to know is that the concurrency fields are automatically assigned the type decimal. Decimal has many methods. You can go and check these in the Apex Developer Guide. Now let's talk about doubling. Double is exactly the same as decimal, but it is of 64 bits, which means that the range that it can hold is much bigger than the range of decimal. This is an example of a double declaration and it is used in any Salesforce field that uses a number with more than one decimal place but with a wider range than decimal. It also has some methods. You can go and check these in the Apex Developer Guide. Now let me go to Salesforce and let me show you some declarations of these data types.
So this is Salesforce. I will open the Developer Console and then I will open the Execute Anonymous window by using Control and E. So let us declare and then let us do the same for Integer longhand let us test these declarations by using the debug command. So first I will test this and then this one, then my long, my decimal and finally my double. One thing I want to make sure is aligned. Okay, so now it looks much better. So let me try now to execute this code. So this code basically declares five variables. One string, one integer, one long, one seven, and one doubled. And then it will output them in the debug log. So let me click on Execute and make sure that you have the Open Log checked to check only the debug statement. Check this box and see what we have. We have the first string and then we have an integer. And then we have a long, and then we have a decimal, and then we have a double. So let me go back to the slides. The next data type is the date data type. The Date Data Type variable holds a value that indicates a particular day. It does not hold any information about time. Date values must always be created using the Assistant Static method. You can also add or subtract an integer value from a date, which will return a date value. These are examples of date variable declaration. Notice the use of the system method. And the Date Data type is used in any date field without time, just like the closed date field. Finally, there are many methods that you can use with the date data types. You can check these out in the Apex Developer Guide. Now we'll talk about the date and time.
The Date Time data type will return a value that indicates a particular day plus the time. Just like the Date data type, the Date time values must always be created using a system static method. You can also add and subtract integers or doubles from a date time value. returning a date time value. These are examples of data declaration. And the data type is used in any date time feed in Salesforce, just like the created date. And finally, there are many methods that can be used with the date/time data type. You can check these and the Developer Guide. Now we'll talk about the time data type. This is mainly a value that indicates a particular time without any date.
It also should be created with a system static method. This is an example of a time declaration using a system static method. There are no salesforce fields that use the time data type, but you can always use this data type in your Apex code. And finally, the time data type has many methods. You can check these out in the Apex Developer Guide. Next, we'll talk about Booleans. A Boolean can only be true or false. This is an example of a Boolean data type variable. It is used in the checkbox field in Salesforce. And there are two methods that can be used with this type of data type. You can find this in the Apex Developer Guide. Now let's go to Salesforce again and let me show you these data types. So let's go back to salesforce. Let us create some more variables. This time, we'll create some date, date time, and time variables. How can we create a date variable? As we have mentioned, we have to use a system method to do that. Let's go to the Developer Guide.
And let's go to the dating class. This is also inside the system namespace inside the appendix. So if I click on the Date class, I can see that it has many methods that I can use with the date. So to create a date, I use a method called a new instance. Let me click on this. This is an example. So I will copy this and I will paste it here. So this will do what? This will create a date variable called my Date One. And this date will be this date. Let us now create a daytime variable. To do that, we will use the daytime class and will use a method to construct a new date-time variable. So in this case, we will use the new instance. And this, you have to give it a year. So let's say 186, then a month, and then a day. And it will construct a daytime using the midnight time. And then we will create a new time variable also using the methods of the time class. To do that, we will use the new instance method. And we will specify the hour, the minute, the second, and the millisecond. So let's specify. Let's say twelve and then twelve. So now we have created three variables. One for the date, a variable, one for the date time, and one for the time. Let's do a Boolean. To do that, we'll simply use True without quotes or False. So now we have created these five variables. Let us test them. To do that, I will use the systems debugger and I will highlight the code that I want to execute. And then I will click on "Execute highlighted." So what will happen now? I will get the output of the code that I just executed. So this is the first variable. The second, the third, the fourth, and the fifth The next data type we'll talk about is the ID data type. This is an 18 character force.com record. Salesforce identifier Each record has a unique ID. And this unique ID is made of 18 characters. So let me go back to Salesforce and let me show you a record. If I open any record and any object in Salesforce, you will notice in the URL, I have this strange string. This is, in fact, the ID of this record.
The ID field is a base 62 encoded string. Each character can be one of 62 possible values. It can be either 26 lowercase letters or 26 uppercase letters and ten digits. So, 26 plus 26 plus ten equals 62. It is declared with a single quote, just like a string. And if you set the ID to a 15-character, Apex will convert this to an 18 character. This is an example. Of course, this is just an example. You cannot do that. You cannot declare an ID and give it to a record in Salesforce. Salesforce will automatically assign IDs. So this is just an example.
However, in Apex, we are unable to do so. And the fields that use this data type are the ID field, the Lookup and the Master Detail field as era for us. And finally, this data type also has some methods. You can go to the Developer Guide and you can check them out. Now we'll talk about the S object data type. There are two different kinds of S object data types. First, there is the specific S object. This refers to any object that can be stored on the force.com platform. And it represents a row of data. And it can only be declared in Apex using the Soap API name of the object. It can be a standard object or a custom object record. So, basically, this is any record of any of your Salesforce objects. So it's an account record.
It's like a book record. Each one of these records is an S object. This is an example. I declared an account account equal to a new account. And then I declared a book, underscore, underscore C. Book one equals a new book underlined in C. So in these examples, I am declaring S objects. I am declaring a new record of type account. And I'm also declaring a new record for type books. Then there's the generic S object. This is exactly the same as the specific one. But instead of declaring the variable using the specific object name, I declare it using subject and then I can cast it. So in this example, I'm creating a subject called s of type account and then casting this to make it an account. After casting it, I can assign the fields of this variable.
And finally, we have the object data type. This is the parent of all Apex data types, just as it is the parent of primitive data types like integer, string, and Boolean. Also, as the parent of any specific or generic object data type, and since it's the parent of any user-defined custom class data type, you can cast an object that represents a more specific data type to its underlying data type. So in this example, we did declare a variable called OBJ of type object and we did assign the value of ten. After that, we can cast this variable and we can make it an integer. So this is the primitive and the object data types. We did talk about the primitive datatypes; about the string, the integer, the date, the date time, and the Boolean. We also talked about the s object, which is a generic and specific one. And finally, we did talk about the object data type, which is the parent of each and every data type. Part two of this will mainly focus on the collections. We have three types of collections. We have the list, the set, and the map. Thank you.
In the first lecture, we talked about these data types. In this lecture we'll talk about the collection data types: about the list, about the set, and about the map. What is a collection data type? A collection data type is used to hold more than one element at a time. In the first part, we have seen data types that hold only one element. So let's say we have declared an integer variable and this variable holds only one element, i.e., one integer. Using the collection, this is not the case. Each of these collection data types can hold more than one element at a time. Let's start with the list. A list is an ordered collection of non-unique elements. The keywords here are both ordered and non-unique.
So the list holds ordered elements that are non unique. You can remember that the word on the list is ordered and N is no unique. The index is an integer and it starts with zero. Lists are equivalent to arrays in Java. Lists are equivalent to arrays in Java. And the element of LS can be of any data type. They can be of the primitive type Subjects, user-defined types, or built-in Apex types. A list can also contain any collection. It can contain a list, it can contain a set, and it can contain a map. In this case, we'll call this a nested list. So this is how we create a list. There are many ways to create a list. On the left hand side, we have to declare the data type, which is, in this case, list. And then we have to define what elements this list will hold. And then we'll type the variable name, and then we'll use the keyword new. So let me go back to the Apex Developer Guide.
So if I go to the Apex Developer Guide and then I go to the Apex class under the system namespace, I can see that there are many ways that I can use to create a list. Let me click on the first way. So this is an example of a list integer. And then I specify the variable name. And then I use the keyword new list of integers. So this will create an empty list. I can also create a list and I can also add the element in this line. To do that, I can use this example, the second line. So in the second line, I created a list and I added three integers to this list. I can also use the array annotations when using lists. The array is used in Java and you can use the same annotation in Apex. As you can see on the first line, I'm creating a list of strings and this list is called colors. I can use the array annotations to create the same list. So, as you can see in lines two, three, and four, I'm using the array annotation on the left most the array annotation. And then after that, I'm using the rightmost array annotation. And finally, I'm using both sides of the array annotation. There are many methods that I can use with this list. I can add elements to a list. I can get an element by providing an index. I can set an element on an index. I can clear a list. I can check if a list is empty. I can check the size of the list to know all these methods. Let me go to the developer guide and let me open the list class. And then I will click on the list of methods. Here I can see all the methods in the list and then I can click on any one of these to know exactly the signature and the return type of the method. And to see an example of this method, The most commonly used methods are the ones on this page.
So you have to master these. This is an example of a list. Let me use this example in my live environment. I will copy it, and then I will open my developer console. So what I'm doing here is step one. I'm declaring a list of strings. This list is called the STR list. Then I'm adding three elements to this list using the method add. So on the left, I will provide the variable name, the list and then I will use the methods to add. And then I will specify the string. I'm repeating this three times, and then I'm adding another element called element one. This is a string element. Why am I doing this? I'm doing this to check if this will be accepted or not. As you can see, this element already exists in the list. And then I'm checking the size of the list. What will happen, as I predicted, because the list allows duplicate elements? So let me execute this. As you can see, the size equals four. The second collection data type we want to talk about is the set, which is an unordered collection of unique elements. The keywords here are unique and unordered and unique. So a set will hold elements that are not ordered. There is no index here, and the elements should be unique. If I add an element that already exists in the set, this element will not be added. These are equivalent to bags. A set can hold any data type. They can hold any primitive type, any S object type, any user defined type, and any built-in and apex type. They can also contain other collections.
So, just like the list, sets can also contain other collections. In this case, they will be called nested. So the difference between lists and sets Lists are collections of non-unique elements that are ordered. So you need to remember the keyword on. But sets hold an unordered collection of unique elements. So you need to remember the keyword "you" and "you." So this is the distinction between ordered for a list and unordered for a set, with lists being non-unique but sets being unique. This is how you create a set. Again, let me go to the developer guide and let me go to the set class. So this is the set class. As you can see, these are the constructors that can be used to build a set. I can specify the first function Object() { [native code] } and then I can specify a set and the second constructor. So, in this case, the new set will be a copy of this set argument. And I can also provide a list as an argument to the set constructor.
So, in this case, the new set will be a copy of the list without the duplicate element and without the index. There are many methods that can be used with sets. These are the most used methods. We can add an element to asset. We can remove an element. Notice here that there is no index. This is unlike the list. We can also clear a set. We can check if a set is empty and we can check the size of a set. This is an example. Let me copy this example and let me show it to you in Salesforce. So what I will do now is simply paste this so the first line will construct a new set. The set name is SCR Set. And as you can see, I'm declaring this as a set of strings. And then I'm adding three elements to this set. The first three elements are Paris, London, and New York. After that, I'm adding another element called Paris. Notice that this element already exists in the set. So, if I add an element to the set again and it already exists, it will not be added. So if I check the size of the set after adding this element, it will be three. To check the size, I will use the method that works. So it will be the set name, that size. And this will return an integer.
And then I can print it out on the debug the size. So let me now execute these lines and you will see that the size equals three. And then you can see these two lines. These are mainly the last two lines. I checked to see if the set contained this element and then removed it using the remove method. And then I did check again, and the return of this was false. So the first return is true because this set indeed contains the element in New York. But again, after removing this element and checking again using the method contained, I have a false because this set does not contain this element anymore. Finally, we talk about maps. Maps hold a collection of unique key-value pairs where each key is unique and maps to a non-unique value. To understand maps, you need to divide a map into two different things. First we have the keys and then we have the values back on the list. We have keys, but the keys cannot be controlled by you. The keys are mainly integers, starting with zero. So we have key zero, key one, key two This is the same thing, but in this case, in the case of maps, we can control the keys. We can specify what the keys are. The keys can be of integer data type, they can be of any other data type, and they link to a value. Each key will be linked to a value.
The keys are equivalent to a set, which means that they are not ordered and they are unique. The values are equivalent to a list, which means that they are ordered and they are non-unique. Maps can also contain any collection, just like the lists and the sets, and in this case, they are nested. So this is how you create a map. Notice that when creating a map, we can specify the key data type and the value data type. So in this case, on the first line we have math and then we have Integer and String, which means that this math will hold the key as an integer but the value will be strings. So let me go to the developer guide and let's go to the map class and the map class. We can see that there are many constructors that can be used when building a map. We can specify the first function Object() { [native code] } and then we can also specify a map as an argument, so in this case, this map will be copied to the new map. Then we can also specify a list. This is an example of a map declaration. In this case, this map variable will be called money and the key will be of type integer. The value will be of type String. So back to the slides. We can also add the values when we declare the map itself, so notice in line number two we are declaring a new map called "my map Two" and then we are using on the rightmost side of the new map. After that, we are giving the argument as the keys and the values.
Maps also have many methods. For example, we have the put method, which will specify ankey and a value, and you can see the example on the right side. We can also have the get method. This is unlike the set because the set does not have a key, but a map and a list do have a key, so in this case I can use the get method and maps I can also use the remove method, the clear that is empty in size and the key set. The key set will return a set of all the keys of this map, and this is an example. Let me copy this example to my salesforce.org and let me show you how to create a map. So what we are doing here in the first line is declaring a new map called String Map. This has keys of type string and also values of type string. After that, we are using the Put method to put keys and values into the map. So in this case, the left-most argument will be the key and the right-most argument will be the value. Notice that both of them are of type string. They can be of any type. This is linked to the declaration that we have made in the first line.
We added three key value pairs, and after that, we used the method Get to get the value of the key knowledge. So this will return to me, Dark Knight. And finally, we did use the method contains key to check if this map indeed contains the key John. So, in this case, this map does not contain this key. So this will return "false." Let me execute these lines. So, clicking on the execute anonymous, we can see that the output of the code is Dark Knight and False. Why that? because I used the Get method to get the value of the Keynote. And then I did check if the map contained the key down. So in this case, this will return to Me dark Night and this will return to me as false. And finally, in this lecture you have learned about the different Apex data types. In the first part of this lecture, you learned about the primitive data types: the object, the S object, the date, the date and time, and the time. And then in part two, you will learn about the collection data types. This is very important to know because it will be used later on in Apex. You now understand the list, datatype, set, and map. The list holds an ordered collection of non-unique elements. The set holds an unordered collection of unique elements. And finally, the map is a combination of set and list. The set is the key, and the list is the value. And finally, as usual, thanks for watching.
In this lecture, we will talk about the different statements that Apex uses to control the flow of a program. In a program, the statements are executed line-by-line in the order of their appearance. So if you have a number of lines of code, these lines are executed one after the other. Apex provides statements that control the flow of the code execution. This is called the control flow statements. With these control flow statements, you can first of all cause Apex code to execute based on a certain condition. And secondly, you can also have a block of code executed repeatedly. This chapter describes these control flow statements. First of all, we'll talk about the Statement, the false statement, and the false statement. And finally, we'll talk about loops. We have more than one type of loop. We have the full loops, the do why loop, and the while loop. And finally, we'll talk about Bray and the continued statements. First, let us start with the if statement. The if statement is the most basic of all the control statements. And if a statement consists of a Boolean expression that is followed by one or more statements, If the Boolean condition is true, then the statement is executed.
So this is the format we have. First of all, the keyword if. After that, between parentheses, we have the Boolean condition. If this Boolean condition is true, then the statements between the curly brackets will execute. This is an example of an if statement. We have first of all declared an integer, and then we have an if statement with a Boolean condition. This bullying condition is based on the integer that we have just declared. If this bullying condition is true, then the statement between the curly brackets will be executed. So, in this case, F grade is greater than or equal to 60 and will have a system debug statement. Then we have the FS statement. The FS statement will be added to the F statement. It will use the basic if statement. But on top of that, it will add an ANLP statement at the end of the IF statement. The else statement is optional and it will execute only if the Boolean condition is not true. So if the bullying condition is true, then the if statement will not execute, but the if statement will execute. This is an example. We have the same example of the F statement. But at the end, you will notice that we have added anLemont. The else statement will only be executed if the Boolean expression and the F statement are not true. In this case, the grade is 75.
If the grade is greater than or equal to 60, the F statement is executed. So in this case, the fitment will not be executed because the grade is indeed more than 60. Finally, we have the alphatement. This is the most complex of the if console statements. It will never create more than one statement. The second if statement onward is stated as else if. The final optional statement is an if statement. So this is the format of an if else if elseatement. Notice that it's the same as an if else statement. But we have added an if-else in the middle. This is an example. We have an integer called the grade. And then we have an if statement. And at the end, we have another statement. In the middle, we have else if statements. So first of all, the first Boolean statement will be evaluated as graded greater than or equal to 90. If this is the case, then the F statement will be executed, and we will go out of the F statement. If not, we'll jump to the second if statement, where we will evaluate the Boolean and so on. And finally, if none of these false if statements ever come to true, we will execute the final F statement. So in this example, the grade is 75.
The first F will not be true, the second will not be true, but the third will be true. So in this case, the programmer will execute the third statement, which is your grade SC, and it will exit the whole false statement. Now we'll talk about loops. Loops in general are used to execute a statement one or more times automatically. We'll first start with the while loop. The while loop executes a statement if the Boolean test returns true. And once the statement is executed, the Boolean condition is evaluated again. If it returns true, the statement will be executed again and so on. The execution will stop when the value of the condition becomes false. This is an example of a while loop. We first have an integer called count, and the value of this count is one. And then we have a while loop. The Boolean condition is that you count less than eleven. The statement is between the curly brackets. So I will have the system debug count now and then I will have the value of the count. So in this case, it will be one. After that, I have another statement, which is count plus plus. So in this case, the count will be two. So to count to two is less than eleven. So the while loop statement will execute again. So I'll have count 12345 in my debug log, followed by count equal to ten. And after the count is done, I will increase the count by one. So the count will be eleven. So, in this case, the count is not less than eleven. So this is when the while loop will stop. Now we talk about the duo loop. A DOI loop is just the same as a while loop. But a do while loop is guaranteed to execute at least once. Why that? Because the doyloop will check the Boolean condition at the bottom of the loop, not at the beginning. So we have the do keyword and then we have the statement.
So this statement will be executed at least once. And after this statement, we have the while keyword and the Boolean condition. So if this condition is not true, then Apex will exit this while statement and the statement will not be executed again. If the Boolean condition is true, then the statement will be executed again. And after that, the Boolean condition will be evaluated. This is an example of a do while loop. First we have an integer called count with a value of one. And then we have the do while statement. We have an expression inside the do, and then we have the while. And then we have the Boolean expression. So the expression inside the do will be executed at least once. After that, the Boolean expression will be evaluated.
If it returns through, the expression inside the do will be executed again. If not, Apex will exit the do all statement. Now, we've talked about the four loops. We have many kinds of four-loops in Apex. First, let's talk about the traditional for loop. A traditional for loop will have the syntax. We will specify the initial statement, the exit condition, and the increment statement, and the body of the for loop. And then we will specify the expression. This is an example of a traditional for loop. As you can see, the body of the loop has three different parts. Part one: this is the initializationstatement, which is integer I equals zero. And then we have the condition. This is the Boolean statement. And finally, we have the increment statement. Between the curly brackets, we have a phrase that we want to execute. So in this case, we are specifying a variable code integer and we are giving it a value equal to zero. And then we are specifying the Boolean statement, which is less than ten.
And after that, we specify the increment, which says increment I buy one. So in this example, the expression inside the loop will be executed exactly ten times. I equals zero the first time and nine the tenth time. When I reach a stand, the Boolean expression will be false, and therefore Apex will exit this loop. The second type of for loop is called the for Each loop This for each loop has this syntax. It can take a list or a set as an argument, and then it will make sure to execute each element of this list or of the set. Let me give you an example to make it clear. This is an example of the format for each group. First of all, we are declaring a list of integers called "My Interest," which has five different elements. And then we declare the winner for each group. Then, for each group, the data type of the list will be taken first. And then it will need a variable. It can be any variable that you want and then a semicolon. And after that, we will insert the name of the list. So this for each loop will make sure that it passes through each and every one of the elements of the list. So in this case, it will pass five different times. So the first time it will have an integer equal to one, and then two, then three, then four, and then five. So we are sure that this for each loop will pass through each one of the elements of the list once.
And finally, we have the SoCal for loop. The so-called for loop will iterate over all of the subject records that are returned by a so-called query. So, as we will see later, a so-called query can return a list of s objects. So if we give this so-called query as an argument in the column, we are making sure that the for loop will pass once on each of these elements. So, as an example, we have a list of accounts. This list will invoke so-called, and the so-called query will return the list that is called AWCs. Then I can give this list as an argument inside the for each loop. So in this case, we will make sure the for loop will pass on each one of the elements of the so-called query once. And finally, we'll talk about the break and the continuous statements. Let's start with the break statement. The break statement will terminate the loop and it will go out of the loop immediately when it appears it is available for the for loops, while loops, and dollops. Let me give you an example to understand the break statement. In this example, I have a for loop. The for loop has an integer equal to zero and a Boolean condition of I less than 100. I will increment by one on each iteration. So if I is ten, we will have the break statement. So in this case, whenever I reaches ten, it will not execute the rest of the statements inside the for loop; it will directly go out of the for loop. So in this case, this for loop will only show zero to nine. When it reaches ten, the apex will go out of this loop completely. So we will have nothing after nine. On the other hand, with the continued statement, we will only skip once. The continuous statement will skip the current iteration and go to the next one. Unlike the break statement, which exits the for loop, while loop, or dot loop completely, the continue statement will only skip once and then continue. This is an example. I have a list of integers and this list has five elements, and then inside the four loop I have a continuous statement, and this continuous statement will execute if x is three.
So in the case of x equals one, We will not reach this x-equal to the same. When x is three, this will be reached, and this will cause the apex to go out of the four loop and go to the next iteration, which is, in this case, four. So this will print out one, two, four, and five, and it will not print three. Finally, as a summary of this lecture, we talked about the different if statements. We have, first of all, the simple if statement, which is only if and a Boolean expression and a statement. And then we have the if else statement, which has an optional else at the end. And then we have if and else statements which have more than one if statement. If the Boolean expression is good for one of the statements, the next statement will not be executed. Only one if the statement is executed. And then we have talked about the loops. We have talked about the do why loop, the three-four loops, the traditional for loop, the for each loop, and the so-called for loop. Finally, we have talked about two statements that we can use in some of the loops. We have talked about the break statement, which will exit the entire loop. And we have talked about the continue statement, which will skip to the next iteration of the loop. And finally, as usual, thanks for watching.
This lecture will be divided into two separate parts. Let's start with the first part. In this lecture we'll talk about object-oriented programming concepts. What is a class and what is an object and object-oriented programming? What is a method? What is a variable? What is a static method and a static variable? And what's the difference between these and the regular ones? What is a function Object() { [native code] } and what is an access modifier? This will be in part 1 of the lecture. And then in the second part, we'll talk about the syntax and different components of an Apex class construction. We'll talk about the different keywords that we can use in constructing an Apex class.
We'll talk about the virtual class and the abstract class, how we can extend them, and how we can override their methods. And then finally, we'll talk about interfaces and how we can implement them. First, let's start with the object-oriented programming concept. Historically, a programmer is a set of procedures that take input data and then, using these procedures or these lines of code, process this data. The goal is to produce output data. So this is the main goal of a program. We have two different types of programming languages. First we have the standard and traditional procedural programming language. just like the C language. This is mainly built around the procedures that we want in our program. Starting the programmer by the main method, we build the different procedures or the different functions that we want to achieve in this program. And then we have the object-oriented program. This is mainly not built around the procedures. The procedures will come at the end, but they are built around the objects that you want to model in your program. So, first you have to model the different objects in your program. And after that, you have a main method where you can use these objects. So this is called a bottom-up approach versus the top-down approach of the procedural programming language.
Op, or object-oriented programming, consists of modelling real-world components into your program. These are code classes, and a classis responsible for achieving certain things. It has some methods. These methods will achieve certain things. And you don't need to know the details of these methods. You just need to call them and they will do their stuff. Now, what's a class? A class is a template or blueprint from which objects can be created. So you need to create objects by using a class. An object is an instance of a class. Let's say that you have a programme where you need to model a pen. So, in this case, you create a class called the Pen class. This is the blueprint that describes what a pen is and all the operations that can be done on a pen. So an instance of the Penclass is called the pen object. So, in other words, the Pen class is the blueprint that is used to build the pen object. A class may contain other classes. These are called the "inner classes." Inner classes may be nested only once in Apex. So this is not the same as Java or Java. We can nest more than one inner class. But in Apex, we can only go one level deep. And how can you call it an inner class? You can call it by using the statement below. We have built our class and we have built different objects from this class.
What an object can have. An object can have states and behaviors. These are things that an object knows about itself and things that an object can do. The state of a pen is mainly like what's the colour of the pen? What's the brand of the pen? These are the states and the behaviours of a pen. This is mainly what a pen can do. It can write, it can be refilled, and so on. So this is called object-oriented programming variables and methods. So the state is the variable and the behaviour is the method. A variable can be assigned to the class itself. In this case, it will be a static variable, meaning it can be assigned to the object itself. In this case, it will be a regular variable. So let's take an example. In the pen class, I can have a variable called pen count. As a result, this variable will not be assigned to a single object. It's not only for one of the pen objects, it's for the whole pen. So, in this case, this will be a staticvariable and it will be linked to the class itself and not to the object itself. And for variables, we don't use any parentheses. Now let's talk about the behaviour of an object, an op. The behaviour is called the method. A method can be called on the class itself,so in this case it will be called a staticmethod, or on the class instance, which is the object. So in this case, it will be the regular method. This is just like the variables.
A variable can be either an astatic variable or a regular variable. Methods always use parentheses when called for. This is not the same as variables. And a method can have one or more parameters inside the parentheses. So in this case, I can give some input to the method using these parameters. And finally, a method can either return some data from a specific data type or it can return void. So in this case, it will not return anything. Now let's dig deep into static variables. As we have mentioned, static variables are variables that belong to the class itself and not to objects of the class. They are used to store information that is shared across the instances of a class. They don't belong to one object; they belong to the whole class. Let me give you an example, just as we have mentioned. Like if you want to create a counter for the number of objects that you have created. This will not belong to the object itself,but it will belong to the class itself. Now let's talk about the static method. A static method can be called directly from the class and not from the objects of the class. In this way, you don't need to instantiate a class. You don't need to create an object to be able to call the static method. You will only call this method using the class itself. A static method cannot be called from a class instance. If you try to create an object and then try to call this static method using this object, you will get an error.
Now let's talk about constructors. Constructors are special methods that are used to instantiate a class. So these are used to build objects out of your class. So by default, whenever you create an Apexclass, a default function Object() { [native code] } is built in the background, and it does not have any parameters. But on top of that, you can build your own constructors. These will be called custom constructors, and they can have either some parameters or zero parameters. A custom function Object() { [native code] } should have the same name as the class. So the methods that are being used as constructors will have the same name as the class, and they will not have any return type, be it void or string or integer. You don't specify any return type in a constructor. And finally, a very important point. Whenever you add any custom function Object() { [native code] } to the Apex class, the default function Object() { [native code] } will be gone. To define a class in Apex,you need to follow this syntax. First of all, you need to specify the access modifier of the class. We'll see this in the next slide. And then you need to specify if this class is either virtual or abstract. This is an optional step, and we'll see this in part two of this lecture.
After that, you specify the share level of the class. We'll see this in a later lecture in this section. And then you type the keyword class. After the keyword class, you type the name of the class. And then, optionally, you specify if this class implements an interface or extends another class. Also, we see these two in the next part. Finally, you specify, between curly brackets, the class body. Now let's talk about the access modifiers for the class. First of all, we have the global access modifier. Using the global access modifier specifies that the class can be seen by allclasses in all namespaces everywhere. So it's not only in my.org, they can be seen in each and every.org that I share this class with. A global method can only be contained in a global class. I cannot specify a global method in an aclass that is not a global class. Why do we use global classes? We use globalclasses, batch Apex, inbound email services, web services, and scheduled Apex. And finally, an app exchange. So whenever you want to publish an application on the anapp exchange, you need to specify this access modifier and the classes that you use in this application. Second, we have the private access modifier. This is the default one if you don't specify anything. So let's say I don't specify any access modifier and I start building my class with the keyword class.
This will be taken as a private class. As a result, classes that use the private access modifier cannot be accessed by any other class, even within the same namespace or organization. These are used mainly in energy classes of a class or N test classes. Finally, we have the public access modifier. This is the most used access modifier. Classes that use the public access modifier can only be seen by other classes within the same application namespace. Or.org. This is the use case. It's used in anything that's not being used for private or for the global access modifier. So, if your situation does not necessitate the use of a private or global access modifier, you will employ the public access modifier. Now let me go to Salesforce and let me show you how to create a class. So we'll go to the developer console and then we'll use the file menu to create a new Apex class. The first step is to give the name of the class. So in this case, it will depend. So, giving this, you will have the access modifier and the class keyword and then the name of the class. First, let's create some variables. We'll create a string variable called "Pen brand." And then we'll create another variable called "Pen colour." We'll also create an integer called "pan price." Now let us create some methods. We'll create two methods if you want. So public void followed by the method name. right one. Then, as previously stated, the parentheses. This method will not return anything. It's a preventable return. So what will it do? It will simply post something to the debug log, and we'll create another method, publicvoid try, which will do the same. So what I did now is I created a class called Pen. I created three variables and two methods. Now let me save this CTRL s.
Now let me open the executeI'm window to run this class. To begin, I will use the built-in function Object() { [native code] } myPen = newPen to create objects from this class. So in this case, I am creating a newPen object called myPen using the built-in constructor. Step two, which I will call some method of this, So how to do that? I will first use the object and then I will use the dot notation to call the method. So what will happen? Now this object, My Pen, will call this method from within the Pen class. So if I click on the execute button, let's see what will happen. So this object created this on the debug log by calling the method. Now going back, I can do the same thing. Now let's try to call this method from the class itself, pen dot write, to what will happen now? execute I will have an error. Because I'm trying to call a method that is non-static using the class itself, how can I solve this? So I can make this method static, so in this case I can call this method from the class itself. Make sure to click oncontrol to save and then let's try to run this. This will give an error because I am trying to call a method that is static from an object. Let me get rid of this and let me try to execute it now.
As you can notice, this will succeed, so let me specify that this is a static method, and now let me create a static variable How to create a static variable I created a static integer, so it will be called pancount, and I need to specify the value when I created it. So now what will happen? I have a static method and an astatic variable. How can I use this? To use this I need to create a constructor, so to create a constructor, as we mentioned, we don't specify anything. So in this case, it will be public and then the class name and then it can take zero or more arguments, so in this case, I will not make it take any arguments and I will just specify that the time count should be increased by one So I created a function Object() { [native code] } that is not the default one and when I do that, the default one will be gone, so after creating this constructor, I will create a method that specifies the count of the pen count. This will be public voidpen account number and this will tell me how many pandas I have the system debug pan count, so what did I do? I created two methods, one function Object() { [native code] } and one method that returns void, but this method will use the static variable I will go back to the executor anonymous and I will create two pens. One equals ten, and I will do the same for ten, two, and then what I will do. I will call this method "so let's call So let's make thisstatic method and let me click on control s and let me call it. I call it using the class itself and not the object, so pen Countdown. So what should happen now?
I am creating two pens using my custom constructor, and when I call this custom function Object() { [native code] } I will increase the pen count variable by one, which is zero, so this is a static variable that is being used on the constructor, and then I'm calling this static method that will specify to me in the debug log the value of the card count. So this should be two. Now let me click on execute and let's see what will happen. So let me go to the D debug log and see. Now we have two. So as a conclusion, what we did,let me close the anonymous. First of all, we have specified a class name, Colton, that has three variables and one static variable. And then we have two methods that only post something to the debug log. Then what we did was construct a custom constructor. This function Object() { [native code] } will use this static integer,this static variable, to increase it. So it will use it and it will increase it. And finally, we have made an astatic method called "pen count." This will use the value of the pen count. So if I create 210 objects, my pen count will be two. And this will be reflected when I call this method. So that's it for part one. And in part two, we'll talk about the other keywords that we can use in creating a class, like the go to and the appliance class. We'll talk about the interface implementation and the external class name. And then in another lecture in this section, we'll talk about the sharing that we can do in classes. Thank you.
Study with ExamSnap to prepare for Salesforce Developer Practice Test Questions and Answers, Study Guide, and a comprehensive Video Training Course. Powered by the popular VCE format, Salesforce Developer Certification Exam Dumps compiled by the industry experts to make sure that you get verified answers. Our Product team ensures that our exams provide Salesforce Developer Practice Test Questions & Exam Dumps that are up-to-date.
Comments (5)
Please post your comments about Salesforce Developer Exams. Don't share your email address
Asking for Salesforce Developer braindumps or Salesforce Developer exam pdf files.
Salesforce Training Courses
Latest IT Certification News
LIMITED OFFER: GET 30% Discount
This is ONE TIME OFFER
A confirmation link will be sent to this email address to verify your login. *We value your privacy. We will not rent or sell your email address.
Download Free Demo of VCE Exam Simulator
Experience Avanset VCE Exam Simulator for yourself.
Simply submit your e-mail address below to get started with our interactive software demo of your free trial.
@peter, personally used the dumps provided here last month and the results were quite pleasing. id recommend that you too use dumps for salesforce developer certification in exam prepping. you wont be disappointed.
plz guyz... help me out!!! looking 2 sit 4 my exam in the coming month and cant decide if these dumps are valid or not... pleeease tell or lead me to valid salesforce developer certification sample questions….
if you are looking to get a buckload of information on the salesforce developer certification exam while familiarizing with the method in which the exams are set i would highly recommend these dumps. elaborate and easy to follow through. highly recommended.
kindly wade away from some dumps comrades. some vendors are offering outdated salesforce developer certification dumps and thus leading to attaining of poor grades in the exam. get the reliable dumps guys
hey comrades! id highly recommend that you cover the coursework you are offered before delving deeper into dumps. although salesforce developer certification practice questions are beneficial lacking the know how will only leave you confused as you may not cover some crucial topics.