About Laravel

Following are some of the multiple choice questions on the Laravel with answers that will help the students in developing their knowledge.

Laravel MCQ

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

  • reuse similar queries
  • routes queries
  • seed queries
  • None of the above

2. Interpolation of variable in laravel is done using ___.

  • {{}}
  • compact
  • helpers
  • None of the above

3. Controller is create in laravel by using ____ command.

  • php artisan make:controller --plain
  • php artisan make:request controller_name create
  • php artisan make: generate controller contoller_name
  • php artisan make:controller generate

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

  • Database
  • Public
  • Resources
  • Storage

5. Laravel is based on _____________________

  • MVVM Design Pattern
  • Composite Design Pattern
  • Singleton Design Pattern
  • MVC Design Pattern

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

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

7. What is the latest version of Laravel?er 2020.

  • 8.0, released on 8th September
  • 7.0, released on 8th September
  • 6.0, released on 8th September
  • None of the above

8. What do you mean by dd() function?

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

9. Why Laravel?

  • Beautiful syntax
  • Old toolkit
  • High learning curve
  • Promotes bad practices

10. Which directory contains “robot.txt” file ?

  • public
  • route
  • view
  • All are Correct

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

  • 503
  • 400
  • 501
  • None

12. In Laravel, @yield used for?

  • to extend an layout
  • to include a file
  • to display the contents of a given section
  • None of the above

13. Composer is a tool for ______ in PHP.

  • Interpolation
  • configuration
  • dependency management
  • None of the above

14. Which command is used to create a new project in Laravel?

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

15. Which command is used to create migrations in Laravel?

  • php artisan make:migration create_users_table
  • php artisan make:migrate create_users_table
  • php artisan migration create_users_table
  • All are Correct

16. What is it Blade?

  • Template Engine
  • package
  • view file
  • framework

17. Where is routing file located in Laravel?

  • routes/
  • public/
  • view/
  • None of the above

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

  • hasTable()
  • hasTab()
  • hashTable()
  • None of the above

19. Which command is used to start laravel server?

  • php artisan serve
  • php artisan project_name
  • php artisan start php
  • artisan start-server

20. Does Laravel Support Caching?

  • Yes
  • No

21. How to define an mutator in Laravel?

  • setNameAttribute method inside model
  • setNameAttribute method inside controller
  • setMutator method inside controller

22. Which of following command is used to remove the compiled class file in Laravel?

  • php artisan clear-compiled
  • php artisan down
  • php artisan clear-class
  • php artisan inspire

23. Which one Laravel command line interface?

  • composer
  • php artisan
  • git
  • CLI

24. What is the feature of Query Builder ?

  • Works on some supported database
  • Hard to understand
  • Used extensively by Eloquent ORM
  • Non-fluid interface

25. What is the feature of Eloquent ORM ?

  • Flexible
  • Timestamps
  • A lot of use methods
  • All of the above

26. Which of following Collection method returns all records from Laravel collection?

  • ->get()
  • whereAll()
  • ->where()
  • ->all()

27. Which one of the follwing command is used to create middleware in Laravel?

  • php artisan make: middleware
  • php artisan: middleware
  • php arti make: middleware
  • None of the above

28. How to remove a complied class file?

  • clear-compiled command
  • flush-compiled command
  • cache-compiled command
  • All are Correct

29. Why does Laravel use the Blade Template Engine?

  • To simplify programming
  • As a template
  • For fun
  • For the view in MVC

30. Which class is used in Laravel to handle exceptions?

  • App\Exceptions\Handler
  • App\Exception\Handler
  • App\Exceptions\Handle
  • None of the above

31. Which method is used in Laravel to method to check request is ajax or not?

  • $request->ajaxRun()
  • $request->ajaxs()
  • $request->ajax()
  • None of the above

32. Laravel is written in __ language.

  • PHP
  • JSP
  • ASP
  • All are Correct

33. In which directory controllers are kept in Laravel?

  • app/http/Controllers
  • app/http/Views
  • app/http/Model
  • app/http/routes

34. How to get current environment in Laravel?

  • $environment = App::environment();
  • $environment = App::environ();
  • $environment = App::environments();
  • None of the above

35. How to get current route name?

  • request()->route->getName()
  • request()->getName()
  • request()->route()->getName()

36. How to get current action name in Laravel?

  • request()->getActionMethod()
  • request()->route()->getActionMethod()
  • request()->DB->getActionMethod()
  • None of the above

37. When was Laravel first released?

  • June 2011
  • June 2009
  • June 2007
  • All are Correct

38. What does ORM stands for in laravel?

  • Object-Rotational Mechanisim
  • Overloaded-relational Mapping
  • Object-relational Mapping
  • Object-related Modifier

39. How to check current laravel version install your system?

  • php artisan check --version
  • php artisan make --version
  • php artisan --version
  • None of the above

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

  • execute() and rollback()
  • save() and update()
  • up() and down()
  • run() and delete()

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

  • public
  • app
  • bootstrap
  • vendor

42. For what do the .env is used?

  • For setting environment variables
  • For running cron jobs
  • For tracking vendors
  • None of These

43. How to create a controller in laravel by cmd?

  • php artisan make: generate controller contoller_name
  • php artisan make:controller generate
  • php artisan make:controller --plain
  • php artisan make:request controller_name create

44. Who developed Laravel?

  • Rasmus Lerdorf
  • Taylor Otwell
  • James Gosling
  • Guido van Rossum

45. How to set a session data in Laravel?

  • $request->db->session('key', 'value');
  • $request->session()->set('key', 'value');
  • $request->session()->put('key', 'value');
  • None of These

46. What is the minimum PHP version required to install Laravel 5.3?

  • 7.1
  • 5.6.4
  • 5.3.2
  • 5.4.3

47. Where do we need to set database connection in Laravel?

  • config.php
  • setting.php
  • In seed files
  • .ENV file

48. __() in laravel used for

  • Printing value
  • For string translation

49. What is the HTTP Status Code for your website. When it is down for maintenance.

  • 501
  • 200
  • 400
  • 503

50. Interpolation of variable in laravel done using

  • compact
  • {{}}
  • helpers

Enjoyed the Quiz. Share this with friends

Comments

Add Your Review

Your email address will not be published.

Subscribe to Newsletter!

Subscribe to get latest updates and information.