0

programming languages Online Quiz - 317

Description: programming languages Online Quiz - 317
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0
  1. The type List is assignable to List.

  2. The type List is assignable to List>.

  3. The type List is assignable to List extends B>.

  4. The type List extends A> is assignable to List.

  5. The type List is assignable to any List reference.

  6. The type List extends B> is assignable to List extends A>.


Correct Option: B,C,F

Given: 1. package com.company.application; 2. 3. public class MainClass { 4. public static void main(String[] args) { } 5. } And MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH environment variable is set to “.“ (current directory). Which two java commands entered at the command line will run MainClass? (Choose two.) A. java MainClass if run from the /apps directory B. java com.company.application.MainClass if run from the /apps directory C. java -classpath /apps com.company.application.MainClass if run from any directory D. java -classpath . MainClass if run from the /apps/com/company/application directory E. java -classpath /apps/com/company/application:. MainClass if run from the /apps directory F. java com.company.application.MainClass if run from the /apps/com/company/application directory

  1. A

  2. B

  3. C

  4. D

  5. E

  6. F


Correct Option: B,C

AI Explanation

To determine which java commands will run the MainClass, we need to consider the CLASSPATH environment variable and the location of the MainClass file. Let's go through each option to determine whether it is correct or incorrect:

Option A) java MainClass if run from the /apps directory - This option is incorrect because the MainClass file is not in the current directory. The command will not be able to find the MainClass file.

Option B) java com.company.application.MainClass if run from the /apps directory - This option is correct because it specifies the fully qualified name of the MainClass and the command is executed from the directory that contains the MainClass file.

Option C) java -classpath /apps com.company.application.MainClass if run from any directory - This option is correct because it specifies the classpath to be the /apps directory, which contains the MainClass file. The command can be executed from any directory.

Option D) java -classpath . MainClass if run from the /apps/com/company/application directory - This option is incorrect because it does not specify the fully qualified name of the MainClass. The command will not be able to find the MainClass file.

Option E) java -classpath /apps/com/company/application:. MainClass if run from the /apps directory - This option is incorrect because it does not specify the fully qualified name of the MainClass. The command will not be able to find the MainClass file.

Option F) java com.company.application.MainClass if run from the /apps/com/company/application directory - This option is incorrect because it does not include the classpath. The command will not be able to find the MainClass file.

The correct answers are B and C. These options specify the fully qualified name of the MainClass and include the correct classpath to locate the MainClass file.

Click the Exhibit button. 10. class Inner { 11. private int x; 12. public void setX( int x) { this.x = x; } 13. public int getX() { return x; } 14. } 15. 16. class Outer { 17. private Inner y; 18. public void setY( Inner y) { this.y = y; } 19. public Inner getY() { return y; } 20. } 21. 22. public class Gamma { 23. public static void main( String[] args) { 24. Outer o = new Outer(); 25. Inner i = new Inner(); 26.int n=10; 27. i.setX(n); 28. o.setY(i); 29. // insert code here 30. System.out.println( o.getY().getX()); 31. } 32. } Which three code fragments, added individually at line 29, produce the output 100? (Choose three.)

  1. n = 100;

  2. i.setX( 100);

  3. o.getY().setX( 100);

  4. i = new Inner(); i.setX( 100);

  5. o.setY( i); i = new Inner(); i.setX( 100);

  6. i = new Inner(); i.setX( 100); o.setY( i);


Correct Option: B,C,F

AI Explanation

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

Option A) n = 100; - This option is incorrect because it assigns the value of 100 to the variable n, but it does not modify the value of x in the Inner object i that is stored in the Outer object o.

Option B) i.setX(100); - This option is correct because it directly sets the value of x in the Inner object i to 100.

Option C) o.getY().setX(100); - This option is correct because it first retrieves the Inner object i stored in the Outer object o using the getY() method, and then sets the value of x in the Inner object to 100 using the setX() method.

Option D) i = new Inner(); i.setX(100); - This option is incorrect because it creates a new Inner object i and sets its value of x to 100, but it does not update the Inner object that is stored in the Outer object o.

Option E) o.setY(i); i = new Inner(); i.setX(100); - This option is incorrect because it first sets the Inner object i as the value of y in the Outer object o, but then it creates a new Inner object i and sets its value of x to 100. This new Inner object is not stored in the Outer object o.

Option F) i = new Inner(); i.setX(100); o.setY(i); - This option is correct because it first creates a new Inner object i and sets its value of x to 100. Then, it sets this Inner object as the value of y in the Outer object o.

The correct answers are B, C, and F. These options modify the value of x in the Inner object i that is stored in the Outer object o, resulting in the output of 100 when o.getY().getX() is called at line 30.

Given: 1. public class Threads2 implements Runnable { 2. 3. public void nun() { 4. System.out.println(”run.”); 5. throw new RuntimeException(”Problem”); 6. } 7. public static void main(String[] args) { 8. Thread t = new Thread(new Threads2()); 9. t.start(); 10. System.out.println(”End of method.”); 11. } 12. } Which two can be results? (Choose two.) A. java.lang.RuntimeException: Problem B. run. java.lang.RuntimeException: Problem C. End of method. java.lang.RuntimeException: Problem D. End of method. run. java.lang.RuntimeException: Problem E. run. java.lang.RuntimeException: Problem End of method.

  1. A

  2. B

  3. C

  4. D

  5. E


Correct Option: D,E

AI Explanation

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

1. public class Threads2 implements Runnable {
2.
3. public void run() {
4.     System.out.println("run.");
5.     throw new RuntimeException("Problem");
6. }
7.
8. public static void main(String[] args) {
9.     Thread t = new Thread(new Threads2());
10.    t.start();
11.    System.out.println("End of method.");
12. }
13.
}

The code defines a class Threads2 that implements the Runnable interface. It has a run() method that prints "run." and throws a RuntimeException with the message "Problem". In the main() method, a new Thread is created with an instance of Threads2 and started. It also prints "End of method.".

Now let's go through each option to determine which ones can be the result:

Option A) A. java.lang.RuntimeException: Problem This option is correct because the run() method throws a RuntimeException with the message "Problem". This exception will be caught by the JVM, and the stack trace will be printed, resulting in the output java.lang.RuntimeException: Problem.

Option B) B. run. This option is incorrect because it only includes the output "run.". The code also prints "End of method." after starting the thread.

Option C) C. End of method. This option is incorrect because it only includes the output "End of method.". The code also throws a RuntimeException in the run() method, which will be caught by the JVM.

Option D) D. End of method. run. java.lang.RuntimeException: Problem This option is correct because it includes all the possible outputs. The code first prints "End of method.", then starts the thread, which executes the run() method and prints "run.". Finally, the exception is thrown and caught by the JVM, resulting in the output java.lang.RuntimeException: Problem.

Option E) E. run. java.lang.RuntimeException: Problem End of method. This option is correct because it includes all the possible outputs, but in a different order. The code first starts the thread, which executes the run() method and prints "run.". Then, the exception is thrown and caught by the JVM, resulting in the output java.lang.RuntimeException: Problem. Finally, "End of method." is printed.

Therefore, the correct answers are options D and E.

  1. Given: 10. class One { 11. public One foo() { return this; } 12. } 13. class Two extends One { 14. public One foo() { return this; } 15. } 16. class Three extends Two { 17. // insert method here 18. } Which two methods, inserted individually, correctly complete the Three class? (Choose two.)
  1. public void foo() { }

  2. public int foo() { return 3; }

  3. public Two foo() { return this; }

  4. public One foo() { return this; }

  5. public Object foo() { return this; }


Correct Option: C,D

AI Explanation

To answer this question, let's analyze each option:

Option A) public void foo() { } - This option is incorrect because it does not match the return type of the foo() method in the superclass Two.

Option B) public int foo() { return 3; } - This option is incorrect because it does not match the return type of the foo() method in the superclass Two.

Option C) public Two foo() { return this; } - This option is correct because it overrides the foo() method in the superclass Two with the same return type. The return type Two is a valid subtype of the return type One declared in the superclass.

Option D) public One foo() { return this; } - This option is correct because it overrides the foo() method in the superclass Two with the same return type. The return type One is the same as the return type declared in the superclass.

Option E) public Object foo() { return this; } - This option is incorrect because it does not match the return type of the foo() method in the superclass Two. Although Object is a superclass of all classes, it is not a valid subtype of the return type One declared in the superclass.

Therefore, the correct answers are Option C) public Two foo() { return this; } and Option D) public One foo() { return this; }.

Given: 10. public class Fabric 11. public enum Color { 12. RED(0xff0000), GREEN(0x00ff00), BLUE(0x0000ff); 13. private final int rgb; 14. Color( int rgb) { this.rgb = rgb; } 15. public int getRGB() { return rgb; } 16. }; 17. public static void main( String[] argv) { 18. // insert code here 19. } 20. } Which two code fragments, inserted independently at line 18, allow the Fabric class to compile? (Choose two.)

  1. Color skyColor = BLUE;

  2. Color treeColor = Color.GREEN;

  3. Color purple = new Color( 0xff00ff);

  4. if( RED.getRGB() < BLUE.getRGB() ) {}

  5. Color purple = Color.BLUE + Color.RED;

  6. if( Color.RED.ordinal() < Color.BLUE.ordinal() ) {}


Correct Option: B,F

AI Explanation

To answer this question, let's review each of the given options:

Option A) Color skyColor = BLUE; This option assigns the enum constant "BLUE" to the variable "skyColor". This is incorrect because "BLUE" is a member of the "Color" enum and should be accessed as "Color.BLUE".

Option B) Color treeColor = Color.GREEN; This option correctly assigns the enum constant "GREEN" from the "Color" enum to the variable "treeColor". This is a valid way to access enum constants.

Option C) Color purple = new Color(0xff00ff); This option attempts to create a new enum constant using the constructor of the "Color" enum. However, enum constants are predefined and cannot be created using the constructor. This is incorrect.

Option D) if (RED.getRGB() < BLUE.getRGB()) {} This option correctly accesses the "getRGB()" method of the "RED" and "BLUE" enum constants and performs a comparison. This is a valid way to access enum constants and their methods.

Option E) Color purple = Color.BLUE + Color.RED; This option attempts to add the enum constants "BLUE" and "RED". However, enum constants cannot be added together using the "+" operator. This is incorrect.

Option F) if (Color.RED.ordinal() < Color.BLUE.ordinal()) {} This option correctly accesses the "ordinal()" method of the "RED" and "BLUE" enum constants and performs a comparison. This is a valid way to access enum constants and their methods.

Therefore, the correct options are B) Color treeColor = Color.GREEN; and F) if (Color.RED.ordinal() < Color.BLUE.ordinal()).

  1. Task View and Gnatt Chart View

  2. Task View, Time View and Workflow View

  3. Task View, Gnatt Chart View and workflow view

  4. Gnatt View and Workflow view


Correct Option: A
  1. Create user

  2. Create folders

  3. Assign privileges

  4. All of the above


Correct Option: D

Which of the following is not a type of Workflow Task

  1. Mapping

  2. Decision

  3. Session

  4. Email


Correct Option: A
  1. Informatica Server

  2. Repository Server

  3. Both A and B

  4. Neither A nor B


Correct Option: C
  1. Tasks must be within Workflows in order to be executed

  2. Workflows must be within Tasks to be executed

  3. Workflow links may contain conditions

  4. A start task is default task in a Workflow


Correct Option: B

What types of data source(s) can be read with the source qualifier transformation?

  1. Relational Databases

  2. Relational Databases and flat files

  3. Relational Databases,lat files and cobol

  4. Relational Databases,lat files,cobol and certified ERP sources such as Peoplesoft and SAP R/3


Correct Option: D
  1. Run the Debugger, validate mappings and mapplets, import source definitions

  2. Run the debugger, create and delete folders, import source definitions

  3. Create and delete folders, view object dependencies, import source definitions

  4. Create and delete folders, create and edit mappings, create target tables


Correct Option: A
- Hide questions