0

programming languages Online Quiz - 241

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

Which of the elements defined within the taglib element of taglib descriptor file are required. Select the two correct answers.

  1. tlib-version

  2. short-name

  3. uri

  4. display-name


Correct Option: A,B
Explanation:

To solve this question, the user needs to know the structure of the taglib descriptor file (also known as the TLD file) used in JavaServer Pages (JSP) applications.

The taglib element is used to define a tag library and contains several optional and required sub-elements. The question asks which of these sub-elements are required.

Now, let's go through each option and explain why it is right or wrong:

A. tlib-version: This sub-element specifies the version of the tag library descriptor file. It is an optional sub-element, not required.

B. short-name: This sub-element specifies a short name for the tag library. It is a required sub-element.

C. uri: This sub-element specifies the URI of the tag library and is used to identify the tag library in JSP pages. It is a required sub-element.

D. display-name: This sub-element specifies a display name for the tag library. It is an optional sub-element, not required.

Therefore, the correct answers are:

  • B. short-name
  • C. uri

The Answer is: B and C

Which of the elements defined within the taglib element of taglib descriptor file are required. Select the two correct answers.

  1. name

  2. description

  3. validator

  4. tag-class

  5. display-name


Correct Option: A,D

AI Explanation

To answer this question, we need to understand the taglib descriptor file and the elements defined within the taglib element.

The taglib descriptor file, also known as the TLD file, is an XML file that defines the custom tags used in a JavaServer Pages (JSP) application. It provides information about the tag library, such as the name, description, tag class, and validator.

Let's go through each option to understand why it is correct or incorrect:

Option A) name - This option is correct because the name attribute is required in the taglib element. It specifies the unique name of the tag library.

Option B) description - This option is incorrect because the description attribute is not required. It provides an optional description of the tag library.

Option C) validator - This option is incorrect because the validator attribute is not required. It specifies a custom class that performs validation for the tag library.

Option D) tag-class - This option is correct because the tag-class attribute is required in the taglib element. It specifies the fully qualified name of the tag handler class.

Option E) display-name - This option is incorrect because the display-name attribute is not required. It provides an optional display name for the tag library.

Therefore, the correct answers are A) name and D) tag-class.

Name the element within the tag element that defines the name of the class that implements the functionality of tag. Select the one correct answer.

  1. class-name

  2. tag

  3. class

  4. tag-class

  5. tei-class


Correct Option: D

How to send signals to other processes?

  1. Use sigsend()

  2. use kill()

  3. use signal()

  4. Only init can send signals


Correct Option: B

Linux supports multi-threading

  1. True

  2. False


Correct Option: B

How to create devices/device files in Linux

  1. mkdev

  2. mknod

  3. lndev

  4. None


Correct Option: B

What is a /dev/zero device in Linux?

  1. A dummy device to represent memory

  2. A dummy device to represent the processor

  3. A dummy device to provide infinite number of zeros

  4. None


Correct Option: C

What is /dev/full device in Linux?

  1. A device file to represent that the current file system is full

  2. A device file to test scenarios of testing a /dev/full

  3. Invalid device

  4. None


Correct Option: B

What is /dev/random device?

  1. A dummy device to represent swap

  2. A dummy device to represent any device

  3. A dummy device to provide infinite number of randon numbers

  4. Invalid device


Correct Option: C

Zombie process will have parent as init

  1. True

  2. False


Correct Option: A

Which of the following will compile without error.

  1. import java.awt.*;package Mypackage;class Myclass {}

  2. package MyPackage;import java.awt.*;class MyClass{}

  3. /This is a comment */package MyPackage;import java.awt.;class MyClass{}

  4. class Myclass {};import java.awt.*;package Mypackage;


Correct Option: B,C

AI Explanation

To answer this question, we need to understand the proper syntax for importing packages and declaring classes in Java.

Option A) import java.awt.*;package Mypackage;class Myclass {}

This option is incorrect because the "package" statement should be the first line of code in a Java file. Therefore, the correct syntax should be "package Mypackage;" followed by the import statement and the class declaration.

Option B) package MyPackage;import java.awt.*;class MyClass{}

This option is correct. The "package" statement is the first line of code, followed by the import statement, and then the class declaration. This is the correct syntax for importing packages and declaring a class.

Option C) /This is a comment */package MyPackage;import java.awt.;class MyClass{}

This option is correct. The comment does not affect the code's compilation. The "package" statement is the first line of code, followed by the import statement, and then the class declaration. This is the correct syntax for importing packages and declaring a class.

Option D) class Myclass {};import java.awt.*;package Mypackage;

This option is incorrect because the "package" statement should be before the import statement and the class declaration.

Therefore, the options that will compile without error are B) package MyPackage;import java.awt.;class MyClass{} and C) /*This is a comment */package MyPackage;import java.awt.;class MyClass{}

Which of the following are legal identifiers.

  1. 2variable

  2. variable2

  3. _whatavariable

  4. 3

  5. $anothervar

  6. #myvar


Correct Option: B,C,D,E

AI Explanation

To answer this question, we need to understand the rules for legal identifiers in programming.

In most programming languages, including Java, the following rules generally apply for legal identifiers:

  1. They can only contain letters (a-z, A-Z), digits (0-9), underscores (_), and dollar signs ($).
  2. They must start with a letter, an underscore, or a dollar sign.
  3. They cannot be a reserved keyword or a special symbol.

Let's go through each option to determine whether it is a legal identifier or not:

Option A) 2variable - This option is not a legal identifier because it starts with a digit, which violates rule 2.

Option B) variable2 - This option is a legal identifier because it starts with a letter, satisfies rule 1, and does not violate rule 3.

Option C) _whatavariable - This option is a legal identifier because it starts with an underscore, satisfies rule 1, and does not violate rule 3.

Option D) 3 - This option is a legal identifier because it starts with an underscore, satisfies rule 1, and does not violate rule 3.

Option E) $anothervar - This option is a legal identifier because it starts with a dollar sign, satisfies rule 1, and does not violate rule 3.

Option F) #myvar - This option is not a legal identifier because it contains a hash symbol (#), which is not allowed according to rule 1.

Therefore, the correct options are B, C, D, and E. These options are legal identifiers according to the given rules.

What will happen if you try to compile and run the following code? public class Q { public static void main(String argv[]){ int anar[]=new int[]{1,2,3}; System.out.println(anar[1]); }}

  1. 1

  2. Error anar is referenced before it is initialized.

  3. 2

  4. Error: size of array must be defined.


Correct Option: C

AI Explanation

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

public class Q {
    public static void main(String argv[]){
        int anar[]=new int[]{1,2,3};
        System.out.println(anar[1]);
    }
}

This code declares an array anar of type int and initializes it with the values 1, 2, and 3. The System.out.println(anar[1]) statement prints the value at index 1 of the anar array.

When you compile and run this code, it will output:

2

Therefore, the correct answer is C) 2.

Which of the following statements are true?

  1. System.out.println( -1 >>> 2);will output a result larger than 10

  2. System.out.println( -1 >>> 2); will output a positive number

  3. System.out.println( 2 >> 1); will output the number 1

  4. System.out.println( 1 <<< 2); will output the number 4


Correct Option: A,B,C

Given the following declarations String s1=new String("Hello")String s2=new String("there");String s3=new String(); Which of the following are legal operations?

  1. s3=s1 + s2;

  2. s3=s1-s2;

  3. s3=s1 & s2;

  4. s3=s1 && s2


Correct Option: A

AI Explanation

To answer this question, we need to understand the different operations that can be performed on strings in Java.

Option A) s3=s1 + s2 - This option is legal. The + operator can be used to concatenate two strings in Java. Therefore, s1 + s2 will concatenate the strings "Hello" and "there", resulting in the string "Hellothere". The concatenated string can then be assigned to s3.

Option B) s3=s1 - s2 - This option is not legal. The - operator is not defined for strings in Java. Therefore, we cannot subtract one string from another.

Option C) s3=s1 & s2 - This option is not legal. The & operator is a bitwise operator and is not defined for strings in Java. Therefore, we cannot perform a bitwise operation on strings.

Option D) s3=s1 && s2 - This option is not legal. The && operator is a logical operator and is not defined for strings in Java. Therefore, we cannot perform a logical operation on strings.

The correct answer is A) s3=s1 + s2. This option is legal because the + operator can be used to concatenate strings in Java.

If you want to use USER32.DLL in your program, which namespace you should use:

  1. System.Collections.Generic

  2. System.Reflection

  3. Microsoft.Office.Interop

  4. None of the above


Correct Option: D

When you need to perform complex calculations or access external resources in SQL Server 2005, which one of the following programming methods do you use?

  1. SQL Server Management Studio

  2. CLR User Defined Type

  3. CLR Stored Procedure

  4. T-SQL View


Correct Option: C

Consider following statements: 1. System.Collections.ArrayList can store values of only single data type 2. System.Collections.ArrayList can store values of multiple data types 3. System.Collections.Generic.List can store values of multiple datatypes 4. System.Collections.Generic.List can store values of only single data type Which of the above is false:

  1. Only 2

  2. Both 1 and 3

  3. 4

  4. Both 2 and 4


Correct Option: B

Which of the following is true:

  1. It is possible for a single class to implement multiple interfaces

  2. It is possible for a class to inherit from multiple classes

  3. It is possible for a class to inherit from a Sealed class

  4. All of above


Correct Option: A

Which of the following is not true about Reflection (System.Reflection and inherited classes):

  1. To get information about event-handler

  2. To get or set property values

  3. Classes in other namespace can use reflection to access data and to determine which fields to persist

  4. None of the above


Correct Option: D

AI Explanation

To answer this question, you need to understand the concept of Reflection and its capabilities.

Reflection is a powerful feature in .NET that allows you to dynamically explore and manipulate types, members, and metadata of an assembly at runtime. It provides the ability to obtain information about types, properties, methods, events, and other members of a class or assembly.

Let's go through each option to understand why it is correct or incorrect:

Option A) To get information about event-handler - This option is correct because Reflection allows you to retrieve information about event handlers, such as their names, parameters, and return types.

Option B) To get or set property values - This option is correct because Reflection allows you to get or set property values dynamically. You can retrieve information about properties, including their names, types, and access modifiers, and then manipulate their values.

Option C) Classes in other namespaces can use reflection to access data and to determine which fields to persist - This option is correct because Reflection provides the ability to access data and determine which fields to persist, regardless of the namespace in which the classes reside.

Option D) None of the above - This option is incorrect because Options A, B, and C are all true statements about Reflection. Therefore, the correct answer is not "None of the above."

The correct answer is D) None of the above.

- Hide questions