Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post help with questions i failed to answer !

    Following are questions i failed to answer ! plz suggest solutions.

    thanks,
    Andrea


    Question:1
    Which of the following statements can you use to reload a page? [MULTIPLE CHOICE]


    a. location.reload();
    b. location.href = location.href;
    c. location.refresh();
    d. Page cannot be reloaded.


    Question:2
    Which of the following functions can you use to test whether an object was created with a specific constructor or not?


    a. instanceof
    b. typeof
    c. classof
    d. classname


    Question:3
    Which of the following ways can you use to prevent default action when a user clicks on a link on any browser?


    a. Use preventDefault method of event object on click event handler.
    b. Set returnValue of event object to false on click event handler.
    c. Return false value on click event handler.
    d. There is no way to prevent default action.











    Question:4
    Consider the following code snippet:

    if (document.addEventListener){
    alert("addEventListener");
    } else if (document.attachEvent){
    alert("attachEvent");
    }
    What does the alert box display on Internet Explorer?


    a. addEventLister
    b. attachEvent
    c. There is no alert box
    d. This code snippet is invalid


    Question:5
    What is the result of c in the following code snippet?

    var a = '1';
    b = 2 * a;
    c = typeof(b);


    a. char
    b. string
    c. number
    d. None of the above


    Question:6
    screen.pixelDepth is not available in Internet Explorer 7.


    a. True
    b. False







    Question:7
    Which of the following functions can be used to stop an event from propagating if you're using a W3C-compliant browser?


    a. stopPropagation
    b. endPropagation
    c. finishPropagation
    d. There are no such methods


    Question:8
    Which of the following is a good reason to avoid user agent sniffing?


    a. User can change the user agent.
    b. user agent is the same for all browsers.
    c. Some browsers do not have user agent.
    d. There is no reason to avoid user agent sniffing.


    Question:9
    What is the value of c in the following code snippet?

    var a = {f: 1};
    var b = a;
    b.f = 100;
    var c = a.f;


    a. undefined
    b. null
    c. 1
    d. 100

    Question:10
    What does the following statement do?

    document.title = "JavaScript";


    a. It changes the title of the current window to "JavaScript" but does not change the text of the title tag.
    b. It changes the text of «title» tag to "JavaScript".
    c. It changes the global title variable value to "JavaScript".
    d. This statement is invalid.


    Question:11
    one way to add functions to an object is by ___.


    a. adding functions to that object prototype.
    b. declaring a new function with that object name as prefix.
    c. There is no way to add functions to an existing object.

    Question:12
    Which of the following properties contains user agent string of web browser?


    a. window.navigator.userAgent
    b. document.Agent
    c. window.User_Agent
    d. window.clientType


    Question:13
    Assume that the document has the following tag:

    «div id="id1"»
    «div id="id11"»
    JavaScript
    «/div»
    «/div»

    What do you see after the following code snippet is executed?

    var a = document.findElementById("id1");
    document.body.appendChild(a.cloneNode(false));


    a. A "JavaScript" text is appended on the document.
    b. There is no change.
    c. This code snippet is invalid.




    Question:14
    Consider the code snippet given below:

    function a() {}
    function b() {}

    Which of the following statements makes "a" object inherit from "b" object?


    a. a.prototype = new b();
    b. a.prototype = b;
    c. a.extend(b);
    d. a.extend(new b());


    Question:15
    Which of the following ways can you use to verify that a browser supports document.getElementsByTagName function?


    a. if (document.getElementsByTagName)
    b. if (typeof(getElementsByTagName) == "function") {
    c. It is not possible to verify document.getElementsByTagName function


    Question:16
    What is the value of c in the following code snippet?

    function a() {}
    var b = a();
    var c = typeof(b);


    a. undefined
    b. a
    c. function
    d. object







    Question:17
    Consider the following code snippet:

    var a = document.getElementById("id1");
    a.onclick = function1;
    a.onclick = function2;

    Which function will be executed if a user clicks on id1 element?


    a. function1
    b. function2
    c. both
    d. none


    Question:18
    You can edit CSS rule using CSS Rule object on Firefox and rules object on Internet Explorer.


    a. True
    b. False

    Question:19
    What is the value of c in the following code snippet?

    function a() {}
    a.prototype.version = "1.8";
    var b = new a();
    var c = b.prototype.version;


    a. undefined
    b. null
    c. 1.8
    d. This code snippet causes an error







    Question:20
    In the W3C model, if you attach an anonymous function as an event handler of an element using addEventListener, how can you remove that anonymous function?


    a. By adding a named function as event hander, then using removeEventListener to remove it.
    b. By passing null argument to removeEventListener.
    c. The anonymous function cannot be removed.


    Question:21
    Which of the following method can you use to convert JSON data in responseText to JavaScript object?


    a. eval
    b. parseJSON
    c. convertToObject
    d. toJSON


    Question:22
    What is the result of c in the following code snippet?

    function a(name) {this.name = name;}
    var b = new a();
    var c = typeof(b.name);


    a. undefined
    b. null
    c. string
    d. object










    Question:23
    Consider the code snippet given below:

    var a = {a1: 1, a2: 2};
    var b = 0;
    for (i in a) {
    b += a[i];
    }

    Which of the following statements is(are) true?


    a. b == 0
    b. b == 1
    c. b == 2
    d. b » 2


    Question:24
    Which of the following XMLHttpRequest properties do you use to assign callback function to handle response to your request?


    a. onreadystatechange
    b. readystate
    c. responseText
    d. response

    Question:25
    Create the XMLHttpRequest is the same in all Internet Explorer browser versions.


    a. True
    b. False










    Question:26
    What is the value of b in the following code snippet?

    function a(){}
    var b = typeof(a.prototype);


    a. undefined
    b. null
    c. a
    d. object


    Question:27
    What does the following code snippet do?

    var a = document.getElementById('id1');
    a.onclick = function1();


    a. It executes function1 and returns its value to onclick attribute of id1 tag.
    b. It attaches function1 as click handler to id1 tag.
    c. This code snippet is invalid.


    Question:28
    What is the result of the following code snippet?

    function a() {alert(x);}
    function b() {var x = "function b"; a();}
    b();


    a. An alert box pops up showing "undefined".
    b. An alert box pops up showing "null".
    c. An alert box pops up showing "function b".
    d. This code snippet causes an error.







    Question:29
    What is the result of a in the following code snippet?

    function f(a, b, c){return true;}
    var a = f.length;


    a. undefined
    b. null
    c. 3
    d. This code snippet is invalid


    Question:30
    If you define function b() nested inside function a(), b() will be able to access variables in its own scope and function a() scope.


    a. True
    b. False


    Question:31
    Which of the following regular expression methods can you use to check whether there exists a pattern within the given string or not?


    a. check
    b. match
    c. test
    d. There are no such methods.


    Question:32
    What is the difference between location.replace() function and change location.href property?


    a. location.replace does not create an entry in history, whereas location.href does.
    b. location.replace creates an entry in history, whereas location.href does not.
    c. There is no difference.

    Question:33
    What is the result of c in the following code snippet?

    var a;
    function b(){
    var b = "b";
    a = function(){
    return b;
    }
    }
    b();
    c = a();


    a. undefined
    b. null
    c. b
    d. This code snippet is invalid.


    Question:34
    What is the result of the following comparison?

    null == null


    a. true
    b. false
    c. undefined
    d. This statement is invalid.


    Question:35
    What does the function typeof with an hash array parameter return?


    a. array
    b. string
    c. number
    d. object




    Question:36
    Which of the following values are false in equal comparison (==)? [MULTIPLE]


    a. null
    b. undefined
    c. ""
    d. 0


    Question:37
    Which of the following code snippet can you use to load CSS files dynamically?


    a. var headTag = document.getElementsByTagName("head")[0];
    var linkTag = document.createElement('link');
    linkTag.type = 'text/css';
    linkTag.rel = 'stylesheet';
    linkTag.href = 'main.css';
    linkTag.media = 'screen';
    headTag.appendChild(linkTag);
    b. var headTag = document.getElementsByTagName("head");
    var linkTag = document.createElement('link');
    linkTag.type = 'text/css';
    linkTag.rel = 'stylesheet';
    linkTag.href = 'main.css';
    linkTag.media = 'screen';
    headTag.appendChild(linkTag);
    c. var headTag = document.getElementsByTagName("head")[0];
    var linkTag = document.createElement('css');
    linkTag.rel = 'stylesheet';
    linkTag.href = 'main.css';
    headTag.appendChild(linkTag);
    d. It is not possible to load CSS files dynamically.










    Question:38
    What is the result of the following code snippet?

    var a = {f: 'object'};
    var b = {f: 'object'};
    var c = a == b;


    a. true
    b. false
    c. null
    d. This code snippet is invalid


    Question:39
    Assume that the header has the following code snippet:

    «script»
    var a = document.getElementById("id1");
    alert(a);
    «/script»

    What's wrong with this code snippet?


    a. At the time this code snippet is executed, the element with id1 does not exist.
    b. The function getElementById is not document's function.
    c. It cannot alert a DOM element.
    d. There is nothing wrong with the given code snippet.


    Question:40
    What does the following statement return?

    document.body.previousSibling;


    a. undefined
    b. null
    c. <head>
    d. <body>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,035
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    Please have a look at forum Rule 1.5. It is not really in your best interests that others do your all or most homework for you. Your teacher may gain a false and
    exaggerated idea of your programming capabilities and so not offer you the support you need. Also, if you hand in other people's work which you do not completely understand, then you will start to fall behind and your difficulties will increase.


    It is your responsibility to die() if necessary….. - PHP Manual

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    Please have a look at forum Rule 1.5. It is not really in your best interests that others do your all or most homework for you. Your teacher may gain a false and
    exaggerated idea of your programming capabilities and so not offer you the support you need. Also, if you hand in other people's work which you do not completely understand, then you will start to fall behind and your difficulties will increase.


    It is your responsibility to die() if necessary….. - PHP Manual
    Its not homework. i need to see the right answers. Had it been a test, why would i get a copy of question paper! Test is over. Now i am free to find the answers. I hope it does not bend any rules !!

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,035
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    Tell us what you think the answers are, and someone will then advise you whether or not they are correct.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    jmania (07-21-2012)

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Posts
    456
    Thanks
    0
    Thanked 20 Times in 20 Posts
    At a glance, some of these are bogus word plays. And as far as the 'typeOf' method goes there's a group trying to get Javascript creators to do away with it and replace it with the 'toType()'. I can't find my original link in my bookmarks but here's another one.Introducing the toType function.
    NO Limits!! DHCreationStation.com
    ------------------------------------------------------------
    Broken items wanted for tinkerin'! PostItNow@BrokenEquipment.com
    Global Complaint Dept.

  • #6
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    My answers!

    1 a,b
    2 b
    3 a
    4 b
    5 c
    6 a
    7 a
    8 a
    9 d
    10 a
    11 a
    12 a
    13 a
    14 a
    15 a
    16 a
    17
    18 a
    19 d
    20 b
    21 a
    22 a
    23 d
    24 a
    25 b
    26 d
    27
    28
    29 c
    30 b
    31 b
    32 a
    33 c
    34 a
    35 d
    36 c
    37 b
    38 b
    39
    40 c

    if possible give explanation for answers!

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,602
    Thanks
    78
    Thanked 4,387 Times in 4,352 Posts
    This one is bogus:
    Question:3
    Which of the following ways can you use to prevent default action when a user clicks on a link on any browser?

    a. Use preventDefault method of event object on click event handler.
    b. Set returnValue of event object to false on click event handler.
    c. Return false value on click event handler.
    d. There is no way to prevent default action.
    *IF* the browser user has JavaScript turned off, or *IF* the browser doesn't support JavaScript, then D is the right answer.

    If JavaScript is supported and enabled then C is the right answer. Or, rather, C would be the right answer if it was written correctly. None of A, B, C are written as proper English. But we can at least guess what that actual meanings are.

    But the question, as given, cannot be answered as a multiple choice question.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #8
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,969
    Thanks
    56
    Thanked 557 Times in 554 Posts
    considering that you PM'd me asking for suggestions (as I assume you did everybody else mildly active on the board), I would suggest that you run the code snippets that you can (from what i can tell about half of those questions can be answered simply by running the code given) and ask specific questions about the topics that genuinely confuse you.

    you will be very lucky if somebody here goes to the effort of answering 40 homework questions, with explanations, but I guess there is something to be said for optimism...

  • #9
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    Hi

    help with questions I failed to answer !

    From post#6
    You failed to answer 4 questions

    17
    27
    28
    39

    Therefore, I think it would have been prudent to to post those
    questions.


    But if you are expecting someone to go through 40 questions
    and give a detailed explanation of the rights and wrongs
    relating to the correct answer then I doubt anyone will do that here.

    May I refer you to your teacher since that is exactly what teachers
    get paid for.

    LT
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,602
    Thanks
    78
    Thanked 4,387 Times in 4,352 Posts
    Quote Originally Posted by xelawho View Post
    considering that you PM'd me asking for suggestions (as I assume you did everybody else mildly active on the board),
    Yep. My only answer is the one above.

    And I don't believe her/him about this being a quiz that is already done. I think it is Monday's homework.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #11
    New to the CF scene
    Join Date
    Jul 2012
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I posted it more than a week back ! so those who think its monday homework can help later.

    You can answer it and make it a sticky note. every one can then use it to test their skill ! or you can give link to related study material /book etc where hints for answer can be found.

  • #12
    New Coder
    Join Date
    Jan 2011
    Posts
    52
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by jmania View Post
    Question:40
    What does the following statement return?

    document.body.previousSibling;


    a. undefined
    b. null
    c. <head>
    d. <body>
    The answer to that question is variable and browser-dependent, therefore the question needs to be withdrawn or revised.
    For I.E. normally the answer will be <HEAD>, but in other browsers it is likely to be a text node, unless there is no newline between </head> and <body>

  • #13
    New Coder
    Join Date
    Jan 2011
    Posts
    52
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Question:35
    What does the function typeof with an hash array parameter return?
    Tell your teacher that typeof is an operator, not a function. Ditto instanceof.
    Last edited by Calvert Tripesi; 07-25-2012 at 02:25 PM.

  • #14
    New Coder
    Join Date
    Jan 2011
    Posts
    52
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by Old Pedant View Post
    This one is bogus:

    If JavaScript is supported and enabled then C is the right answer. Or, rather, C would be the right answer if it was written correctly. None of A, B, C are written as proper English. But we can at least guess what that actual meanings are.
    It is further ambiguous in that the answer varies according to how the handler was installed. If addEventListener is used, return false has no effect.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •