Code Stubs

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.

Edit Code Stubs

You can edit code stubs when selecting languages for a question.

Screenshot 2023-12-12 at 4.09.32 PM.png
Codestub

You can check the Edit Code stubs checkbox to edit the code stub.

Code Stub Parameters

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.

Sample

Problem Statement

Write a program that reads a string and checks whether the string is palindrome or not.

Code Stub

  • Function Name - isPalindrome

  • Return Type - STRING

  • Function Parameters -

    • Type - STRING

    • Name - str

Screenshot 2023-12-12 at 4.11.25 PM.png
Code Stub - isPallinddrome

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:

  • Bash

  • Go

  • Rust

For these languages, you can type the code stub manually in the editor.

Code Stub Code Generation Types

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.

Screenshot 2023-12-12 at 4.11.25 PM.png
Code Stub - System Generated

  • 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.

Screenshot 2023-12-12 at 4.14.23 PM.png
Code Stub - User generated

Can't find what you're looking for?