Monday, 30 November 2015

AngularJS Interview Questions and Answers for Experienced

AngularJS Interview Questions and Answers for Experienced



Question: What is AngularJS?
It is javasScript framework which is written in javascript. It is Best for Single Page Applications. It extend the html with new attributes which makes it more useful for UI Developer.


Question: In which language, AngularJS is written?
javaScript


Question: When First AngularJS was released?
2009

Question: When latest AngularJS was released?
November 24, 2017


Question: What is latest version of AngularJS?
1.6.7


Question: Who created AngularJS?
Misko Hevery started to work on AngularJS in 2009. He was employee of Google.
Question: Is it opensource?
Yes, It is free to use.



Question: Explain what are the key features of Angular.js?
  1. Scope
  2. Controller
  3. Model
  4. View
  5. Services
  6. Data Binding
  7. Directives
  8. Filters
  9. Testable



Question: From where we can download the AngularJS File?
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>



Question: What is controller in AngularJS?
Controller is constructor function in Angular Controller.
When a Controller is attached to the DOM with use the ng-controller, Angular will instantiate a new Controller object using constructor function.



Question: Explain what are directives?
Directives are used to add new attributes of HTML.



Question: What are the different types of Directive?
Different types of directives are
  1. Element directives
  2. Attribute directives
  3. CSS class directives
  4. Comment directives



Question: Explain what is injector?
An injector is a service locator, used to retrieve object instances.



Question: Explain what are factory method in angularJs?
Factory method are used to create the directive. It is invoked only once, when compiler matches the directive for the first time.



Question: Does Angular use the jQuery library?
Ans. Yes, Angular can use jQuery if you have included the jQuery library.
IF Not, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.



Question: What is ng-app, ng-init and ng-model?
ng-app - To initialize the Angular Application.
ng-init - To initialize the Angular Application data.
ng-model - To bind the html tags (input, select, textarea) to Angular Application Data.



Question: What is Data Binding in Angular JS?
It is synchronization of data between the model(Angular Application variable) and view components (display with {{}}).



Question: Give an Example of Data-Binding in AngularJS?
<div ng-app="" ng-init="quantity=10;cost=5">
<b>Total Cost: {{ quantity * cost }}</b>
</div>


Question: What is Looping in AngularJs and Give an Example?
It is used to display the data in loop same as foreach in PHP
Example:
<div data-ng-app="" data-ng-init="names=['Web','Technology','Experts','Notes']">
<b>Loop Example:</b>
  <br />
<ul>
<li data-ng-repeat="x in names">
      {{ x }}
    </li>
</ul>
</div>

Question: How to Write Expression in AngularJS?
<div ng-app="">
<b>Expression: {{ 15 + 55 }}</b>
</div>



Question: How to initiate variable in AngularJS?
<div ng-app="" ng-init="quantity=10;cost=5">
<b>Total Cost: {{ quantity * cost }}</b>
</div>


OR

<div ng-app="" ng-init="quantity=1;cost=5">
<b>Total Cost: <span ng-bind="quantity * cost"></span></b>
</div>



Question: Example of AngularJS Strings?
<div ng-app="" ng-init="Str1='Web';Str2='Technology'">
Full String is : <b>{{ Str1 + " " + Str2 }}</b>
</div>




Question: Example of AngularJS Object?
<div ng-app="" ng-init="myobj={Str1:'Web',Str2:'Technology'}">
String Display: <b>{{ myobj.Str2 }}</b></div>



Question: What is Angular Controllers & give an Example?
Controller is constructor function in Angular Controller.
When a Controller is attached to the DOM with use the ng-controller, Angular will instantiate a new Controller object using constructor function.
Example:
<div ng-app="" ng-controller="StrControllerExample">
String 1: <input ng-model="str1" type="text" /><br />
String 2: <input ng-model="str2" type="text" /><br />
Full String <b> {{fullString()}}</b>
</div>
<script>
function StrControllerExample($scope) {
    $scope.str1 = "Web",
    $scope.str2 = "Technology",
    $scope.fullString = function() {
        return $scope.str1+ " " + $scope.str2;
    }
}
</script>




Question: What is Dependency Injection?
Dependency Injection (DI) is a software design pattern that deals with how components get deal of their dependencies.


MongoDB Database Commands with Examples

mongoDB Database Commands with Examples

Question: Expalin the Basic terminology for MongoDB?
RDBMS MongoDB
Database Database
Table Collection
Tuple/Row Document
column Field
Table Join Embedded Documents
Primary Key Primary Key (Default key _id provided by mongodb itself)
Mysqld/Oracle mongod
mysql/sqlplus mongo

Note: # used for commenting.

Question: Create a New database?
use mydb #switched to db mydb



Question: Check which database you are currently using?
use



Question: Display the List of databases?
show dbs #All database will display which have atleast 1 document.



Question: Delete the current database?
db.dropDatabase() #Delete the current used database.



Question: How to create collection for a database?
db.createCollection("mycollection") #create a collection for current selected database.



Question: Display the List of collections in database?
show collections #All collection will display for current database.



Question: How to drop the collection?
db.mycollection.drop() #mycollection collection will be deleted.



Question: How to delete all the records from mongodb ?
db.collection.remove();



Question: How to delete all the records with condition?
db.collection.remove({uid=111});

Will delete all the record where uid=1111


Question: How to insert data(Know as document) into collection?
db.mycollection.insert({
   _id: ObjectId(7df78ad89765),
   title: 'MongoDB Overview',    
   by: 'Web technology',   
   tags: ['mongodb', 'database', 'NoSQL'],   
})
#Single document is added in collection "mycollection" .



Question: How to add multiple document into collection in single command?
db.mycollection.insert({
   {   
   title: 'MongoDB Overview',    
   by: 'Web technology',   
   tags: ['mongodb', 'database', 'NoSQL'],   
   },
 
   {
   title: 'MongoDB Overview2',    
   by: 'Web technology experts notes',   
   tags: ['mongodb', 'database', 'NoSQL' ,'Multiple Record'],   
       
   }
])



Question: What is command for search a document? Give Example?
find() is used to search. For Example

db.mycollection.find()#Search the one document in un structured way .



Question: How to search a document in pretty way (structured way) ? Give Example?
pretty() is used to search in pretty way. For Example

db.mycollection.find({"by":"Web technology"}).pretty()#Search the one document in structured way .



Question: How to search a document with "and condition"?
db.mycollection.find({"by":"Web technology",{"title": "MongoDB Overview"}}).pretty()#Search the one document in structured way .



Question: How to list first 10 document?
db.mycollection.find({"by":"Web technology",{"title": "MongoDB Overview"}}).limit(10).pretty()#Search the 10 document in structured way .



Question: How to get 2nd document?
db.mycollection.find({"by":"Web technology",{"title": "MongoDB Overview"}}).limit(1).skip(1).pretty()#Search the 10 document in structured way .



Question: How to list document with title ascending order?
db.mycollection.find({"by":"Web technology",{"title": "MongoDB Overview"}}).sort({"title":1}).pretty()#Search the in title ascending order.



Question: How to search document in title descending order?
db.mycollection.find({"by":"Web technology",{"title": "MongoDB Overview"}}).sort({"title":-1}).pretty()#Search the in title descending order. 



Question: How to Add indexing?
db.mycollection.ensureIndex({"title":1,"description":-1})#title in ascending order and description in descending order.To create index in descending order you need to use -1. 



Question: How to search a document with "OR condition"?
db.mycollection.find({"by":"Web technology",$or[{"title": "MongoDB Overview"}]}).pretty()#Search the one document in structured way .



Question: How to update a document?
db.mycollection.update({'title':'MongoDB Overview'},{$set:{'title':'MongoDB text'}})#update "MongoDB Overview" with "MongoDB text " .



Question: How to delete a document?
db.mycollection.remove({'title':'MongoDB Overview'})#Delete the record where document is 'MongoDB Overview' .




Find all records
db.mycollection.find();
Display all the records in this collection.



Find all records and display in pretty way
db.mycollection.find().pretty();
Display all the records in this collection but presentable way.



Find all records with single condition (Age: 29)
db.mycollection.find({age:29});
Display all the records where age=29.



Find all records with multiple AND condition (Age: 29, Number:17)
db.mycollection.find({age:29, number:17});
Display all the records where age=29 and number=17



Find all records with multiple OR condition (Age: 29 OR Number:17)
db.mycollection.find({$or:[{age:29},{number:17}]});
Display all the records where age=29 OR number=17 (each of one).



Find all records with multiple OR condition (Age>28 OR Number:17)
db.mycollection.find({$or:[{age:{$gt:28}},{number:17}]});
Display all the records where age>29 and number=17



Find all records and display and one display column (name)
db.mycollection.find({},{name:1}).pretty();
Display all the name in this collections.



Find all records and display and two display column (name and number)
db.mycollection.find({},{name:1,number:1}).pretty();
Display all the name and number in this collections.



Limit the number of record
db.mycollection.find().limit(3).pretty();
Display only 3 records.



Display all the records except 1,2,3
db.mycollection.find().skip(3).pretty();
Skip first 3 records.