Ads by Google
Get This Adsense Pop-up Window


Friday 18 August 2017

Angularjs upwork test answers (top 10%, 20%) Answers 2019

1. A promise is an interface that deals with objects that are __ or __ filled in at a future point in time (basically, asynchronous actions)?

Answers:

• set, data
• returned, data
• returned, set
• returned, get

2. Which of the following are methods in an instance of $q.defer() ?
Note: There may be more than one right answer.

Answers:

• finally
• when
• notify
• then
• reject
• resolve

3. Which of the following is the correct syntax for using the $q.all method?
Note: There may be more than one right answer.

Answers:

• «`
$q.all([promise1(),promise2]]).then((values) => {

});
«
• «`
$q.all(“promise1”, “promise2”).then((values) => {

});
«`
• «`
$q.all({«promise1″: promise1(),»promise2»: promise2()}).then((values) => {

});
«`

4. Custom directives are used in AngularJS to extend the functionality of HTML?

Answers:

• extend
• integrate
• render
• connect
• connect

5. Explain $q service, deferred and promises, Select a correct answer?

Answers:

• Promises are post processing logics which are executed after some operation/action is completed whereas ‘deferred’ is used to control how and when those promise logics will execute.
• We can think about promises as “WHAT” we want to fire after an operation is completed while deferred controls “WHEN” and “HOW” those promises will execute.
• “$q” is the angular service which provides promises and deferred functionality.
• All of the above

6. The Promise proposal dictates the following for asynchronous requests?
Note: There may be more than one right answer.

Answers:

• The Promise has a then function, which takes two arguments, a function to handle the “resolved” or “success” event, and a function to handle the “rejected” or the “failure” event
• It is guaranteed that one of the two callbacks will be called, as soon as the result is available
• Async requests return a promise instead of a return value
• The Promise proposal is the basis for how AngularJS structures local

7. How to use AngularJS promises, read the example code?

Answers:

• controller(‘MyCtrl’, function($scope, $q) {
function longOperation() {
var q = $q.defer();
somethingLong(function() {
q.resolve();
});
return q.promise;
}
longOperation().then(function() {
});
})
• controller(‘MyCtrl’, function($scope, $q) {
var lastUrl;
var lastFileName
return {
createPdf(url, fileName){
//do processing
lastUrl = url;
lastFileName = fileName
},
loadLastPdf(){
//use lastUrl and lastFileName
}
}
})
• Both of the above
• None of the above

8. What is ng-hide directive used for?

Answers:

• Show a given control
Hide a given control
• Both of the above
• None of the above

9. What is the output of the following code:

$scope.firstName = «John»,
$scope.lastName = «Doe»
{{ firstName | uppercase }} {{ lastName }}

Answers:

• john doe
• JOHN DOE
• John Doe
• JOHN Doe

10. Which of the following is a valid http get request in AngularJS?

Answers:

• $http.request(«someUrl»)
.then(function(response) {
$scope.content = response.data;
});
• $http({
url : «someUrl»
}).then(function succesFunction(response) {
$scope.content = response.data;
}, function errorFunction(response) {
$scope.content = response.statusText;
});
• $http({
url : “someUrl»
data : «test»
}).then(function succesFunction(response) {
$scope.content = response.data;
}, function errorFunction(response) {
$scope.content = response.statusText;
});
• $http.get(”method=get”,“someUrl”)
.then(function(response) {
$scope.content = response.data;
});

11. Which of the following directive bootstraps AngularJS framework?

Answers:

• ng-init
• ng-app
• ng-controller
• ng-bootstrap

12. AngularJS supports inbuilt internationalization following types of filters?
Note: There may be more than one right answer.

Answers:

• numbers
• date
• currency
• None of the above

13. Which of the following is validation css class in AngularJS?

Answers:

• ng-valid
• ng-invalid
• ng-pristine
• All of the above.

14. Which of the following service is used to handle uncaught exceptions in AngularJS?

Answers:

• $errorHandler
• $exception
• $log
• $exceptionHandler

15. Out of the following which statement is equivalent to
< p ng-bind=»foo «>< /p >

Answers:

• <p>{{foo}}</p>
• <p {{foo}}></p>
• <p>{{«foo»}}</p>
• <p {{«foo»}}></p>

16. Which of the following module is required for routing?

Answers:

• angular.js
• angular-route.js
• angularRouting.js
• route.js

17. Which of the following is not a type of an Angular service?

Answers:

• service
• value
• controller
• provider
• factory
• constant

18. Which of the following is not valid feature for Angular templates?

Answers:

• Routes
• Filters
• Directives
• Forms

19. Dynamically loadable DOM template fragment, called a , through a ?

Answers:

• view, model
• view, route
• view, template
• view, render

20. Which Angular service simulate the ‘console’ object methods from Javascript?

Answers:

• Http
• Log
• Interpolate
• Sce

21. What is Angular Expression, How do you differentiate between Angular expressions and JavaScript expressions?

Answers:

• Context : The expressions are evaluated against a scope object in Angular, while Javascript expressions are evaluated against the global window.
• Forgiving: In Angular expression, the evaluation is forgiving to null and undefined whereas in JavaScript undefined properties generate TypeError or ReferenceError.
• No Control Flow Statements: We cannot use loops, conditionals or exceptions in an Angular expression.
• Filters: In Angular unlike JavaScript, we can use filters to format data before displaying it.
• All of the above

22. Which of the following is true about lowercase filter?

Answers:

• Lowercase filter converts a text to lower case text.
• Lowercase filter converts the first character of the text to lower case.
• Lowercase filter converts the first character of each word in text to lower case.
• None of the above

23. Which of the following is Angular E2E testing tool?

Answers:

• JsTestDriver
• Jasmine
• Nightwatch
• Protractor

24. What is the output of the following code:

$scope.data = [1, 2, 3, 4, 5];
< span ng-repeat=»item in data» ng-if=»item > 5 && item < 10 «>{{ item }}< /span >

Answers:

• 6 7 8 9 10
• 1 2 3 4 5
• Nothing is output

25. What can be following validate data in AngularJS?

Answers:

• $dirty − states that value has been changed.
• $invalid − states that value entered is invalid.
• $error − states the exact error.
• All of the above

26. AngularJS service can be created,registered,created in following different ways?
Note: There may be more than one right answer.

Answers:

• the factory() method
• the value() method
• the service() method
• the provider() method
• None of the above

27. ng-bind directive binds ___.

Answers:

• Data to model.
• View to controller.
• Model to HTML element.
• Model to $scope.

28. What is the output of the following code?

< body ng-app=»myApp» >
< !— directive: my-directive — >
< /body>
var app = angular.module(«myApp», []);
app.directive(«myDirective», function() {
return {
replace : true,
template : «<h1>I got printed</h1>»
};
});

Answers:

• <h1 my-directive=»»>I got printed</h1>
• Blank Screen
• <h1>I got printed</h1>
• <h1 class=»my-directive»>I got printed</h1>

29. What kind of filters are supported the inbuilt internationalization in AngularJS?

Answers:

• currency and date
• currency, date and numbers
• date and numbers
• None of above

30. What is the output of the following code?

< div ng-app=»myApp» >
< h1>{{98 | myFormat}}< /h1>
< /div>
var app = angular.module(‘myApp’, []);
app.service(‘myAlter’, function() {
this.myFunc = function (x) {
return x+’%’;
}
});
app.filter(‘myFormat’,[‘myAlter’, function(myAlter) {
return function(x) {
return myAlter.myFunc(x);
};
}]);

Answers:

• 98%
• 9.8
• 0.98
• 0.98%

31. Which of the following correctly sets a height to 100px for an element?

Answers:

• angular.element(‘#element’).style.height = ‘100px’;
• angular.element(‘#element’).css.height = 100;
• angular.element(‘#element’).css(‘height’, 100);
• angular.element(‘#element’).css(‘height’, ‘100px’);

32. How AngularJS expressions are different from the JavaScript expressions?

Answers:

• Angular expressions can be added inside the HTML templates.
• Angular expressions doesn’t support control flow statements (conditionals, loops, or exceptions).
• Angular expressions support filters to format data before displaying it.
• All of the above

33. Which of the following service components in Angular used to create XMLHttpRequest objects?
Note: There may be more than one right answer.

Answers:

• jsonpCallbacks
• httpParamSerializer
• httpParamSerializerJQLike
• http
• httpBackend
• xhrFactory

34. AngularJS filters ____.

Answers:

• Format the data without changing original data.
• Filter the data to display on UI.
• Fetch the data from remote server.
• Cache the subset of data on the browser.

35. What is the difference beetween watchGroup and watchCollection methods?

Answers:

• The `watchCollection` watch the single object properties, while `watchGroup` watch a group of expressions.
• The `watchCollection` deeply watch the single object properties, while `watchGroup` watch a group of expressions.
• The `watchGroup` deeply watch the single object properties, while `watchCollection` watch a group of expressions.
• The `watchGroup` shallow watch the single object property, while `watchCollection` all object properties.

36. Using the following Custom AJAX property within AngularJs Service?

Answers:

• myApp.factory(‘GetBalance’, [‘$resource’, function ($resource) {
return $resource(‘/Service/GetBalance’, {}, {
query: { method: ‘GET’, params: {}, headers: { ‘beforeSend’: » } }, isArray: true,
});
}]);
• myApp.factory(‘GetBalance’, [‘$resource’, function ($resource) {
return $resource(‘/Service/GetBalance’, {}, {
query: { method: ‘GET’, params: {}, }, isArray: true,
});
}]);
• $.ajax({
type: «GET/POST»,
url: ‘http://somewhere.net/’,
data: data,
beforeSend: »,
}).done().fail();
• All of the above

37. What are the filters in AngularJS, Choose the right answer?

Answers:

• Filters are the rendered view with information from the controller and model. These can be a single file (like index.html) or multiple views in one page using «partials».
• Filters select a subset of items from an array and return a new array. Filters are used to show filtered items from a list of items based on defined criteria.
• It is concept of switching views. AngularJS based controller decides which view to render based on the business logic.
• All of the above

38. What is $rootScope, Choose a True statement?

Answers:

• Scope is a special JavaScript object which plays the role of joining controller with the views. Scope contains the model data. In controllers, model data is accessed via $scope object. $rootScope is the parent of all of the scope variables.
• Scope is a special Php object which plays the role of joining controller with the views. Scope contains the model data. In controllers, model data is accessed via $scope object. $rootScope is the parent of all of the scope variables.
• Scope is a special ASP.Net object which plays the role of joining controller with the views. Scope contains the model data. In controllers, model data is accessed via $scope object. $rootScope is the parent of all of the scope variables.
• All of the above

39. Which of the following is the correct syntax for using filters?

Answers:

• «`
<ul>
<li ng-repeat=»x in names || orderBy:’country’»>
{{ x.name + ‘, ‘ + x.country }}
</li>
</ul>
«`
• «`
<ul>
<li ng-repeat=»x in names && orderBy:’country’»>
{{ x.name + ‘, ‘ + x.country }}
</li>
</ul>
«`
• «`
<ul>
<li ng-repeat=»x in names | orderBy=’country’»>
{{ x.name + ‘, ‘ + x.country }}
</li>
</ul>
«`
• «`
<ul>
<li ng-repeat=»user in users | orderBy:’country’»>
{{ user.name + ‘, ‘ user.country}}
</li>
</ul>
«`

40. The ng-model directive is used for ____.

Answers:

• One-way data binding.
• Two-way data binding.
• Binding view to controller.
• None of the above.

41. What is $rootScope, Choose a True statement?

Answers:

• Scope is a special JavaScript object which plays the role of joining controller with the views. Scope contains the model data. In controllers, model data is accessed via $scope object. $rootScope is the parent of all of the scope variables.
• Scope is a special Php object which plays the role of joining controller with the views. Scope contains the model data. In controllers, model data is accessed via $scope object. $rootScope is the parent of all of the scope variables.
• Scope is a special ASP.Net object which plays the role of joining controller with the views. Scope contains the model data. In controllers, model data is accessed via $scope object. $rootScope is the parent of all of the scope variables.
• All of the above

42. AngularJS directives can be written in HTML element as:

Answers:

• Tag
• Attribute
• Class name
• All of the above.

43. Which of the following statement is True about provider?

Answers:

• provider is used by AngularJS internally to create services, factory etc.
• provider is used during config phase
• provider is a special factory method
• All of the above

44. How you can Get AngularJs Service from Plain Javascript using the following code?

Answers:

• angular.service(‘messagingService’, [‘$rootScope’, ‘applicationLogService’, ‘dialogService’, MessageService]);
• angular.injector([‘ng’, ‘error-handling’]).get(«messagingService»).GetName();
• angular.injector([‘ng’, ‘error-handling’, ‘module-that-owns-dialogService’ ]).get(«messagingService»).GetName();
• All of the above

45. Angular loads into the page, waits for the page to be fully loaded, and then looks for ng-app to define its ___ boundaries?

Answers:

• web
• pages
• filter
• template

46. What is $scope?

Answers:

• It transfers data between a controller and view.
• It transfers data between model and controller.
• It is a global scope in AngularJS.
• None of the above.

47. Which of the following service is used to retrieve or submit data to the remote server?

Answers:

• $http
• $XMLHttpRequest
• $window
• $get

48. Which of the following modules will help with routing in the Angular application?

Answers:

• angularRouter
• ng-view-router
• ngRoute
• viewRouter

49. AngularJS applies some basic transformations on all requests and responses made through its $http service?
Note: There may be more than one right answer.

Answers:

• Request transformations If the data property of the requested config object contains an object, serialize it into JSON format.
• Response transformations If an XSR prefix is detected, strip it. If a XML response is detected, deserialize it using a JSON parser.
• Response transformations If an XSRF prefix is detected, strip it. If a JSON response is detected, deserialize it using a JSON parser.
• None of the above

50. What are the services in AngularJS?

Answers:

• Services are singleton objects which are instantiated only once in app an are used to do the defined task.
• Services are objects which AngularJS uses internally.
• Services are not used in AngularJS.
• Services are server side components of AngularJS.

51. Which of the following methods make $scope dirty-checking?

Answers:

• `$watch, $watchCollection`
• `$digest, $eval`
• `$watch, $apply`
• `$apply, $digest`

52. Which of the following code will clickCount incremented on button click and displayed?

Answers:

• <button ng-click=»clickCount = clickCount + 1″ >
Click me!
</button>
<span> count: {{clickCount}} </span>
• <button on-click=»clickCount = clickCount + 1″ >
Click me!
</button>
<span> count: {{clickCount}} </span>
• <button ng-click=»clickCount = clickCount + 1″ >
Click me!
</button>
<span> count: {clickCount} </span>
• <button on-click=»clickCount = clickCount + 1″ >
Click me!
</button>
<span> count: {clickCount} </span>

53. Which of the following is valid route definition?

Answers:

• app.config(function($ routeProvider) { $routeProvider
.on(«/1», {
templateUrl : «1.htm» })
.on(«/2», {
templateUrl : «2.htm»
})
.otherwise( {
templateUrl : «default.htm»
})
});
• app.config(function($ routeProvider) { $routeProvider
.when(«/1», { templateUrl : «1.htm»
})
.when(«/2», { templateUrl : «2.htm»
})
.otherwise( {
templateUrl : «default.htm»
})
});
• app.config(function($ routeProvider) { $routeProvider
.when(«/1», { templateUrl : «1.htm»
})
.when(«/2», { templateUrl : «2.htm»
})
.default( {
templateUrl : «default.htm»
})
});
• app.config(function($routeProvider) { $routeProvider
.on(«/1», {
templateUrl : «1.htm» })
.on(«/2», {
templateUrl : «2.htm»
})
.default( {
templateUrl : «default.htm»
})
});

54. Which of the following is true about ng-model directive?

Answers:

• ng-model directive binds the values of AngularJS application data to HTML input controls.
• ng-model directive creates a model variable which can be used with the html page and within the container control having ng-app directive.
• Both of the above.
• None of the above.

55. How can you display the elements which contains given pattern of a collection?

Answers:

• <ul>
<li ng-repeat=»item in collection | contains:’pattern’ «>
{{ item }}
</li>
</ul>
• <ul>
<li ng-repeat=»item in collection filter:’pattern’ «>
{{ item }}
</li>
</ul>
• <ul>
<li ng-iterate=»item in collection | filter:’pattern’ «>
{{ item }}
</li>
</ul>
• <ul>
<li ng-repeat=»item in collection | filter:’pattern’ «>
{{ item }}
</li>
</ul>

56. What is the output of the following code:

< div ng-app=»myApp» ng-controller=»myCtrl» >
< p ng-bind=»marks_obtained» ng-if=»(marks_obtained/total_marks)*100 >= 40″ > </ p>
< /div>
var app = angular.module(‘myApp’, []);
app.controller(‘myCtrl’, function($scope) {
$scope.marks_obtained= «60»;
$scope.total_marks = «100»;
});

Answers:

• Pass
• 60
• NaN
• 0.60

57. Which way to hold dependencies in Angular component is more viable ?

Answers:

• The component can create the dependency, typically using the new operator.
• The component can look up the dependency, by referring to a global variable.
• The component can have the dependency passed to it, where it is needed.
• The component can have JSON file with dependencies.

58. Which module is used for navigate to different pages without reloading the entire application?

Answers:

• ngBindHtml
• ngHref
• ngRoute
• ngNavigate

59. In which component is it right way to use the additional libraries? Such as jQuery and etc.

Answers:

• controller
• service
• provider
• directive

60. Which of the following is not a valid for Angular expressions?

Answers:

• Arrays
• Objects
• Function definition
• Strings

61. What is deep linking in AngularJS?

Answers:

• Deep linking allows you to encode the state of application in the URL so that it can be bookmarked.
• Deep linking is a SEO based technique.
• Deep linking refers to linking various views to a central page.
• None of the above.

62. Convenience methods are provided for most of the common request types, including?
Note: There may be more than one right answer.

Answers:

• JSONP
• HEAD
• TRACE
• PUT

63. When are the filters executed in the Angular application?

Answers:

• After each `$digest`.
• Before each `$digest`.
• When their inputs are changed
• When one of their inputs is undefined

64. How is it possible to emit some event?

Answers:

• `$emit()`
• `$on()`
• `$digest`
• `$watch`

65. AngularJS supports i18n/L10n for the following filters out of the box?
Note: There may be more than one right answer.

Answers:

• date/time
• factory
• number
• currency

66. What is the output of the following code:

$scope.x = 20;
{{ x | number:2 }}

Answers:

• 20
• 20.0
• 20.00

67. Which of the following syntax is True of filter using HTML Template?

Answers:

• {( filter_expression filter : expression : comparator : anyPropertyKey)}
• {filter_expression filter : expression : comparator : anyPropertyKey}
• {{ filter_expression | filter : expression : comparator : anyPropertyKey}}
• { filter_expression | filter : expression : comparator : anyPropertyKey}

68. Which of the following custom filters will uppercase every third symbol in a string?

Answers:

• «`
app.filter(‘myFormat’, function() {
return function(x) {
var i, c, txt = «»;
for (i = 0; i < x.length; i++) {
c = x[i];
if (i % 3 == 0) {
c = c.toUpperCase();
}
txt += c;
}
return txt;
};
});
«`
• «`
app.filter(‘myFormat’, function() {
return function(x) {
var i, c, txt = «»;
for (i = 0; i < x.length; i++) {
if (i % 3 == 0) {
c = c.toLowerCase();
}
txt += c;
}
return txt;
};
});
«`
• «`
app.filter(‘myFormat’, function() {
return function(x) {
var i, c, txt = «»;
for (i = 0; i < x.length; i++) {
c = x[i];
if (i % 3 == 0) {
c = c.toUpperCase();
}
txt += c;
return txt;
}
};
});
«`
• «`
app.filter(‘myFormat’, function() {
return function(x) {
var i, c, txt = «»;
for (i = 0; i < x.length; i++) {
c = x[i];
if (i % 3 == 0) {
txt += c;
}
return txt.toUpperCase();
}
};
});
«`

69. Which of the following is the best way to create a shallow copy of an object in Angular?

Answers:

• angular.copy
• angular.extend
• angular.identity
• angular.injector

70. Which directive is responsible for bootstrapping the AngularJS application?

Answers:

• ng-init
• ng-app
• ng-model
• ng-controller

71. Which of the following statements are true?

Answers:

• Expression cannot contain condition, loop or RegEx.
• Expression cannot declare a function.
• Expression cannot contain comma, void or return keyword.
• All of the above.

72. For the given url http://mysite.com:8080/urlpath?q=1 what is the value of the expression below?
var host = $location.host();

Answers:

• mysite.com
• mysite.com:8080
• http://mysite.com
• http://mysite.com:8080

73. How to use AngularJS Promise for some object as following?
Note: There may be more than one right answer.

Answers:

• function getCurrentCall() {
var deferred = $q.defer();
if (!$scope.currentCall) {
$scope.currentCall = ‘foo’;
}
deferred.resolve();
return deferred.promise;
}
• $scope.turnOffLocalAudio = function() {
getCurrentCall().then(function() {
if ($scope.currentCall.chat) {
$scope.currentCall.chat.offLocalAudio(false);
}
}, function() {
// unable to get CurrentCall
});
};
• $scope.turnOffLocalAudio = function () {
if ($scope.currentCall) {
if ($scope.currentCall.chat) {
$scope.currentCall.chat.offLocalAudio(false);
}
}
}
• All of the above

74. What is difference between ng-if and ng-show directives?

Answers:

• When using ng-if or ng-show directive, the hidden elements are placed in DOM with property display: none.
• When using ng-show directive, the hidden elements are placed in DOM with property display: none. directive ng-if includes those elements in DOM, which are equal to the condition. — наиболее подходящее
• When using ng-if directive, the hidden elements are placed in DOM with property display: none. directive ng-show includes those elements in DOM, which are equal to the condition.
• When using ng-if or ng-show directive, in DOM are placed those elements, which are equal to the condition.

75. Which of the following directives changes CSS-style of DOM-element?
Note: There may be more than one right answer.

Answers:

• `ng-class`
• `ng-value`
• `ng-style`
• `ng-options`

76. Data binding in AngularJS is the synchronization between the and the ?

Answers:

• model, view
• model, state
• view, controller
• model, controller

77. Which of the following directive allows us to use form?

Answers:

• ng-include
• ng-form
• ng-bind
• ng-attach

78. How can using ngView directive?

Answers:

• To display the HTML templates or views in the specified routes.
• To display the HTML templates.
• To display the views in the specified routes.
• To display iframes

79. What is the output for the following code?
’30’ + 35

Answers:

• 65
• NaN
• 3035

80. Which of the following statement True of templates in AngularJS?

Answers:

• In Angular, templates are written with HTML that contains Angular-specific elements and attributes. Angular combines the template with information from the model and controller to render the dynamic view that a user sees in the browser. In other words, if your HTML page is having some Angular specific elements/attributes it becomes a template in AngularJS.
• Transfer data to and from the UI:Angular.js helps to eliminate almost all of the boiler plate like validating the form, displaying validation errors, returning to an internal model and so on which occurs due to flow of marshalling data.
• Deep linking allows you to encode the state of application in the URL so that it can be bookmarked. The application can then be restored from the URL to the same state.
• All of the above

81. How is it possible to pass parameters in $http get request?

Answers:

• in property data
• in property params
• in property url
• in property resource

82. What are the services in AngularJS?

Answers:

• Filters select a subset of items from an array and return a new array. Filters are used to show filtered items from a list of items based on defined criteria.
• AngularJS come with several built-in services. For example $http service is used to make XMLHttpRequests (Ajax calls). Services are singleton objects which are instantiated only once in app.
• Templates are the rendered view with information from the controller and model. These can be a single file (like index.html) or multiple views in one page using «partials».
• All of the above

83. What type of the attribute directive data binding is used in code below?

var directive = function(){
return {
scope: {
myParam: ‘@’
}
}
}

Answers:

• Isolate scope one way string binding. Parent changes affect child, child changes doesn’t affect parent
• Isolate Scope two way object binding. Parent changes affect child and child changes affect parent
• Isolate scope object and object literal expression binding
• Isolate scope function expression binding

84. Do I need to worry about security holes in AngularJS?
Note: There may be more than one right answer.

Answers:

• Like any other technology, AngularJS is not impervious to attack. Angular does, however, provide built-in protection from basic security holes including cross-site scripting and HTML injection attacks. AngularJS does round-trip escaping on all strings for you and even offers XSRF protection for server-side communication.
• AngularJS was designed to be compatible with other security measures like Content Security Policy (CSP), HTTPS (SSL/TLS) and server-side authentication and authorization that greatly reduce the possible attack vectors and we highly recommended their use.
• Transfer data to and from the UI:Angular.js helps to eliminate almost all of the boiler plate like validating the form, displaying validation errors, returning to an internal model and so on which occurs due to flow of marshalling data.
• All of the above

85. AngularJS has default headers which it applies to all outgoing requests, which include the following?
Note: There may be more than one right answer.

Answers:

• Accept: application/json, text/plain,
• X-Requested-With: HttpRequest
• X-Requested-With: XMLHttpRequest
• None of the above

86. What makes angular.js better and does?

Answers:

• Registering Callbacks:There is no need to register callbacks . This makes your code simple and easy to debug.
• Control HTML DOM programmatically:All the application that are created using Angular never have to manipulate the DOM although it can be done if it is required.
• Transfer data to and from the UI:Angular.js helps to eliminate almost all of the boiler plate like validating the form, displaying validation errors, returning to an internal model and so on which occurs due to flow of marshalling data.
• No initilization code: With angular.js you can bootstrap your app easily using services, which auto-injected into your application in Guice like dependency injection style.
• All of the above

87. What {{::value}} is mean?

Answers:

• The output value
• Two-way object binding is disabled
• One-way object binding is disabled
• It’s incorrect

88. How to use and register decorators in AngularJS?
Note: There may be more than one right answer.

Answers:

• $tempalte.decorator
• $provide.decorator
• provide.decorator
• module.decorator

89. Pick the correct statement in connection to the ng-include directive?

Answers:

• It is used to embed HTML from an external file
• It is used to embed JS from external files
• Both of the above
• None of the above

90. Which method of $routeProvider redirect to a specific page when no other route definition is matched?

Answers:

• when()
• otherwise()
• redirectTo()
• default()

91. Which of the following provider can be used to configure routes?

Answers:

• $routeProvider
• $url
• $rulesProvider
• None of the above.

92. Select a True statement of RootRouter concept?

Answers:

• The top level Router that interacts with the current URL location
• Displays the Routing Components for the active Route. Manages navigation from one component to the next
• Defines how the router should navigate to a component based on a URL pattern
• An Angular component with a RouteConfig and an associated Router

93. How can you lowercase a given string named examplePattern?

Answers:

• {{ examplePattern filter : lowercase }}
• {{ examplePattern | lowercase }}
• {{ lowercase(examplePattern) }}
• {{ examplePattern | filter : lowercase }}

94. If you want to observe the changes of full object $scope.myObj={one:1, two:2}, what way do you choose?

Answers:

• `$scope.$watch(‘myObj’, function(){ … })`
• `$scope.$on(‘myObj’, function(){ … })`
• `$scope.$watch(‘myObj’, function(){ … }, true)`
• `$scope.$on(‘myObj’, function(){ … }, true)`

95. The ng-change directive must be used with ng-model directives.

Answers:

• True
• False
• Sometimes
• None of the above.

96. Which of the followings are validation directives?

Answers:

• ng-required
• ng-minlength
• ng-pattern
• All of the above.

97. What is service in AngularJS?

Answers:

• Service is reusable UI component.
• Service is a reusable JavaScript Function.
• Service is data provider.
• None of the above.

98. Call angularjs service from simple JS following code?

Answers:

• angular.module(‘main.app’, []).factory(‘MyService’, [‘$http’, function ($http) {
return new function () {
this.GetName = function () {
return «MyName»;
};
};
}]);
angular.injector([‘ng’, ‘main.app’]).get(«MyService»).GetName();
• angular.module(‘app.main’).factory(‘MyService’, [«$http», function ($http) {
return new function () {
this.GetName = function () {
return «MyName»;
};
};
}]);
• Both of the above
• None of the above

99. Which of the following is valid AngularJS application definition?

Answers:

• var myApp = ng.module(‘myApp’,[]); d-)
• var myApp = angular.app(‘myApp’,[]);
• var myApp = angular.module(‘myApp’,[]);
• var myApp = ng.app(‘myApp’,[]);

100. Which of the following isValid AngularJS Expression?

Answers:

• {{ 2+2 }}
• { 2+2 }
• (( 2+2 ))
• { ( 2+2 ) }

102. What is $rootScope?

Answers:

• $rootScope does’t exist
• $rootScope is single root object scope for the app. All other scopes are descendant scope of the root scope.
• $rootScope is single root object scope in each module. All other scopes are descendant scope of the root scope.
• $rootScope and $scope are the same object. Developers decide what they will use.

103. What kind of filters are supported the inbuilt internationalization in Angularjs?

Answers:

• currency and date
• Currency, date and numbers
• date and numbers
• None of above

104. You can invoke a directive by using following example?

Answers:

• <w3-test-directive></w3-test-directive>
• <div w3-test-directive></div>
• <div class=”w3-test-directive”></div>
• <– directive: w3-test-directive –>
• <!– directive: w3-test-directive –>

105. config phase is the phase during which AngularJS bootstraps itself.

Answers:

• True
• False

106. Which of the following is true about currency filter?

Answers:

• Currency filter formats text in a currency format.
Currency filter is a function which takes text as input.
• Both of the above.
• None of the above.

Laravel upwork test answers (Top 10%, 20%) || Answers 2019

1. Use a validation rules inside the custom validation class?

Answers:

• $emailsOutput = Output::get(’email’);
$emails = explode(‘,’, $emails);
foreach($emails as $email) {
$validator = Validator::make(
[’email’ => $email],
[’email’ => ‘required|email’]
);
if ($validator->fails())
{
// There is an invalid email in the input.
}
}
• $emailsInput = Input::get(’email’);
$emails = explode(‘,’, $emails);
foreach($emails as $email) {
$validator = Validator::make(
[’email’ => $email],
[’email’ => ‘required|email’]
);
if ($validator->fails())
{
// There is an invalid email in the input.
}
}
• $emailsOutput = Output::get_email(’email’);
$emails = explode(‘,’, $emails);
foreach($emails as $email) {
$validator = Validator::make(
[’email’ => $email],
[’email’ => ‘required|email’]
);
if ($validator->fails())
{
// There is an invalid email in the input.
}
}
• None
2. If blog post has infinite number of comments we can define one-to-many relationship by placing following code in post model?

Answers:

• public function comments()
{
return $this->hasMany(‘App\Comment’);
}
• public function comments()
{
return $this->belongsTo(‘App\Comment’);
}
• public function comments()
{
return $this->oneToMany(‘App\Comment’);
}
3. Using Form class to add the ‘disabled’ attribute for some options.

Answers:

• {{ Form::select(‘set’, $sets, $prod->set_id, array(‘class’ => ‘form-select’)) }}
• {{ Form::select(‘set’, $sets, $prod->set_id, array(‘class’ => ‘form-select’, ‘disabled’)) }}
• {{ Form::select(‘set’, $sets, $prod->set_id, array(‘class’ => ‘form-select’, ‘adddisabled’)) }}
• All of the above
4. Which of the following are correct for route definitions?
 Note: There may be more than one right answer.

Answers:

• Route::get(‘user/{name?}’)
• Route::get(‘user/{name}’)
• Route::get(‘{user}/name’)
• Route::get(‘user/?name}’)
5. To protect application from cross-site request forgery attacks, which of the following should be included in forms?

Answers:

• {{ secure }}
• {{ csrf_field() }}
• {{ protect() }}
• {{ csrf_protect() }}
6. Which of the following will list all routes?

Answers:

• php artisan route:all
• php artisan route:list
• php artisan route
• php artisan route —all
7. Which of the following validator methods returns ‘True’ when form data is valid?

Answers:

• fails()
• passes()
• valid()
• success()
8. Which of the following is correct to define middleware for multiple views in controller file?

Answers:

• public function __construct()
{
$this->middleware(‘admin’, [‘only’ => [‘create’, ‘edit’, ‘show’]]);
}
• public function __construct()
{
$this->middleware(‘admin’, [‘only’ => ‘create|edit|show’]);
}
• public function __construct()
{
$this->middleware(‘admin’, [‘only’ => ‘create’]);
}
• All of the above
9. Which of the following command should be used to run all outstanding migration?

Answers:

• php artisan migrate:migration_name
• php artisan migrate
• php artisan create:migration
• php artisan generate:migration
10. Which of the following is/are correct to define custom validation messages?
 Note: There may be more than one right answer.

Answers:

• Pass the custom messages as the third argument to the Validator::make method
• Specify your custom messages in a language file.
• Customize the error messages used by the form request by overriding the messages method.
11. Which of the following can be included in route definition to validate form data?

Answers:

• Validator::valid($formData, $rules);
• Validator::make($formData, $rules);
• Validate::make($formData, $rules);
• Validate::create($formData, $rules););
12. How access custom textbox name in Laravel using validation ‘unique’?

Answers:

• ‘admin_username’ => ‘required|min:5|max:15|unique:administrators,username’,
• ‘admin_username’ => ‘required|min:5|max:15|unique:administrators’,
• ‘admin_username’ => ‘requireds|min:5|max:15|unique:administrators’.username’,
• All of the above
13. The field under validation must be present in the input data and not empty. A field is considered «empty» if one of the following conditions are true:

Answers:

• The value is null.
• The value is an empty string.
• The value is an empty array or empty Countable object.
• The value is an uploaded file with no path.
• All of the above
14. To validate a date named finish_date against following rules:
 -Should be date
 -Required
 -Should be greater than start_date
 which of the following is correct validation rule?

Answers:

• ‘finish_date’ => ‘required|date|after|start_date’
• ‘finish_date’ => ‘required|date|>:start_date’
• ‘finish_date’ => ‘required|date|after:start_date’
• ‘finish_date’ => ‘required|date|greater:start_date’
15. If we have a following URL
 http://myapp.dev/?foo=bar&baz=boo
 Which of the following will get the values of ‘foo’ and ‘baz’?

Answers:

• Request::get(‘foo’, ‘baz’);
• Request::only([‘foo’, ‘baz’]);
• Request::except(‘foo’, ‘baz’);
16. Which of the following is correct syntax for passing data to views?
 Note: There may be more than one right answer.

Answers:

• return view(‘greetings’, [‘name’ => ‘Victoria’]);
• return view(‘greeting’)->with(‘user’, ‘Victoria’);
• return view(‘greeting’)->->withAll(compact(‘teams’))
17. Which of the following is a correct way to assign middleware ‘auth’ to a route?

Answers:

• Route::get(‘profile’, [
‘middleware’ => ‘auth’,
‘uses’ => ‘UserController@show’
]);
• Route::get(‘profile’, [
‘controller’ => ‘auth’,
‘uses’ => ‘UserController@show’
]);
• Route::get(‘profile’, [
‘secure’ => ‘auth’,
‘uses’ => ‘UserController@show’
]);
• Route::get(‘profile’, [
‘filter’ => ‘auth’,
‘uses’ => ‘UserController@show’
]);
18. Which of the following validation rule is correct to validate that the file is an image file having dimensions of min 200 height x min 400 width?

Answers:

• ‘avatar’ => ‘image:min_width=100,min_height=200’
• ‘avatar’ => ‘dimensions:min_width=100,min_height=200’
• ‘avatar’ => ‘file:image|dimensions:min_width=100,min_height=200’
• ‘avatar’ => ‘file:type=image,min_width=100,min_height=200’
19. Which of the following validation rules are acceptable?
 Note: There may be more than one right answer.

Answers:

• [‘field’ => ‘accepted’]
• [‘field’ => ‘active_url’]
• [‘field’ => ‘alpha’]
• [‘field’ => ‘after:10/10/16’]
20. If you don’t want Eloquent to automatically manage created_at and updated_at columns, which of the following will be correct?

Answers:

• Set the model $timestamps property to false
• Eloquent will always automatically manage created_at and updated_at columns
• Set the model $created_at and updated_at properties to false
21. Which of the following code is correct to insert multiple records?

Answers:

• public function store(Request $request)
{
$inputArrays = Getinput::allItem();
$schedule = new Schedule;
foreach ($inputArrays as $array) {
$student->name = $name;
$student->for_date = $date;
$student->save();
}
return view(‘students.index’);
}
• public function store(Request $request)
{
$inputArrays = Getinput::all();
$schedule = new Schedule;
foreach ($inputArrays as $array) {
$student->name = $name;
$student->for_date = $date;
$student->save();
}
return view(‘students.index’);
}
• public function store(Request $request)
{
$inputArrays = Input::all();
$schedule = new Schedule;
foreach ($inputArrays as $array) {
$student->name = $name;
$student->for_date = $date;
$student->save();
}
return view(‘students.index’);
}
• All of the above
22. Creating database view in migration laravel 5.2
 Note: There may be more than one right answer.

Answers:

• CREATE VIEW wones AS SELECT (name from leagues) AS name
join teams where (leagues.id = team.country_id)
join players where (teams.id = players.team_id)
join points where (players.id = points.player_id)
sum(points.remnants) AS trem
count(points.remnants where points.remnants < 4) AS crem
• CREATE VIEW wones AS
SELECT
leagues.name,
sum(points.remnants) AS trem
sum(IF(points.remnants<4, 1, 0)) AS crem
FROM leagues
JOIN teams ON (leagues.id = team.country_id)
JOIN players ON (teams.id = players.team_id)
JOIN points ON (players.id = points.player_id);
• DB::statement( ‘CREATE VIEW wones AS
SELECT
leagues.name as name,
sum(points.remnants) as trem,
count(case when points.remnants < 4 then 1 end) as crem
FROM leauges
JOIN teams ON (teams.league_id = leagues.id)
JOIN players ON (players.team_id = teams.id)
JOIN points ON (points.player_id = players.id);
‘ );
• All of the above
23. Which of the following is correct to create a route(s) to resource controller named «PostController»?

Answers:

• Route::resource(‘PostController’, ‘post’);
• Route::resource(‘post’, ‘PostController’);
• Route::get(‘post’, ‘PostController’);
• Route::post(‘post’, ‘PostController’);
24. Which of the following are correct to delete a model with primary key 2?
 Note: There may be more than one right answer.

Answers:

• $flight = App\Flight::find(2);
$flight->delete();
• $flight->delete(2);
• App\Flight::destroy(2);
25. Which of the following loops are available in blade?
 Note: There may be more than one right answer.

Answers:

• @for ($i = 0; $i < 10; $i++)
The current value is {{ $i }}
@endfor
• @foreach ($users as $user)
<p>This is user {{ $user->id }}</p>
@endforeach
• @forelse ($users as $user)
<li>{{ $user->name }}</li>
@empty
<p>No users</p>
@endforelse
• @while (true)
<p>I’m looping forever.</p>
@endwhile
26. ____ are an important part of any web-based application. They help control the flow of the application which allows us to receive input from our users and make decisions that affect the functionality of our applications.

Answers:

• Routing
• Module
• Views
• Forms
27. To define a single action controller for following route
 Route::get(‘user/{id}’, ‘ShowProfile’);
 which of the following is correct?

Answers:

• You may place a single __construct method on the controller
• You may place a single __invoke method on the controller
• You may place a single __create method on the controller
• You can not create single action controller in laravel
28. Which of the following HTML form actions are not supported?
 Note: There may be more than one right answer.

Answers:

• PUT
• POST
• DELETE
• PATCH
29. Which of the following is the correct way to set SQLite as database for unit testing?

Answers:

• ‘sqlite’ => [
‘driver’ => ‘sqlite’,
‘database’ => storage_path.’/database.sqlite’,
‘prefix’ => »,
],
• ‘sqlite’ => [
‘driver’ => ‘sqlite’,
‘database’ => storage_path(‘database.sqlite’),
‘prefix’ => »,
],
• ‘sqlite’ => [
‘driver’ => ‘sqlite’,
‘dtabase’ => storage_path().’/database.sqlite’,
‘prefix’ => »,
],
• All of the above
30. Validation If checkbox ticked then Input text is required?
 Note: There may be more than one right answer.

Answers:

• return [
‘has_login’ => ‘sometimes’,
‘pin’ => ‘required_with:has_login,on’,
];
• return [
‘has_login’ => ‘sometimes’,
‘pin’ => ‘required_if:has_login,on’,
];
• return [
‘has_login’ => ‘accepted’,
‘pin’ => ‘required’,
];
• All of the above
31. Which of the following methods can be used to register a route that responds to all HTTP verbs?

Answers:

• Route::any()
• Route::match()
• Route::all()
32. Which of the following is correct directory for view files?

Answers:

• app/views
• storage/views
• resources/views
• public/views
33. Which of the following is true to get the URL of an image ‘img/logo.png’ from route ‘/example’ ?

Answers:

• Route::get(‘example’, function () {
return URL::asset(‘img/logo.png’);
});
• Route::get(‘example’, function () {
return URL::assets(‘img/logo.png’);
});
• Route::get(‘example’, function () {
return URL::full(‘img/logo.png’);
});
34. How do you add default value to a select list in form.

Answers:

• Form::getselect(
‘myselect’,
$categories,
$myselectedcategories,
array(
‘class’ => ‘form-control’,
‘id’ => ‘myselect’
)
}}
• Form::getselect(
‘myselect’,
array_merge([» => [‘label’ => ‘Please Select’, ‘disabled’ => true], $categories),
$myselectedcategories,
array(
‘class’ => ‘form-control’,
‘id’ => ‘myselect’
)
}}
• Form::select(
‘myselect’,
array_merge([» => [‘label’ => ‘Please Select’, ‘disabled’ => true], $categories),
$myselectedcategories,
array(
‘class’ => ‘form-control’,
‘id’ => ‘myselect’
)
}}
• Form::select(
‘myselect’,
$categories,
$myselectedcategories,
array(
‘class’ => ‘form-control’,
‘id’ => ‘myselect’
)
}}
35. Which method can be used to create custom blade directives?

Answers:

• Blade::directive()
• Blade::custom()
• We can not create custom blade commands
36. To create a controller which handles all «CRUD» routes, which of the following is correct command?

Answers:

• php artisan make:controller CarController —all
• php artisan make:controller CarController —crud
• php artisan make:controller CarController
• php artisan make:controller CarController —resource
37. Which of the following is correct to pass $name variable to views?
 Note: There may be more than one right answer.

Answers:

• public function index() {
return view(‘welcome’)->with(‘name’, ‘Foo’);
}
• public function index() {
$name = ‘Foo’;
return view(‘welcome’)->withName($name);
}
• public function index() {
$name = ‘Foo’;
return view(‘welcome’, compact(‘name’));
}
38. Which of the following methods can be chained to get a single column from a database table?

Answers:

• ->name(‘title’);
• ->get(‘title’);
• ->column(‘title’);
• ->pluck(‘title’);
39. Which of the following methods should be used to alter the columns of an existing table?

Answers:

• Schema::alter()
• Schema::create()
• Schema::update()
• Schema::table()
40. Which of the following can be used in Schema::create() method? (check all that apply)
 Note: There may be more than one right answer.

Answers:

• $table->integer(‘id’);
• $table->string(‘username’);
• $table->primary(‘id’);
• $table->unique(‘username’);
41. Which of the following is correct in order to create a model named ‘Person’ with accompanying migration?

Answers:

• php laravel make:model Person -m
• php artisan make:model Person -m
• php artisan make:model Person
• php artisan create:model Person -m
42. Which method can be used to store items in cache permanently?

Answers:

• Cache::permanent(‘key’, ‘value’);
• Cache::add(‘key’, ‘value’);
• Cache::put(‘key’, ‘value’);
• Cache::forever(‘key’, ‘value’);
43. Which of the following artisan command is correct to create a model with table named ‘projects’?

Answers:

• php artisan make:model Project
• php artisan create:model Project -m
• php artisan create:table Project
• php artisan make:model Project -m
44. Which of the following is the correct way to retrieve soft deleted models?

Answers:

• $flights = App\Flight::withTrashed()->get();
• $flights = App\Flight::onlyTrashed()->get();
• $flights = App\Flight::onlyDeleted()->get();
• $flights = App\Flight::Trashed()->get();
45. Which of the following methods can be used to retrieve the record as an object containing the column names and the data stored in the record?

Answers:

• get()
• find()
• add()
• insert()
46. Which of the following static methods can be used with our models? (choose all that apply)
 Note: There may be more than one right answer.

Answers:

• ::find()
• ::destroy()
• ::all()
• ::show()
47. Which file contains the database configurations?

Answers:

• config/db.php
• public/database.php
• config/config.php
• config/database.php
48. Which of the following is the correct way to get all rows from the table named users?

Answers:

• DB::list(‘users’)->get();
• DB::table(‘users’);
DB::table(‘users’)->all();
• DB::table(‘users’)->get();
49. Which of the following is used to retrieve all blog posts that have at least one comment?

Answers:

• $posts = App\Post::has(‘comments’)->get();
• $posts = App\Post::find(‘comments’)->get();
• $posts = App\Post::find()->comments()->get();
50. The migrations directory contains PHP classes which allow Laravel to update the schema of your current____, or populate it with values while keeping all versions of the application in sync.

Answers:

• language
• config
• libraries
• database
51. Which of the following is correct to execute the below statement without error?
 $flight = App\User::create([‘name’ => ‘John Doe’]);

Answers:

• In model, set:
protected $fillable = [‘name’];
• In model, set:
protected $guarded = [‘name’];
• Above statement will execute without any error and will create a record in database.
52. Which of the following methods can be used with models to build relationships?
 Note: There may be more than one right answer.

Answers:

• belongsToMany()
• hasOne()
• hasMany()
• belongsTo()
53. Which of the following databases are supported by Laravel 5?
 Note: There may be more than one right answer.

Answers:

• PostgreSQL
• MySQL
• SQLite
• MongoDB
54. Eloquent can fire the following events allowing you to hook into various points in the model’s lifecycle. (choose all that apply)
 Note: There may be more than one right answer.

Answers:

• creating
• created
• updating
• restoring
55. Which method will retrieve the first result of the query in Laravel eloquent?

Answers:

• findOrPass(1);
• all(1);
• findOrFail(1);
• get(1);
56. Which of the following is correct to retrieve all comments that are associated with a single post (post_id = 1) with one to many relation in Model?

Answers:

• $comments = App\Post::comments->find(1);
• $comments = App\Post::find()->comments(1);
• $comments = App\Post::find(1)->comments;
57. Which of the following methods are provided by migration class?
 Note: There may be more than one right answer.

Answers:

• up()
• down()
• create()
• destroy()
58. Which of the following can be used to get only selected column from a database table?

Answers:

• $selected_vote = users_details::lists(‘selected_vote’);
• $selected_vote = users_details::all()->get(‘selected_vote’);
• $selected_vote = users_details::get([‘selected_vote’]);
• All of the above
59. Which of the following are correct route methods?
 Note: There may be more than one right answer.

Answers:

• Route::get($uri, $callback);
• Route::options($uri, $callback);
• Route::put($uri, $callback);
• Route::delete($uri, $callback);
60. Which of the following is the correct way to display unescaped data in blade?

Answers:

• Hello, { $name }.
• Hello, {! $name !}.
• Hello, {!! $name !!}.
• Hello, {{$name }}.
61. What will be the output of the following in view if $name = «Andy»?
 Welcome, {{ $name or ‘John’ }}

Answers:

• Welcome, Andy John
• Welcome, Andy or John
• Welcome, Andy
• Welcome, John
62. Which of the following is a shortcut for ternary statement in blade?

Answers:

• {{ isset($name) ? $name : ‘Default’ }}
• {{ $name or ‘Default’ }}
• {{ $name else ‘Default’ }}
• none
63. To define a callback when view is rendered we can use:

Answers:

• View::composer()
• View::callback()
• View::method()
• View::match()
64. Suppose we have a collection which contains the website news. What is the best way to share that collection in all views?

Answers:

• $news=NewsStory::orderBy(‘created_at’, ‘desc’)->paginate(5);
• view()->share(‘news’, NewsStory::orderBy(‘created_at’, ‘desc’)->paginate(5));
• view()->addShare(‘news’, NewsStory::orderBy(‘created_at’, ‘desc’)->paginate(5));
• All of the above
65. Which view facade within a service provider’s boot method can be used to share data with all views?

Answers:

• View::config(‘key’, ‘value’);
• View::put(‘key’, ‘value’);
• View::store(‘key’, ‘value’);
• View::share(‘key’, ‘value’);
66. Which of the following can be used to add images in a view? (choose all that apply)
 Note: There may be more than one right answer.

Answers:

<img src=»{{ URL::asset(‘img/myimage.png’) }}» alt=»a picture»/>
• {{ HTML::image(‘img/myimage.png’, ‘a picture’) }}
• include(app_path().»/../resources/views/fronthead.blade.php»);
• All of the above
67. Which of the following is executed first?

Answers:

• View::creator(‘profile’, ‘App\Http\ViewCreators\ProfileCreator’);
• View::composer(‘profile’, ‘App\Http\ViewCreators\ProfileCreator’);
68. Which of the following is true for Elixir and Gulp? (choose all that apply)
 Note: There may be more than one right answer.

Answers:

• Elixir is built on top of Gulp, so to run your Elixir tasks you only need to run the gulp
• The gulp watch command will continue running in your terminal and watch your assets for any changes.
• Adding the —production flag to the command will instruct Elixir to minify your CSS and JavaScript files
• None of the above
69. Which of the following variable is available inside your loops in blade?

Answers:

• $iterate
• $first
• $index
• $loop
70. Which of the following can be used in views to print a message if array is empty?

Answers:

• <ul>
@while ($names as $name)
<li>{{ $name }}</li>
@else
<li>Don’t have names to list.</li>
@endwhile
</ul>
• <ul>
@if ($names as $name)
<li>{{ $name }}</li>
@else
<li>Don’t have names to list.</li>
@endif
</ul>
• <ul>
@for ($names as $name)
<li>{{ $name }}</li>
@else
<li>Don’t have names to list.</li>
@endfor
</ul>
• <ul>
@forelse ($names as $name)
<li>{{ $name }}</li>
@empty
<li>Don’t have names to list.</li>
@endforelse
</ul>
71. Which one of the following is the last parameter for @each directive in blade?

Answers:

• Array or collection you wish to iterate over
• View partial to render for each element in the array or collection
• The view that will be rendered if the given array is empty
72. To reference a view
 view(‘user.profile’, $data);
 Which of the following is the correct name and path for view file?

Answers:

• resources/views/user/profile.php
• resources/views/admin/user.blade.php
• storage/views/admin/profile.blade.php
• resources/views/user/profile.blade.php
73. Which of the following is correct to loop over an array named $lists in view?

Answers:

• <ul>
@foreach ($lists as $list)
<li>{{ $list }}</li>
@endforeach
</ul>
• <ul>
{ foreach ($lists as $list) }
<li>{{ $list }}</li>
{ endforeach }
</ul>
• <ul>
@foreach ($list as $lists)
<li>{{ $list }}</li>
@endforeach
</ul>
• <ul>
@foreach ($lists as $list)
<li>{{ $list }}</li>
@end
</ul>
74. If you need to add additional routes to a resource controller beyond the default set of resource routes, you should define those routes after your call to Route::resource

Answers:

• True
• False
75. How do you upload an image to a form with many to many relationships?

Answers:

• $file = Request::file(‘resume’);
$extension = $file->getClientOriginalExtension();
Storage::disk(‘local’)->put($file->getFilename().’.’.$extension, File::get($file));
$resume = new Resume();
$resume->mime = $file->getClientMimeType();
$resume->filename = $file->getFilename().’.’.$extension;
$candidate=new Candidate();
$data=array_except($data, array(‘_token’,’resume’));
$user->candidate()->save($candidate);
$candidate->resume()->save($resume);
$candidate=$user->candidate($user);
$candidate->update($data);
• public function create()
{
$categories = Category::lists(‘name’, ‘id’);
$days = Day::lists(‘dayname’, ‘id’);
return view(‘articles.create’, compact(‘categories’, ‘days’));
}
public function store(ArticleRequest $request)
{
$image_name = $request->file(‘image’)->getClientOriginalName();
$request->file(‘image’)->move(base_path().’/public/images’, $image_name);
$article = ($request->except([‘image’]));
$article[‘image’] = $image_name;
Article::create($article);
}
• $file = Request::addfile(‘resume’);
$extension = $files->getClientOriginalExtension();
Storage::disk(‘local’)->put($file->getFilename().’.’.$extension, File::get($file));
$resume = new Resume();
$resume->mime = $file->getClientMimeType();
$resume->filename = $file->getFilename().’.’.$extension;
$candidate=new Candidate();
$data=array_except($data, array(‘_token’,’resume’));
$user->candidate()->save($candidate);
$candidate->resume()->save($resume);
$candidate=$user->candidate($user);
$candidate->update($data);
• All of the above
76. Which of the following is convenient and correct way to automatically inject the model instances directly into your routes?

Answers:

• Route::get(‘api/users/{user}’, function ($user) {
return $user->email;
});
• Route::get(‘users/{user}’, function (App\User $user) {
return $user->email;
});
• Route::get(‘users/{id}’, function (App\User $user) {
return $user->email;
});
77. Which of the following is required before using @section and @endsection in blade file?

Answers:

• @template
• @extends
• @require
• @include

Friday 30 June 2017

Upwork Test Answers | MS Excel Upwork Test Answers 2019

  1. Which of the following options are available for auto fill, when you release the mouse button after using AutoFill, Excel not only fills in the series but also displays the Auto Fill options button ?
  • Copy Cells
  • Fill Formatting Only
  1. In the case of synchronizing changes between Table and model, a linked table is a live connection between the range or named table that contains the data values, and the Data Model that powers the report, by default. The Data Model is updated automatically if changes occur in ___________ ?
  • Tables
  1. Which among following settings is the default macro security setting by?
  • Disable all macros with notification
  1. Information Rights Management (IRM) allows individuals and administrators to specify access permissions to documents, workbooks, and presentations. This helps present sensitive information from being printed, forwarded, or copied by unauthorized people. IRM cannot help with the following though:
  • Prevent content from being copied by using third-party screen capture programs.
  1. Which of the following are advantages of range names ?
  • Names are easier to remember than range coordinates.
  • Names don’t change when you move a range to another part of the worksheet.
  • Named ranges adjust automatically whenever you insert or delete rows or columns within the range.
  1. Which of the following formulas yields the address of the last cell in a range ?
  • ADDRESS(ROW(rng)+ROWS(rng)-1,COLUMN(rng)+COLUMNS(rng)-1)
  1. Some features work differently in Excel online as compared to the Excel desktop version. Which of the following is not true for Excel online?
  • Workbooks that have Information rights management(IRM) settings applied at the workbook level cannot be viewed in a browser window.
  1. In Excel, a data list, or database table, is a table of worksheet data that utilizes a special structure, a built-in Data from which allow the users to edit records in a data list. For smaller data lists, you can use the navigation keys as well the scroll bar of the data form to locate a record which requires editing. What type of commands can be used for locating a record if we want to make changes in it while using larger data lists?
  • Filter command
  1. Excel contains a conditional formatting present that highlights top/bottom values. However, using a formula instead provides more flexibility. If you have a series of data with high & low magnitude values and you want to format only N number of high magnitude values in the series of data, which of the following formulas is valid?
  • = A1<= MAX(data,N)
  1. What is the filename extension of Excel workbooks which are saved as ‘Excel Templates’?
  • .xltx
  1. By using names, you can make your formulas much easier to understand and maintain. You can define a name for a cell range, function, constant, or table. Names must be no more than 255 characters long. You can also use any single letter as a range name except the following ?
  • R
  • C
  1. A _________ is similar to a data bar in that it compares the relative values of cells in a range. Instead of bars in each cell, you see cell shading, where the shading color reflects the cell’s value.
  • color cell
  1. What are Information Functions in Excel?
  • ISFOMULA
  • SHEET
  • SHEETS
  1. If cell A2 has a full name (Firstname, Middle Initial and Lastname) like “Karen E. McRich” which of the following formulas will extract the lastname ?
  • =Right(a2,find(“.”,a2)-1,1)
  1. We can perform what If Analysis in Excel with the use of Data Tables in which we can see the effect of changing an input value on the result returned by a formula as soon as we enter a new input value in the cell that feeds into the formula.
    which types of Data Tables can we create to perform what- If Analysis in Excel?
  • One & Two Variable Data Tables
  1. The auto calculate feature in Excel does which of the following ?
  • Provides a quick way to view the result of an arithmetic operation on a range of cells.
  1. A Data Model integrates the tables, enabling extensive analysis using PivotTables ________ , ________
  • Power Pivot, Power View
  1. What could you do to stop the pivot table from losing the column width upon refreshing?
  • Format loss in a pivot table can be prevented simply by changing the pivot table options. under the “pivot Table Options” turn on the “Enable Preserve Formatting” and disable the “Auto Format” options.
  1. Select Home->Fill->Series. Excel displays the series dialog box. Which of the following represent the “Growth” type?
  • None of above
  1. Excel provides _______, which are labels applied to a single cell or to a range of cells.
  • Range Names
  1. An Excel workbook is a collection of?
  • Worksheets and charts
  1. Anytime when you return more than single cell, you should be using array formula. Array formulas are special formulas that work on an array of numbers and it will work effectively if you press the following keys combination?
  • Ctrl+shift+enter
  1. Which of the following formulas uses absolute references?
  • =$A$1*2
  • =D11 * $C$3
  1. In most cases the PivotTable loses the column width when it is refreshed. which of following options can be used when the PivotTable is refreshed, so as to not lose the width of column ?
  • Enabling Preserve formatting and disabling Auto Format in PivotTable Options
  1. Tables offer which of the following advantages?
  • All of the above
  1. Use_____ to visualize the relative values of cells in a range. In this case, however, Excel adds a particular icon to each cell in the range, and that icon tells you something about the cell’s value relative to the rest of the range?
  • Icon Sets
  1. All 2-D and 3-D charts have an x-axis known as the horizontal axis and a y-axis known as the vertical axis. Which of the following charts don’t have x-axis and y-axis?
  • Pie Chart
  1. To show the actual formula instead of Cell Values which of the following function    can be used?
  • FORMULATEXT(cell)
  1. A worksheet range can be defined as which of the following?
  • A Group of cells
  1. Which of the following formulas yields the work hours between dates on a custom schedule?
  • {=SUM(CHOOSE(WEEKDAY(ROW(INDIRECT(date1&”:”&date2))),1,2,3,4,5,6,7))}
  1. When you have many different PivotTables in one report, you can share a slicer that you created in one PivotTable with other PivotTables. Which of the following statements is not true?
  • Any changes that you make to a shared slicer are immediately reflected in all PivotTables that are connected to that slicer
  1. Which of the function listed will not work if you are looking for an exact value based on a right looking column?
  • VLOOKUP
  1. Which of the following can be accomplished by Creating Highlighted Cell Rules?
  • What are the top 10 values
  • Which cell values are above average, and which are below average ?
  • Which cells values are duplicate �  ? 
  1. Which of the following could be true when #NAME, error appears in an Excel cell?
  • You Spelled a function name incorrectly
  • you used a string value without surrounding it with quotation marks.
  1. DGET Database Function in Excel extracts a single value from a record in the data list that matches the criteria you specify. DGET Function return error value if no record matches the specified criteria or the match criteria is greater than the specified criteria.
  2. Which of the following error values is returned if multiple records are matched?
  • #NUM
  1. Which of the following depicts a correct range?
  • B1:B30
  1. Which of the following is/are array formulas?
  • =B12:B16*E12:E16
  • =SUM(B12:B16*E12:E16)

Wordpress Upwork Test Answers | WordPress Upwork Test Answers 2019

Q1.) select all the default taxonomies in wordpress.

Ans.)
1) category
2) post_tag
3) link_category
4) post_category

Q2.) which concept does wordpress uses to control user access to different features.

Ans.) Role

Q3.) Which of the following is a not default image size in WP?

Ans.) Small size

Q4.) What is the name of table in database which stores custom fields data?

Ans.) wp_postmeta

Q.5) What are WordPress hooks?

Ans.) group of plugins which control wordpress behavior

Q6.) How do you enable the network setup menu item(enable multisite) in wordpress?

Ans.) set WP_Allow_MULTISITE as true in wp_config.php

Q7.) how to style each list item background of the wordpress navigation separately.

Ans.)
nav li:nth-child(1).current-menu-item
{
background-color: red;
}
nav li:nth-child(2).current-menu-item
{
background-color: blue;
}
nav li:nth-child(3).current-menu-item
{
background-color: green;
}

Q8.)If you need to store information temporarily, which wordpress system would you use :

Ans.) Transients

Q9.) how do you enable debug mode in WP?

Ans.) By setting WP_DEBUG as true in WP-Config.php

Q10.) what can the contributer role do?

Ans.) Edit Posts

Q11.)�  Which constant is NOT recognized in wp-config.php?

Ans.) wp_HOME_URL

Q12.)�  Which wp global object is used to execute custom databse queries?

Ans.) $wpdb

Q13.)�  Which one of the following files is located in the root of your wordpress installation directory and contains your website’s setup details, such as database connection info?

Ans.)wp_config.php

Q14.) what is user Management?

Ans.) WP User Manager. Managing your members, creating front-end profiles and custom login and registration pages should be easy. You easily add custom userregistration, login and password recovery forms to your WordPress website.

Q15.) How you can create a static page with wordpress?

Ans.) to create a static page in wordpress………

Q16.) Is it possible to create posts programmatically?

Ans.) Yes,with wp_insert_post() function

Q17.) which of the following is the correct way to register shortcode?

Ans.)
function foobar_func( $atts )
{
return “foo and bar”;
}
dd_shortcode( ‘foobar’, ‘foobar_func’ );

Q18.) What is wordpress multisite?

Ans.) wp configuration features that supports multiple sites.

Q19.) Which of the following is not a default user role in wp?

Ans.) Blogger

Q20.) What does wp_rand() function?

Ans.) Generates a random number.

Q21.) Which of the following is not a wordpress role?

Ans.) System

Q22.) Which of the following is incorrect possible value for $show attribute of bloginfo($show) function?

Ans.) ‘homeurl’

Q23.) pick the correct default post types readily available to users or internally used by the wordpress installation.

Ans.)
1) post
2) page

Q24.) what is common to all these functions: next_post,previous_post,link_pages,the _author_url,wp_get_link?

Ans.) They are all deprecated.

Q25.) WordPress navigation menu without sub menu.

Ans.) wp_nav_menu( array( ‘theme_location’ => ‘primary’, ‘menu_class’ => ‘nav-menu’,’depth’ => 1) ) );

Share this:

Upwork Test Answers | PHP Upwork Test Answers 2019

  1. which MIME type needs to be used to send an attachment in mail ?
  •    multipart/mixed
  1. What is the output of  the following code ?
class Foo {private $foo;
protected $bar;
public $test;
public function  __construct()
{
$this->foo = 1;
$this->bar = 2;
$this ->test = 3;
}
}
print_r(   (array) new Foo );
  •   Array([Foofoo]=>1 [*bar]=>2[test]=>3)
  1. By default, every database connection opened by a script is either explicitly closed by the user during run time of released__________ at the end of the script.
  •  Server-side
  1. Which magic method is used to implement overloading in PHP ?
  •  __call
  1. What will be the output of following code ?
<?php   $i = 016;echo $i /2;
?>
  •   7
  1. Which of the following file modes is used to write into a file at the end of the existing content, and create the file if the file does not exist ?
  •  a
  1. Which of the following statements is incorrect with respect to inheritance in PHP?
  •  A Class can extend more than one class.
  1. You can extend the exception class, but you cannot override any of the preceding methods they are declared as :
  • final
  1. What is the correct syntax of mail() function in php ?
  •  mail($to,$subject,$message,$headers)
  1. What is the fastest way to insert an item $item into the specified position $position of the array $array ?
  •  array_merge() and array_slice()
  1. Which of the following MySQL fetch constants imply: if the columns are returned into the array having both a numerical index and the field name as the array index ?
  • Ans. MYSQL_BOTH
  1. Which function is used to get  the number of arguments passed to the function ?
  •  func_num_args()
  1. What is the output of the following code ?
<?phpfunction abc(){
return_FUNCTION_;
}
function xyz()
{
return abc();
}
echo xyz();
?>
  •  abc
  1. �  Which Function can be used to determine if a file exist? (choose all that apply)
  •    is_readable(),
file_exists(),
is_file_exists()
  1. What will be the output of following code
<?phpclass A {
public static function foo() {
static::who();
}
public static function who(){
echo __CLASS__.”\n”;
}
}
class B extends A {
public static function test(){
A::foo();
parent::foo();
self::foo();
}
public static function who() {
echo __CLASS__. “\n”;
}
}
Class C extends B {
public static function who(){
echo __CLASS__.”\n”;
}
}
C::test();
?>
  •  ACC
  1. Which of the following will print out the PHP call stack ?
  •   $e=new Exception;
var_dump($e->getTraceAsString())
  1. What is the correct way to send an SMTP(Simple Mail Transfer Protocol) email using PHP?
  •  sendmail($EmailAddress,”Subject”,”$MessageBody);
  1. The PDO_MYSQL Data Source Name(DSN) is composed of the following elements ?
  • dbname
unix_socket
charset
  1. Which is true about the curl_setopt() API ?
  •  It sets one option for cURL transfer
  1. What will be the output of the following PHP code ?
<?php$var=300;
$int options  = array(“options”=>array(“min_range”=>0,”max_range”=>256));
if(!filter_var($var,FILTER_VALIDATE_INT, $int_options))
echo(“Integer is not valid”);
else
echo(“Integer is valid”);
?>
  • Integer is not valid
  1. Which function is used to read a file removing the HTML and PHP tags in it ?
  • fgetss()
  1. What will the output of following code :-
<?phpclass BaseClass {
public function test() {
echo “BaseClass::test() called\n”;
}
final public function moreTesting() {
echo “BaseClass::moreTesting() called \n”;
}
}
class ChildClass extends BaseClass {
public function moretesting(){
echo “ChildClass::moreTesting() called\n”;
}
}
$obj = new ChildClass;
$obj->moreTesting();
?>
  • Results in Fatal error : Cannot override final method
BaseClass::moreTesting();
  1. What will happen if a fatal error was thrown in your PHP program ?
  • The PHP program will stop executing at the point where the error
occured.
  1. Which of the following code can be used to send email to multiple recipients ?
  • $recipients = array(‘recipient1@domain.com’,’receipient2@domain.com);
mail($recipients,$subject,$messege,$headers);
  1. Which of the following functions belong to Exception class ? (Choose all that apply)
  •    getLine()
getTraceAsString();
  1. Which of the following are valid MySQLi Configuration options ? (Choose all that apply ?
  •    mysqli.allow_persistent
mysqli.default_port
mysqli.default_socket
  1. Which is the best approach to parse HTML and extract structured information from it ?
  •  Use an XML parser (as simpleXML) and XPath queries if available.
  1. What is the output of the following code ?
<?phpfunction y($v) {
echo $v;
}
$w = “y”;
$w (“z”);
$w = “x”;
?>
  •  z
  1. Xdebug is a PHP____________, the information which Xdebug provides is about stack and functions with full parameter for user defined functions, memory allocation and support for infinite recursions.
  •  Extension
  1. See the example class code below
class ExampleClass{
public $val = 5 ;
function &getValNum()
{
return $this->val;
}
}
which of the following one can be used for Return by reference ?
  •   $obj = new ExampleClass();
$myVal = $obj->getValNum();
  1. What is the output of following code ?
function myFun($a) {if(!$a){
throw new Exception(‘Value init.’);
}
return 3/$a;
}
try {
echo myfun(3) .”\n”;
}catch (Exception $e){
echo ‘Caught exception: ‘, $e->getMessage(), “\n”;
} finally {
echo “first\n”;
}
try{
echo myFun(1).”\n”;
} catch (Exception $e) {
echo ‘Caught exeption:’, $e->getMessage(),”\n”;
}  finally {
echo “second\n”;
}
echo “Hello PHP Example\n”;
  •  1 first 3 second Hello PHP Example
  1. What is true about ini_set(‘memory_limit’,’-1’) ?
  • parse error
  1. what is the correct way to read-in multiple values from an array ?
  •  list($x,$y,$z) = array(7,8,9);
  1. What is the best practice for running MySQL queries in PHP? Consider the risk of SQL injection ?
  •  Use PDO prepared statements and parameterized queries
  1. Which of the following is the right MIME to use as a Contant Type for JSON data ?
  • application/json
  1. Which of the following is the correct way to convert a variable from a string to an integer ?
  •  $number_variable = (int)$string_variable;
  1. There are a number of mysqlnd plugins already available. These include
  •  PECL/mysqlnd_pscache – Prepared Statement Handle Cache plugin
PECL/mysqlnd_sip – SQL Injection Protection Plugin
PECL /mysqlnd_uh – User Handler Plugin
PECL/mysqlnd_qc – Query Cache Plugin
  1. What will be the  output of executing the following code ?
  •  Fata error : Call to private method Foo:: printName() from context
  1. When designing classes with UML, a class at its core has the following components ? (choose all that apply)
  •  Methods, Attributes
  1. Which of the following would show an error in php ?
  •  @echo 1
  1. What would be the output of the following code ?
$str = “0011110000bsts11100”;echo trim($str,’010s’);
  •  bst
  1. What would be the output of the I and II sample codes:
I)$a  = array();
$b = $a;
$b[‘foo’] = 42;
echo $a[‘foo’];
II)
$a = new StdClass();
$b = $a;
$b->foo = 42;
echo $a->foo;
  •  Null 42
  1. Which of the following is not a Super Global variable in PHP ?
  •  None of the above
  1. Which of the following would produce an error :
$currentDT = new DateTime();
  •  $currentDT->getTimezone(new DateTimeZone(‘UTC’));
  1. Which statement is incorrect ?
  •  unset() forces the PHP garbage collector to immediately.
  1. which of the following is not related to garbage collection in PHP ?
  • gc_cycles()
  1. which statement is not correct ?
  2. $x = null;
  • empty($x) return TRUE
  1. What would be the output of the following code ?
  2. $parts = parse_url(“https://example.com/test/1234?testing&val&id=1&&=23&row=4”);
    parse_str($parts[‘query’],$query);
    echo count($query);
  • 4
  1. Which of the following is not the correct way to create an empty object in PHP ?
  • $obj = new stdClass();
  1. Which function is used to destroy a variable or object ?
  • unset()
  1. What will be the output of the following code ?
  2. $arr = array(“THEY”,”WE”,array(“I”,”YOU”),”YOUR”);
    echo(count($arr,1));
  • 6
  1. Which statement is not correct ?
  • PHP_EOL – The correct ‘End of Line’ symbol for this platform.
  1. Which method is used to tweak an oject’s cloning behavior ?
  • clone()
  1. How do you access result set meta data ?

<?php
$mysqli = new mysqli(“example.com”, “user”, “password”, “database”);
if ($mysqli->connect_errno) {
echo “Failed to connect to MySQL: (” . $mysqli->connect_errno . “) ” . $mysqli->connect_error;
}

$res = $mysqli->query(“SELECT 1 AS _one, ‘Hello’ AS _two FROM DUAL”);
var_dump($res->fetch_fields());
?>
  1. Which of the following will decode a JSON variable $json to an object ?
  2. $json = ‘{“abc”:1,”def”:2,”ghi”:3,”jkl”:4,”mno”:5}’;
  • both of above ($object = json_decode($json); and $object = json_decode($json,true);)
  1. Choose the correct option to force redirect from http to https :
  • RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  1. What will be the output of executing the following code ?
  2. <?php
    class Foo {
    private function printName($name) {
    print_r($name);
    }
    }
    $a = new Foo();
    $a->printName(‘James’);
    ?>
  • Fatal error: Call to private method Foo::printName() from context…
  1. What will be the output of the below code ?
  2. $tmp = “Dragon%%Ball%%z%”;
    $arr = explode(‘%’,trim($tmp));
    echo count($arr);
  • 6
  1. Which of the following options will fall to remove the element “y” when placed in the blank space in the below sample code
  2. $row = array(0=>”x”,1=>”y”,2=>”z”,3=>”w”)
    print_r($row)
  • array_diff($row,[“y”]);

  1. Which of the following is the correct option to get a numerically indexed array containing all defined timezone identifiers in PHP

  • DateTimeZone::listIdentifiers(DateTimeZone::UTC);

  1. What will be the output of the following code ?
  2. echo(1234==’1234 test’ ? ‘Equal’ : ‘Not equal’);
  • Equal
  1. After the following query is executed using PHP, which function can be used to count the number of rows returned ?(choose all that apply)
  2. SELECT * from students
  • mysqli_affected_rows()
mysqli_numrows()