0

programming languages Online Quiz - 23

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

How to include mxml file?

  1. In Application tag

  2. In Script tag

  3. We can use either a or b

  4. None of the above


Correct Option: A

Flex Application requires Adobe Flash Player

  1. True

  2. False


Correct Option: A
  1. bubbling-target-capturing

  2. target-bubbling-capturing

  3. capturing-target-bubbling

  4. Can't say


Correct Option: C
  1. mxml file

  2. swf file

  3. as file

  4. Don't know


Correct Option: B

2.Which two languages are used in Flex?

  1. Java & C

  2. mxml & as

  3. C & C

  4. java & javascript.


Correct Option: B

How to include mxml file?

  1. In Application tag

  2. In Script tag

  3. We can use either a or b

  4. None of the above


Correct Option: A
  1. bubbling-target-capturing

  2. target-bubbling-capturing

  3. capturing-target-bubbling

  4. Can't say


Correct Option: C

xml version =“1.0” encoding=”utf-8” ?> which tags are not mandatory for mxml file

  1. ?

  2. xml=”version”

  3. encode=”utf-8”

  4. None of the above


Correct Option: C
  1. mxml file

  2. swf file

  3. as file

  4. Don't know


Correct Option: B

What is the output for the below code ? import java.io.Console; public class Test { public static void main(String... args) { Console con = System.console(); boolean auth = false; if (con != null) { int count = 0; do { String uname = con.readLine(null); char[] pwd = con.readPassword("Enter %s's password: ", uname); con.writer().write("\n\n"); } while (!auth && ++count < 3); } } }

  1. NullPointerException

  2. It works properly

  3. Compile Error : No readPassword() method in Console class

  4. null


Correct Option: A

AI Explanation

To answer this question, let's go through the code step by step:

  1. The code imports the java.io.Console class, which provides methods for reading input from the console.
  2. The Test class is defined with a main method.
  3. Inside the main method, a Console object con is created using System.console().
  4. A boolean variable auth is initialized as false.
  5. The code checks if the con object is not null.
  6. Inside the if statement, an integer variable count is initialized as 0.
  7. The code enters a do-while loop.
  8. Inside the loop, the code prompts the user to enter a username using con.readLine(null).
  9. It then prompts the user to enter a password using con.readPassword("Enter %s's password: ", uname). Note that %s is used as a placeholder for the username.
  10. After reading the password, the code writes two new lines using con.writer().write("\n\n").
  11. The loop continues as long as auth is false and count is less than 3.
  12. Finally, the program ends.

Now, let's analyze the options:

Option A) NullPointerException - This option is correct. The reason is that the System.console() method can return null if the application is not run from the command line or if the console is not available. Therefore, if con is null, trying to invoke methods on it, such as readLine() and readPassword(), will result in a NullPointerException.

Option B) It works properly - This option is incorrect. As explained above, if con is null, invoking methods on it will cause a NullPointerException.

Option C) Compile Error: No readPassword() method in Console class - This option is incorrect. The Console class does have a readPassword() method.

Option D) null - This option is incorrect. The code does not output anything directly. It may throw a NullPointerException, but it does not output null explicitly.

The correct answer is A) NullPointerException because if con is null, invoking methods on it will result in a NullPointerException.

interface I{ final class C1 { //1 static int i=9;; //2 } } class C2 implements I{ public static void main(String a[]){ System.out.println(I.C1.i); ///3 }}

  1. compile time error at line 1

  2. compile time error at line 2

  3. compile time error at line 3

  4. prints 9

  5. Runtime exception


Correct Option: D

AI Explanation

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

Option A) compile time error at line 1 - This option is incorrect. There is no compile-time error at line 1. The class declaration of C1 inside the interface I is valid.

Option B) compile time error at line 2 - This option is incorrect. There is no compile-time error at line 2. The declaration of the static variable i inside the inner class C1 is valid.

Option C) compile time error at line 3 - This option is incorrect. There is no compile-time error at line 3. The statement System.out.println(I.C1.i); is accessing the static variable i from the inner class C1 and is valid.

Option D) prints 9 - This option is correct. The output of the given code will be 9. The statement System.out.println(I.C1.i); prints the value of the static variable i from the inner class C1, which is 9.

Option E) Runtime exception - This option is incorrect. There will be no runtime exception in this code. The code will compile and execute without any exceptions.

The correct answer is D. This option is correct because the code will print the value 9.

- Hide questions