31st
May
Laravel MCQ

Laravel MCQ

  • Admin
  • 31st May, 2022
  • 1092 Followers

Laravel MCQ Quiz & Test

Following are mostly asked Laravel MCQ test that are designed for professionals like you to crack you interviews. You can take this Laravel online test before appearing to you real interview. This Laravel quiz there are around 30+ multiple choice questions on Laravel with four options.

1) The _______ directory contains your project’s cache, session and log data.

  • A. Database
  • B. Public
  • C. Resources
  • D. Storage

2) Laravel is based on _____________________

  • A. MVVM Design Pattern
  • B. Composite Design Pattern
  • C. Singleton Design Pattern
  • D. MVC Design Pattern

3) Which one Laravel command line interface?

  • A. composer
  • B. php artisan
  • C. git
  • D. CLI

4) Which of following command is used to remove the compiled class file in Laravel?

  • A. php artisan clear-compiled
  • B. php artisan down
  • C. php artisan clear-class
  • D. php artisan inspire

5) How to define an mutator in Laravel?

  • A. setNameAttribute method inside model
  • B. setNameAttribute method inside controller
  • C. setMutator method inside controller
Download Free : Laravel MCQ PDF

6) Does Laravel Support Caching?

  • A. Yes
  • B. No

7) Where do we need to set database connection in Laravel?

  • A. config.php
  • B. setting.php
  • C. .ENV file
  • D. In seed files

8) What would this touch() function do? $obj= User::find(1); $obj->touch();

  • A. store a user object in cache
  • B. created a new filed in database
  • C. update updated_at to current timestamp
  • D. None of the Above

9) Which command is used to start laravel server?

  • A. php artisan serve
  • B. php artisan project_name
  • C. php artisan start php
  • D. artisan start-server

10) Which command is used to create a new project in Laravel?

  • A. php composer.phar create-project --pref-dist laravel/laravel lar-project "5.7.*"
  • B. php composer.phar create-project --prefer-dist laravel/laravel lar-project "5.7.*"
  • C. php compose.phar create-project --prefer-dist laravel/laravel lar-project "5.7.*"
  • D. php composer.phar create-project --prefer-di laravel/laravel lar-project "5.7.*"

11) Composer is a tool for ______ in PHP.

  • A. Interpolation
  • B. configuration
  • C. dependency management
  • D. None of the above

12) What is it Blade?

  • A. Template Engine
  • B. package
  • C. view file
  • D. framework

13) Where is routing file located in Laravel?

  • A. routes/
  • B. public/
  • C. view/
  • D. None of the above

14) Which command is used to create migrations in Laravel?

  • A. php artisan make:migration create_users_table
  • B. php artisan make:migrate create_users_table
  • C. php artisan migration create_users_table
  • D. All are Correct

15) The vendor directory contains ___.

  • A. Third-party code
  • B. Configuration files
  • C. Assets
  • D. Laravel Framework code

16) Which of following Collection method returns all records from Laravel collection?

  • A. ->get()
  • B. whereAll()
  • C. ->where()
  • D. ->all()

17) Which one of the follwing command is used to create middleware in Laravel?

  • A. php artisan make: middleware
  • B. php artisan: middleware
  • C. php arti make: middleware
  • D. None of the above

18) How to remove a complied class file?

  • A. clear-compiled command
  • B. flush-compiled command
  • C. cache-compiled command
  • D. All are Correct

19) What do you mean by dd() function?

  • A. The full form of dd is Date and Day.
  • B. The full form of dd is Directory and Door.
  • C. The full form of dd is Diel and Deal.
  • D. The full form of dd is Dump and Die.

20) Which of the following function in Laravel checks that the desired table is exists in the database or not?

  • A. hasTable()
  • B. hasTab()
  • C. hashTable()
  • D. None of the above

21) Which class is used in Laravel to handle exceptions?

  • A. App\Exceptions\Handler
  • B. App\Exception\Handler
  • C. App\Exceptions\Handle
  • D. None of the above

22) Which method is used in Laravel to method to check request is ajax or not?

  • A. $request->ajaxRun()
  • B. $request->ajaxs()
  • C. $request->ajax()
  • D. None of the above

23) Laravel is written in __ language.

  • A. PHP
  • B. JSP
  • C. ASP
  • D. All are Correct

24) Query scope is a feature of Laravel where we can ____.

  • A. reuse similar queries
  • B. routes queries
  • C. seed queries
  • D. None of the above

25) In which directory controllers are kept in Laravel?

  • A. app/http/Controllers
  • B. app/http/Views
  • C. app/http/Model
  • D. app/http/routes

26) How to get current environment in Laravel?

  • A. $environment = App::environment();
  • B. $environment = App::environ();
  • C. $environment = App::environments();
  • D. None of the above

27) In Laravel, @yield used for?

  • A. to extend an layout
  • B. to include a file
  • C. to display the contents of a given section
  • D. None of the above

28) After running "artisan down", The project will show the maintenance page. What would be HTTP Status return Code?

  • A. 503
  • B. 400
  • C. 501
  • D. None

29) Which directory contains “robot.txt” file ?

  • A. public
  • B. route
  • C. view
  • D. All are Correct

30) How to get current route name?

  • A. request()->route->getName()
  • B. request()->getName()
  • C. request()->route()->getName()

31) What is the minimum PHP version required to install Laravel 5.3?

  • A. 5.6.4
  • B. 5.4.3
  • C. 5.4.1
  • D. None of the above

32) How to get current action name in Laravel?

  • A. request()->getActionMethod()
  • B. request()->route()->getActionMethod()
  • C. request()->DB->getActionMethod()
  • D. None of the above

33) What is the latest version of Laravel?er 2020.

  • A. 8.0, released on 8th September
  • B. 7.0, released on 8th September
  • C. 6.0, released on 8th September
  • D. None of the above

34) When was Laravel first released?

  • A. June 2011
  • B. June 2009
  • C. June 2007
  • D. All are Correct

35) What does ORM stands for in laravel?

  • A. Object-Rotational Mechanisim
  • B. Overloaded-relational Mapping
  • C. Object-relational Mapping
  • D. Object-related Modifier

36) How to check current laravel version install your system?

  • A. php artisan check --version
  • B. php artisan make --version
  • C. php artisan --version
  • D. None of the above

37) Controller is create in laravel by using ____ command.

  • A. php artisan make:controller --plain
  • B. php artisan make:request controller_name create
  • C. php artisan make: generate controller contoller_name
  • D. php artisan make:controller generate

38) How to set a session data in Laravel?

  • A. $request->session()->put('key', 'value');
  • B. $request->session()->set('key', 'value');
  • C. $request->db->session('key', 'value');
  • D. None of These

39) Interpolation of variable in laravel is done using ___.

  • A. {{}}
  • B. compact
  • C. helpers
  • D. None of the above

40) Which of the following methods are used in Database Migrations classes?

  • A. execute() and rollback()
  • B. save() and update()
  • C. up() and down()
  • D. run() and delete()

41) Which of the following is a root directory in laravel

  • A. public
  • B. app
  • C. bootstrap
  • D. vendor

Laravel Online Test Questions (Laravel FAQs)

1) How to initialize laravel collection?

A collection in Laravel Framework can be created from an array using the collect() helper method or by instantiating the Illuminate\Support\Collection class.

Below is an example to  intialize Collection in Laravel

$collection = collect(['abc', 'Xyz', 'laravel']);

2) Explain relationships in Laravel Framework?

A relationship is an association between two models. Relationships are created to link tables together and provide a way for data to be related. In Laravel, there are mainly 3 types of relationships used in Laravel framework.

  • belongs-to: The belongs-to relationship is the most common type of relationship that you will see in your application. It indicates that one model (belongs to) another model and it is often used to indicate that a user has many posts or a post belongs to a user.
  • has-one: The has-one relationship indicates that one model (has one) belongs to another model but it does not have any additional information about the association between the two models such as how many there are or what type they are. It's often used when we want to show how many comments a post has or how many likes it received.
  • has-many: The has-many relationship indicates that one model (has many) belongs to another model but it also provides

3) What is logging in Laravel?

The Laravel logging system is based on "channels". Each channel represents a specific way of writing log information, such as a console, file, or database. For example, you can create a channel called "console" that will write log information to the console. You can also create channels called "file" and "database" that will write log information to files and databases.
There are four main types of channels: -

  • Event: A log event.
  • Warning: A log warning.
  • Error: A log error.
  • Information: A log informational message.

4) What are Requests in Laravel?

Requests in Laravel are a way to send data to your application. There are two types of requests, GET and POST. GET requests are used when you want to retrieve data from the server and POST requests are used when you want the server to do something for you.

Requests are the first step in a Laravel workflow. It is the first thing that happens when a user interacts with your application.

Requests are made up of three parts:

  • URL: The URL to which you want to redirect the user.
  • HTTP: The HTTP verb you want to use (GET, POST, PUT, DELETE).
  • DATA: The data you want sent with that request (parameters).

5) What is throttling and how to implement it in Laravel?

Throttling is a technique used to control the number of concurrent requests. It can be implemented in Laravel by using the throttle middleware.

Throttling is a technique used to limit the number of concurrent requests that can be processed by a system. It can be used for both limiting the load on your servers as well as for protecting against Denial-of-Service attacks. Throttling is often done with an API call or web request, but it can also be done via a queue, such as Beanstalkd or Gearman.

In Laravel, throttling can be implemented using the throttle middleware which will allow you to specify how many requests should go out per second and how long each request should wait before being sent out again.

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.

Related MCQ/Quiz

01st
Nov
jQuery MCQ
01st
May
Powerpoint MCQ
01st
Jun
Blue Prism MCQ
01st
Jun
MS DOS MCQ
01st
Jun
Robotics MCQ