Code Stubs are boilerplate code that can be given to the candidates as a Kickstarter in the Test. It allows the candidate to focus more on the algorithm needed to solve the problem rather than focusing on input and output syntax.
Code Stubs are generated for a particular language when they are selected while setting up a question. However, you can also edit the code stub generated for a particular language.
You can edit code stubs when selecting languages for a question.
You can check the Edit Code stubs checkbox to edit the code stub.
Different parameters that are required for generating code stubs are as follows,
Function Name - You can only specify one function for the automated code stub generation. However, If you require more than one function, you can select the particular language and manually modify the code stub as required.
Return Type - The function's return type defines the type of value returned by the function. It can be a string, integer, float, boolean, long integer, double, void etc.
Function Parameters - Function parameters are the variables that are passed as arguments into a function. You can specify the type of the parameters, and also you can add multiple parameters if required.
Write a program that reads a string and checks whether the string is palindrome or not.
Function Name - isPalindrome
Return Type - STRING
Function Parameters -
Type - STRING
Name - str
Once you add the code stub parameters, then click on generate code to generate the code stub.
Currently, you cannot generate code stubs automatically for the following languages:
For these languages, you can type the code stub manually in the editor.
There are 2 ways in which code stub code is generated.
System Generated -The code stub that is generated automatically by the system using the code stub parameters provided by the user is known as system-generated code stub. These are generated as you click generate code button as show in following image.
User Generated - The code stub that is manually created by the user by editing the code stub editor as show in the image below is known as user-generated code stub.