Showing posts with label interview. Show all posts
Showing posts with label interview. Show all posts

Thursday, 6 June 2013

Frequently asked PhoneGap/Cordova interview questions

When we talk about PhoneGap/Hybrid mobile app development, it is most probable that the interviewer may also ask about JavaScript, Dojo, jQuery, HTML5, CSS, Sencha, JSON and so on. Be prepared. Below are some questions which I came across -

1. What is PhoneGap and why ?
PhoneGap is a mobile application framework that allows developers to use HTML, JavaScript and CSS to create mobile apps that are present as first-class applications on the phone. That means the mobile apps have their own icons and operate similarly to native applications without a browser frame around them.

They have access to a set of native functions to further make them work like native apps.

Mobile developers use PhoneGap because it allows them to have a common codebase for all their application code. It doesn’t force developers to write code from scratch every time they move from platform to platform.

2. PhoneGap architecture.
PhoneGap has a plugin-based architecture. Each device-specific feature is a plugin, which consists of javascript and native sides. Js side should be as cross-platform as possible, whereas native side can be implemented only once, for 1 device. Nevertheless built-in plugins are developed for all of the most popular platforms, so no need to reinvent the wheel.
This architecture, together with open source code, not only allows a developer to fix their bugs, but also allows them to tweak their plugins for as per requirements. Also, a developer can build his own plugin, and support any platform of his choice.

3. What is the difference between PhoneGap and Cordova?
PhoneGap is a distribution of Apache Cordova. You can think of Apache Cordova as the engine that powers PhoneGap, similar to how WebKit is the engine that powers Chrome or Safari.

4. What is PhoneGap Build, and how is it different from PhoneGap framework?
PhoneGap is a mobile application development framework, based upon the open source Apache Cordova project. It allows you to write an app once with HTML, CSS and JavaScript, and then deploy it to a wide range of mobile devices without losing the features of a native app. PhoneGap Build is a cloud-based service built on top of the PhoneGap framework. It allows you to easily build those same mobile apps in the cloud.

5. What is a Plist file in iOS development ?
Yes, this is not related to phonegap, but interviewer expects the answer!

Property lists are a way of structuring arbitrary data and accessing it at run-time. An information property list is a specialized type of property list that contains configuration data for a bundle. The keys and values in the file describe the various behaviors and configuration options you want applied to your bundle. Xcode typically creates an information property list file for any bundle-based projects automatically and configures an initial set of keys and values with appropriate default values. You can edit the file to add any keys and values that are appropriate for your project or change the default values of existing keys.

For further details click here.

6. What is the difference between ChildBrowser and InAppBrowser in PhoneGap ?
As the name suggests, Child Browser Plugin is a plugin and can be integrated in any phonegap application.

Whereas, InAppBrowser is a phonegap API that provides the ability to spawn a browser instance from a Cordova(2.3.0) application. The API is based on standard browser capability. In a nutshell, this has the same functionality as the ChildBrowser, and has events support as well.
Example usage:
var ref = window.open('http://google.com', '_blank');
ref.addEventListener('loadstart', function(event) { alert(event.type + ' - ' + event.url); } );
ref.addEventListener('loadstop', function(event) { alert(event.type + ' - ' + event.url); } );
ref.addEventListener('exit', function(event) { alert(event.type); } );

// also, you can do ref.removeEventListener('loadstart', myfunc) .. etc

7. What are CDNs in jQuery? Why do we use it?
CDNs(Content Delivery Networks) can offer a performance benefit by hosting jQuery on servers spread across the globe.
There are three CDNs available that host the jQuery library free of charge:
  1. Google’s Libraries API CDN (a.k.a. Google Ajax API CDN)
  2. Microsoft’s Ajax CDN
  3. Media Temple’s ProCDN (the official “jQuery CDN”)
Using jQuery's CDN provided by MediaTemple
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

There are several benefits to using CDNs:
  • The file will normally load faster than it would if self hosted.
  • Odds are better that the site visitor will have a cached copy of the file since other sites will also be linking to the same file.
  • It saves the site owner some bandwidth since the file is externally hosted.
8. Name PhoneGap events
  • deviceready
  • pause
  • resume
  • online
  • offline
  • backbutton
  • batterycritical
  • batterylow
  • batterystatus
  • menubutton
  • searchbutton
  • startcallbutton
  • endcallbutton
  • volumedownbutton
  • volumeupbutton
More details here



References:
http://docs.phonegap.com/
http://phonegap.com/about/faq/
https://cordova.apache.org/




Wednesday, 29 May 2013

Commonly asked JavaScript interview questions

1. What is the difference between == and === in javascript ?
The 3 equal signs mean "equality without type coercion". Using the triple equals, the values must be equal in type as well.
0==false   // true
0===false  // false, because they are of a different type
1=="1"     // true, auto type coercion
1==="1"    // false, because they are of a different type

Null and Undefined types are == (but not ===). [i.e. Null==Undefined (but not Null===Undefined)]

2. null vs undefined in Javascript ?
In JavaScript, undefined means a variable has been declared but has not yet been assigned a value, such as:

var TestVar;
alert(TestVar); //shows undefined
alert(typeof TestVar); //shows undefined
null is an assignment value. It can be assigned to a variable as a representation of no value:

var TestVar = null;
alert(TestVar); //shows null
alert(typeof TestVar); //shows object

From the preceding examples, it is clear that undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object.

3. What are global variables and how are they declared? Also, explain problems using globals?
Global variables are available throughout your code: that is, the variables have no scope. Local variables scope, on the other hand, is restricted to where it is declared (ex-within a function). The var keyword is used to declare a local variable, while omitting the var keyword creates a global variable.

// Declare a local variable
var localVariable = "TechRepublic"
// Declare a global
globalVariable = "NewDelhi"

Most JavaScript developers avoid globals. One reason why is they’re averse to naming conflicts between local and globals, Also, code that depends on globals can be difficult to maintain and test.

4. How do you handle errors in JavaScript?
Exceptions that occur at runtime can be handled via try/catch/finally blocks. This can avoid unfriendly error messages. The finally block is optional and execution is transferred to the catch block of code when/if runtime errors occur. When the try/catch block is finally done, code execution transfers to the finally code block. This is the same way it works in other languages like C# and Java.

try {
// do something
} catch (e) {
// do something with the exception
} finally {
// This code block always executes whether there is an exception or not.
}

5. The onerror Event Handler
JavaScript 1.1 allowed a new event handler named "onerror". This Event Handler allows you to have something happen when the page throws an error.
The onerror event can only be defined inside your JavaScript code as a property of the window object:

<script type="text/javascript">
window.onerror=function(){
 //code to run when error has occured on page
}
</script>

6. Write a 1-line JavaScript code that concatenates all strings passed into a function?
The following function should help achieve the desired result

function concatenate() {
return String.prototype.concat.apply('', arguments);
}

7. What are windows object and navigator object in JavaScript?
The window object represents an open window in a browser.
Windows object is top level object in Java script and contains several other objects such as, document, history, location, name, menu bar etc., in itself. It is the global object for Java script that is written at client-side. For more details, click here.

The navigator object contains information about the browser.
navigator.appName - Gives the name of the browser
navigator.appVersion - Gives the browser version
navigator.appCodeName - Gives the browser codename
navigator.platform - Gives the platform on which the browser is running
For more details, click here.

8. Difference between window.onload and onDocumentReady?
The onload event does not fire until every last piece of the page is loaded, this includes css and images, which means there’s a huge delay before any code is executed.
If you just want to wait until the DOM is loaded and is able to be manipulated. onDocumentReady allows you to do that.


Friday, 28 December 2012

Commonly asked database Q&A

What is the difference between a “where” clause and a “having” clause?
“Where” is a kind of restriction statement. You use where clause to restrict all the data from DB.Where clause is using before result retrieving. But Having clause is using after retrieving the data.Having clause is a kind of filtering command.

What is bit data type and what’s the information that can be stored inside a bit column?
Bit data type is used to store Boolean information like 1 or 0 (true or false). Until SQL Server 6.5 bit data type could hold either a 1 or 0 and there was no support for NULL. But from SQL Server 7.0 onwards, bit data type can represent a third state, which is NULL.

What’s the difference between DELETE TABLE and TRUNCATE TABLE commands?
DELETE TABLE is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow. TRUNCATE TABLE also deletes all the rows in a table, but it will not log the deletion of each row, instead it logs the de-allocation of the data pages of the table, which makes it faster. Of course, TRUNCATE TABLE can be rolled back.

 What is de-normalization and when would you go for it?
As the name indicates, de-normalization is the reverse process of normalization. It is the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced.

What is a “constraint”?
A constraint allows you to apply simple referential integrity checks to a table. There are four primary types of constraints that are currently supported by SQL Server:
PRIMARY/UNIQUE – enforces uniqueness of a particular table column.
DEFAULT – specifies a default value for a column in case an insert operation does not provide one.
FOREIGN KEY – validates that every value in a column exists in a column of another table.
NOT NULL – constraint which does not allow values in the specific column to be null. And also, it is the only constraint which is not a table level constraint.

What’s the difference between a primary key and a unique key?
Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a non-clustered index by default. Another major difference is that, primary key does not allow NULLs, but unique key allows one NULL only.

What is a “functional dependency”? How does it relate to database table design?
Functional dependency relates to how one object depends upon the other in the database. for example, procedure/function sp2 may be called by procedure sp1. Then we say that sp1 has functional dependency on sp2.

Why can a “group by” or “order by” clause expensive to process?
Processing of “group by” or “order by” clause often requires creation of Temporary tables to process the results of the query, which depending of the result set can be very expensive.

Source - GeekyFry