Skip to main content

Posts

PHP Traits - Multiple Choice Questions

PHP Traits - Multiple Choice Questions A PHP trait is a partial class implementation (i.e. constants, properties and methods) that can be mixed into one or more existing PHP classes. Traits work double duty: they say what a class can do (like an interface), and they provide a modular implementation (like a class). [Modern PHP: New Features and Good Practices By Josh Lockhart] Try below quiz questions and check your knowledge on PHP Traits . 1) We use . . . . . keyword to declare a trait and . . . . keyword is used in order to include it in a class. A) Declare, Use B) Initiate, Include C) Trait, Use D) none of above 2) We can use above trait in any of the class as: A) class Welcomeclass{ use Trait Welcome; } B) class Welcomeclass{ use Welcome: } C) class Welcomeclass{ use Welcome; } D) class Welcomeclass{ use=> Welcome; } 3) Methods declared in a class using a trait take precedence over methods declared in the trait. However, methods in a trait will override method...

Past Participle Exercises - Set 2

Past Participle Exercises - Set 2 Past participle is generally formed by adding 'ed' or 'd' to the base form of a verb and is the same as the past tense form of the verb. For example the past participle of 'back' is 'backed'. Some irregular verbs have past participles that are not formed by adding 'ed' or 'd' and may not be the same as the past tense form of the verb. The past participle of 'see' is 'seen'. Complete the below sentences using past participles. 1) Ricky had already . . . . . . the traffic rules by crossing the red lights. (broke,broken) 2) Nina had . . . . . . all of her coke before her dinner arrived. (drank, drunk) 3) The oysters were . . . . . in the sand now, covered by a few inches of sea water. (sank, sunk) 4) Garry had . . . . . . his son to work a couple of times. (bring, brought) 5) The red company has always . . . . . . its employees on Fridays. (pay, paid) 6) I felt awful as I had . ....

Angular 4 Pipes Multiple Choice Questions with Answers

Angular 4 Pipes Multiple Choice Questions with Answers Pipes transform displayed values within a template. A pipe takes in data as input and transforms it to a desired output. [ via ] Practice your Angular 4 Pipes skills by answering below Angular 4 Pipes multiple choice questions with answers. 1) Just like filters in AngularJS, pipes are intended to encapsulate all the data transformation logic. A) True B) False 2) Using SlicePipe, answer below question: var = "abcdefghijk"; {{var | slice:3:-3}} A) defghi B) defgh C) kjih D) abc 3) The Angular pipes differ in functionality from simple case changing to date and internationalisation, but most importantly, you can't write your own pipes. A) True B) False 4) The number pipe is location sensitive, which means that the same format argument will produce differently formatted results based on the . . . . . . . A) user's format setting B) user's currency setting C) user's locale setting D) all of ab...

Participle exercises with answers - Set 1

Participle exercises with answers - Set 1 Participle is a word formed from a verb (for example going, gone, being, been) and used as an adjective (for example working woman, burnt toast) or a noun (for example good breeding). In English language participles are also used to make compound verb forms (e.g. is going, has been). [ Via ] Present participle is formed by adding ing to the base form of a verb. If the verb ends with the letter g, l, m, n, p or t (with a short vowel sound before it), this letter is doubled, for example: dig - digging, swim - swimming etc. If the verb ends with the letter e, this letter is dropped, for example come - coming, have - having etc. If the verb ends with the letters ie, these letters are changed to y, for example die - dying, tie - tying etc. [Source: English Grammar And Exercises 3, Book 4 by Chapman L.R.H.] Complete the following sentences using present participle : 1) The sisters fell asleep after . . . . . . a sumptuous meal. (eat) 2) D...

PHP Constructors Multiple Choice Questions

PHP Constructors Multiple Choice Questions 1) PHP recognises constructors by the name . . . . . A) _construct B) __construct C) __constructor D) _constructor 2) In . . . . . constructors, it is important to remember that you have to call the parent constructor explicitly. A) Singleton B) secure C) public D) subclass 3) Constructor and destructor methods have no . . . . . . and are called automatically - they cannot be called explicitly and consequently their declarations need no access specifier. A) parameters B) destructor C) return value D) aproval 4) Unlike constructors, you cannot pass information to a destructor, because you are never sure when its going to be run. A) True B) False 5) You can invoke class constructors that don’t have any relation to the instantiated object by simply prefacing _constructor with the class name like A) classname::__construct() B) classname:__construct() C) classname=>__construct() D) classname->__construct() 6) . . . . . . is...

PHP Namespaces Multiple Choice Questions

PHP Namespaces Multiple Choice Questions 1. With the introduction of namespaces, the same function name can be used in multiple places. A) True B) False 2. Within a namespace, for accessing the built-in PHP classes you can prefix the class name with a . . . . . and let PHP look in the global class list. A) percent B) ampersand C) asterix D) backslash 3. Which of the below namespace declaration is correct? A) namespace ORA: B) namespace 1_RA; C) namespace ORA; D) namespace ORA_#; 4. Multiple namespaces cannot be defined in the same file. A) True B) False 5. As the namespace size grows, using namespaces can become a little repetitious, but PHP also provides the . . . . . statement, which allows you to alias a specific namespace. A) php B) grant C) use D) label 6. If you want to use this class from another namespace, which of the following statement or statements is correct: A) echo MyApp\Accountant\Addition::asCurrency(200); B) echo MyApp\Accountant\Addition...

Adverbs Exercises with Answers - Set 4

Adverbs Exercises with Answers - Set 4 It is quite easy to locate an Adverb as adverbs answer one of the several questions to a verb. These questions are: when? where? how? how much? As an example, sometimes people say, "You did good", but good is an adjective; the adverb is well , so you should say, "You did well." Complete the below sentences with adverbs. 1. Jasmine cooks . . . . . . (terrible / terribly) 2. Our professor, Mr Smith, . . . . . . . late for the lessons. (never / be) 3. She is a good dancer. She dances really . . . . . . . . (good, well) 4. Saarvi runs fast, but Ananya runs . . . . . . Saarvi. (fast) (hint: its a comparative adverb) 5. Peter did . . . . . in the school. (good, well) 6. Peter did . . . . . work in the school. (good, well) 7. Catherine is happy. She smiles . . . . . . . . (happy) 8. My best friend is a . . . . . . driver. She drives . . . . . . . . (careless, carelessly) 9. Our army must strike . . . . . ...