programming languages Online Quiz - 319

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

Given: 11. public class Key { 12. private long id1; 13. private long 1d2; 14. 15. // class Key methods 16. } A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key? (Choose two.)

  1. public int hashCode()

  2. public boolean equals(Key k)

  3. public int compareTo(Object o)

  4. public boolean equals(Object o)

  5. public boolean compareTo(Key k)

Correct Option: A,D

AI Explanation

To assure that the Key class works correctly as a key in a java.util.HashMap, two methods should be overridden: hashCode() and equals(Object o).

A. public int hashCode() - This method needs to be overridden to provide a unique hash code for each Key object. The HashMap uses the hash code to determine the bucket location for storing and retrieving objects.

D. public boolean equals(Object o) - This method needs to be overridden to define the equality comparison for Key objects. The HashMap uses the equals() method to check if two keys are equal or not.

Options B, C, and E are incorrect:

B. public boolean equals(Key k) - This method is not the correct signature for the equals() method. The equals() method should take an Object parameter, not a specific type.

C. public int compareTo(Object o) - This method is not necessary for the Key class to work as a key in a HashMap. The compareTo() method is used for sorting objects and is not relevant to the HashMap implementation.

E. public boolean compareTo(Key k) - This method is not the correct signature for the compareTo() method. The compareTo() method should take an Object parameter, not a specific type.

Therefore, the correct answer is options A and D.

AppDomains are usually created by hosts

  1. True

  2. False

Correct Option: A

Which tool is used to generate PE files from MSIl code?

  1. ildasm

  2. ilasm

  3. capol

  4. resgen

Correct Option: B

Placing web service files in one of these folders, generates a proxy class(out of .wsdl) and a typed dataset (out of .xsd). What is the name of the folder?

  1. App_Data

  2. App_Resources

  3. App_Code

  4. App_WebReferences

Correct Option: C

Which of the page directive defines the class or virtual path used to type the Master property of a page?

  1. @MasterType

  2. @MasterPage

  3. @Master

  4. @MasterPath

Correct Option: A

What is called as a collection of CSS files and images?

  1. Skin

  2. Themes

  3. CSS_folder

  4. None

Correct Option: B

POST is an IDEMPOTENT method.

  1. True

  2. False

Correct Option: B

service() method - it's advisable to override it in our applications.

  1. True

  2. False

Correct Option: B

In MVC architecture, VIew means the JSP.

  1. True

  2. False

Correct Option: A

SERVLETCONFIG--- one per web Application.

  1. True

  2. False

Correct Option: B

init() & destroy() ---methods can ONLY BE CALLED ONCE!

  1. True

  2. False

Correct Option: A

What noted Java developer at his Ph.D. defense answered a planted question with a rap song backed by a recorded rhythm track on a hidden tape recorder?

  1. James Gosling

  2. Guy Steele

  3. Joshua Bloch

  4. Greg Papadopoulos

Correct Option: C

True or false: It is preferable to write: List dogs = new ArrayList(); instead of List dogs = new ArrayList(); because raw types enable developers to avoid needless verbiage.

  1. True

  2. False

Correct Option: B

Who agrees with the idea that developers should write "dumb code," meaning straightforward, clean code that follows the most obvious object-oriented principles, in order to get the best compiler optimization -- and that clever, hacked-up, bit-banging code will get poorer results?

  1. Brian Goetz

  2. Heinz Kabutz

  3. Cay Horstmann

  4. All of the above

  5. None of the above

Correct Option: D

Joshua Bloch says that the strangest thing about the Java platform is _____

  1. Poor Unicode support.

  2. java.lang.Cloneable does not contain clone() method.

  3. The byte type is signed.

  4. The creators of the Java programming language modeled the syntax after C and C++.

  5. java.io.InputStream is an abstract class and not an interface.

Correct Option: C

Who strongly believes in the importance of unit testing and says that developers should engage in it?

  1. Heinz Kabutz

  2. Cay Horstmann

  3. Joshua Bloch

  4. 1 and 3

  5. All of the above

Correct Option: D

Qusay Mahmoud remarked that "Today's generation of students is becoming known as Generation C." What does "C" stand for?

  1. Create, complete, and collect

  2. Creativity, curiosity, and career

  3. Content, cash, choice, and control

  4. Compete, confer, and collect

Correct Option: C

For which action can you use the TO_DATE function?

  1. Convert any date literal to a date

  2. Convert any numeric literal to a date

  3. Convert any character literal to a date

  4. Convert any date to a character literal

  5. Format ’10-JAN-99’ to ‘January 10 1999’

Correct Option: C

Computer science professors Qusay Mahmoud and Cay Horstmann agree that the biggest mistake made by teachers of computer science is

  1. Overwhelming students with too much code complexity too early

  2. Lecturing too much

  3. Failing to educate students in the use of tools

  4. Failing to encourage individual creativity and initiative

Correct Option: B

Which one is a system privilege?






Correct Option: D
- Hide questions