Java-Script

Question 1

Consider the JavaScript Code :

var y = "12";
function f() 
{
      var y = "6";
      alert (this.y);
      function g() 
      {
           alert (y); 
      }
      g();
} 
f();

If M is the number of alert dialog boxes generated by this JavaScript code and D1, D2, ...., DM represents the content displayed in each of the M dialog boxes, then : 

A
M=3; D1 displays ”12”; D2 displays ”6”; D3 displays ”12”.
B
M=3; D1 displays ”6”; D2 displays ”12”; D3 displays ”6”.
C
M=2; D1 displays ”6”; D2 displays ”12”.
D
M=2; D1 displays ”12”; D2 displays ”6”.
       Web-Technologies       Java-Script       UGC-NET CS 2018 JUNE Paper-2
Question 1 Explanation: 
The JavaScript this keyword refers to the object it belongs to.
It has different values depending on where it is used:
• In a method, this refers to the owner object.
• Alone, this refers to the global object.
• In a function, this refers to the global object.
• In an event, this refers to the element that received the event.
• Methods like call(), and apply() can refer this to any object.
• There are two alert boxes in the javascript code. So two messages will be displayed.
• First message, alert(this.y) here this.y is global variable whose value is 12. So first message is “12”.
• Second message is alert(y) , here “y” local variable and value is 6 so second message displays value “6”
Question 2
Earlier name of java programming language was:
A
OAK
B
D
C
Netbean
D
Eclipse
       Web-Technologies       Java-Script       Nielit Scientist-B IT 4-12-2016
Question 2 Explanation: 
Oak is a discontinued programming language created by James Gosling in 1991, initially for Sun Micro systems' set-top box project. The language later evolved to become Java.
Question 3
Which of the following is a platform free language?
A
Java
B
C
C
Assembly
D
Fortran
       Web-Technologies       Java-Script       Nielit Scientist-B IT 4-12-2016
Question 3 Explanation: 
  • Sun released the Java HotSpot virtual machine and compiler as free software under the GNU General Public License on November 13, 2006, with a promise that the rest of the JDK (that includes the JRE) would be placed under the GPL by March 2007 ("except for a few components that Sun does not have the right to publish in distributable source form under the GPL").

  • Java code is platform independent in the sense that the same Java application or algorithms (typically compiled to Java bytecode and packaged in a .jar file) will run identically on Windows and Linux.
  • Question 4
    The correct syntax to write “Hi there” in Javascript is
    A
    jscript.write (“Hi There”);
    B
    document.write (“Hi There”);
    C
    print (“Hi There”);
    D
    print.jscript (“Hi There”);
           Web-Technologies       Java-Script       ISRO CS 2015       Video-Explanation
    Question 4 Explanation: 
    JavaScript can "display" data in different ways:
    Writing into an HTML element, using innerHTML.
    Writing into the HTML output using document.write().
    Writing into an alert box, using window.alert().
    Writing into the browser console, using console.log().
    There are 4 questions to complete.

    Access quiz wise question and answers by becoming as a solutions adda PRO SUBSCRIBER with Ad-Free content

    Register Now

    If you have registered and made your payment please contact solutionsadda.in@gmail.com to get access