Interview Question in Javascript


 

Interview Question :: What's the difference between JavaScript and Java?

 What's the difference between JavaScript and Java?

by ksk
VoteNowAnswers to "What's the difference between JavaScript and Java?"
JavaScript is an object-oriented scripting language that allows you to create dynamic HTML pages, allowing you to process/validate input data and maintain data, usually within the browser. Originally created by Netscape for use with their Navigator browser, Microsoft reverse engineered the technology, added their own varients and defined JScript. Due to differences, both were more formally turned into the ECMA-262 standard and renamed EcmaScript, though nobody really refers to it by that name. 
 
On the other hand, "Java" is a programming language, core set of libraries, and virtual machine platform that allows you to create compiled programs that run on nearly every platform, without distribution of source code in its raw form or recompilation.
 

While the two share part of their names in common, they are really two completely different programming languages/models/platforms. Yes, they can communicate with each other through technologies like LiveScript. However, you should really consider them as two completely separate technologies. 

by ksk
The main difference between these two computer languages is that javascript functions within the web browser while java functions outside of the browser, using its own specific file types. Don't let this distinction confuse you, though. The latest versions of the browsers have java runtime engines built into them so that java applets can play within the browser window, similarly to how a plug-in works. But even though a web browser can run a java applet within its window, it doesn't hold all of the code for the applet in the HTML page, the way that a javascript works. A java applet only includes bits of code within the HTML source to call functions and libraries that reside outside of the HTML source. Conversely, all of the javascript code is contained in the HTML of the page where the javascript executes.

 

What this distinction means to web page designers is this: javascripts function much more quickly than java applets. 

by ksk

 There's a world of difference between the two. Javascript is used for front-end web development while Java can only be used as a back-end language within a web environment. Java doesn't need a web browser to compile and execute like Javascript does. Java is compiled prior to runtime while Javascript is compiled at runtime. The syntax/reserved-words are also different. There's many more differences if you go and do some research on the two languages. 





Following are some points which differentiates java & javascript 




  1. Java follows strong type checking where as Javascript is very flexible in datatype(loosly typed). Supports types which represents boolean,int,string 




    • Ex : Variables in Java is declared as datatype <varname>; --> int num




    • But in Javascript variable declaration will be as var <varname>; --> var myName;





  2. Javascript support function declarations, but without accessibility specifiers,parameter datatype,return type




  • Javascript : function fcnName(str)





........function body.......... 







  • Java : public int functionName(int no)



 



..........function body......... 

by ksk