0

programming languages Online Quiz - 9

Description: programming languages Online Quiz - 9
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Which is true about an anonymous inner class?

  1. It can extend exactly one class and implement exactly one interface.

  2. It can extend exactly one class and can implement multiple interfaces.

  3. It can extend exactly one class or implement exactly one interface.

  4. It can implement multiple interfaces regardless of whether it also extends a class.


Correct Option: C
class Boo {
    Boo(String s) {}
    Boo() {}
}
class Bar extends Boo {
    Bar() {}
    Bar(String s) {
        super(s);
    }
    void zoo() { 
         // insert code here      
    }  
}

which one create an anonymous inner class from within class Bar?

  1. Boo f = new Boo(24) { };

  2. Boo f = new Bar() { };

  3. Bar f = new Boo(String s) { };

  4. Boo f = new Boo.Bar(String s) { };


Correct Option: B

Which is true about a method-local inner class?

  1. It must be marked final.

  2. It can be marked abstract.

  3. It can be marked public.

  4. It can be marked static.


Correct Option: B

Which constructs an anonymous inner class instance?

  1. Runnable r = new Runnable() { };

  2. Runnable r = new Runnable(public void run() { });

  3. Runnable r = new Runnable { public void run(){}};

  4. System.out.println(new Runnable() {public void run() { }});


Correct Option: D
public class MyOuter {
    public static class MyInner {
        public static void foo() {}
    }
}

which statement, if placed in a class other than MyOuter or MyInner, instantiates an instance of the nested class?

  1. MyOuter.MyInner m = new MyOuter.MyInner();

  2. MyOuter.MyInner mi = new MyInner();

  3. MyOuter m = new MyOuter(); MyOuter.MyInner mi = m.new MyOuter.MyInner();

  4. MyInner mi = new MyOuter.MyInner();


Correct Option: A

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) MyOuter.MyInner m = new MyOuter.MyInner(); This option is correct because it instantiates an instance of the nested class MyInner by using the fully qualified name MyOuter.MyInner.

Option B) MyOuter.MyInner mi = new MyInner(); This option is incorrect because it tries to instantiate an instance of the nested class MyInner without using the fully qualified name MyOuter.MyInner. Since this statement is placed in a class other than MyOuter or MyInner, the nested class cannot be accessed directly without using the outer class name.

Option C) MyOuter m = new MyOuter(); MyOuter.MyInner mi = m.new MyOuter.MyInner(); This option is incorrect because it creates an instance of the outer class MyOuter. It then tries to create an instance of the nested class using the new keyword and the outer class name MyOuter, but this is not the correct syntax to instantiate a static nested class.

Option D) MyInner mi = new MyOuter.MyInner(); This option is incorrect because it tries to instantiate the nested class MyInner using the outer class name MyOuter, which is not the correct syntax for accessing a static nested class. Additionally, since this statement is placed in a class other than MyOuter or MyInner, the nested class cannot be accessed directly without using the outer class name.

The correct answer is A. This option instantiates an instance of the nested class MyInner by using the fully qualified name MyOuter.MyInner.

Which of these is /are SYNON relations?

  1. defined as

  2. refers

  3. owned by

  4. defined by

  5. includes

  6. has


Correct Option: A,C,E,F

Which is not a file to field relation

  1. known as

  2. has

  3. qualified by

  4. includes

  5. refers to

  6. qualified as


Correct Option: A,D,E,F

Which is not a file to file relation

  1. defined as

  2. refers

  3. owned by

  4. includes

  5. extended by

  6. known by


Correct Option: B,F

Which is a non-keyed access path

  1. Physical

  2. Update

  3. Resequence

  4. Retrieval

  5. Span

  6. Query


Correct Option: A

How many types of access paths are there in SYNON

  1. 6

  2. 5

  3. 7

  4. 8

  5. 4

  6. 9


Correct Option: A

What is the output of the below JavaScript?
alert(Math.sqrt(-16));

  1. -4

  2. 4

  3. Error

  4. NaN


Correct Option: D

What is the output of the below JavaScript?


with(Math){               
     alert(pow(2,3));       
}   
  1. 8

  2. 9

  3. error

  4. 6


Correct Option: A

What is the output of the below JavaScript?


alert(parseInt("8.56") + " " + parseInt("8error"));     
  1. Error

  2. 98

  3. 88

  4. 16


Correct Option: C

What is the output of the below JavaScript?
alert(parseFloat("8.56"));

  1. 8.56

  2. 9

  3. error

  4. NaN


Correct Option: A

What is the output of the below JavaScript?


    var currDate = new Date("30 September, 2011");
    alert(currDate.getMonth());
  1. 9

  2. 8

  3. 10

  4. error


Correct Option: B

function Book(id, name) {
    this.id = id;
    this.name = name;
}
var book = new Book("1001", "Head First JavaScript");
alert(book.id);
  1. 1001

  2. error

  3. Head First JavaScript

  4. id


Correct Option: A

What is the output of the below JavaScript?


var book = "Head First JavaScript";         
alert(book.length);     
  1. 21

  2. 20

  3. 22

  4. error


Correct Option: A

a = 10;         
var b = 20;         
var c = a + b;          
alert(c);   
  1. error

  2. 1020

  3. 30

  4. 20


Correct Option: C

var personObj = new Object();       
personObj.firstname = "Jerome";         
personObj.lastname = "Davin";       
alert(personObj.firstname);     
  1. Jerome

  2. Davin

  3. error

  4. firstname


Correct Option: A

What is the output of the below JavaScript?


var personObj = {firstname:"Jerome",lastname:"Davin"};          
alert(personObj.lastname);      
  1. Davin

  2. Jerome

  3. error

  4. lastname


Correct Option: A
- Hide questions