Java

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What will be the result of this method, if we pass in a Bird object? public void whatIsThis(Animal a) { if (a instanceof Dog) System.out.println("This is a Dog!"); else System.out.println("I don't know what this is"); }

"I don't know what this is"

What is the value of 'count' at line 4? for (int count = 1; count < 5; count++) { count = count + count; } // Line 4

'count' is out of scope at line 4, and no longer exists

for (byte i = 0; i<5; i++) { system.out.print (i); }

01234

What is the output of the following code? int 1 =0; while(i = 4

01XXX

int i = 0; while(i <5) if(i==0)system.out.print(0); i==; system.out.print((i>2?1:2)); }

022111

What is the output of the following code?

13

Which of these is the symbol for an annotation?

@

You need a collection to represent secret agents. Every agent has a unique codename that identifies them, and an Agent object that represents them. The best collection for this would be?

A HashMap< String, Agent >

Which of these is a valid location for an annotation in Java 8?

Before a class declaration Before the use of a type All of these Before a method declaration

Protected data can...

Can be accessed only by classes in the same package, or subclasses

Which of these is a consequnce of removing a method declaration from an interface after it has been implemented?

Code would break whenever an interface reference is used to polymorphicaly call the method in an instance of an implementing class.

Which of these is a consequence of adding a method declaration to an interface after it has been implemented? (Without declaring the method static or default.)

Every implementing subclass would need to add a definition for the new method.

Interfaces are a form of inheritance

FALSE

Java supports multiple inheritance of classes

FALSE

True or False: A class in Java can extend multiple parent classes

FALSE

True or False: A class without a properly defined main() method may be executed directly.

FALSE

True or False: A final class cannot be instantiated

FALSE

True or False: If the class Car extends class Automobile, then an instance of Automobile can access Car methods

FALSE

True or False: If you write a constructor, the compiler will still give you a default, no-argument constructor.

FALSE

True or False: Interface implementation is a form of inheritance

FALSE

True or False: Strings only hold a single a character.

FALSE

True or False: The subclass of an abstract class cannot be abstract.

FALSE

What is the boolean value of this statement? String string1 = "TEST"; string1.equals(string1.toLowerCase());

FALSE

true or False: An array is a type of Collection in Java

FALSE

What is the use of the '%' operator?

It returns the remainder of a division operation between integers

Which of these is NOT true for Java?

Java allows direct manipulation of memory addresses

Which interface does not extend the Collection interface?

Map

Should you catch all Throwable objects?

No, Errors are Throwable, and should not be caught

The "transient" keyword...

Prevents data from being serialized

IndexOutOfBoundsException is what type of Exception?

RunTimeException

Select the option that is true of Strings in Java.

String is a class.

Because LinkedLists in java implement List, they have an index.

TRUE

The equals() method is equivalent to the == operator, unless overridden

TRUE

True or False: A finally block will execute regardless of whether an exception is caught.

TRUE

True or False: An interface can extend more than one interface

TRUE

True or False: Because sets have no ordering, there is no way to retrieve a specific object from a Set immediately.

TRUE

True or False: Inherited behaviors can be overriden in a subclass

TRUE

True or False: Java can be run on any machine that has a JVM

TRUE

True or False: Mapping with annotations requires you to identify the mapped classes in your configuration document.

TRUE

True or False: Static methods can be called without instantiating the class first.

TRUE

True or False: The Object reference can be used to polymorphically store a reference to an instance of any class in Java

TRUE

True or False: The main() method must be static, in order to be executed by the JVM.

TRUE

True or False: The relationship between a class and its members is a, HAS-A" relationship

TRUE

True or False: You can string multiple if...else statements together

TRUE

True or False: You can use both annotations and mapping files in the same project

TRUE

The @Override annotation...

Tells the compiler that the method is intended to override a superclass method

int count = 0; while (count < 2) { System.out.print("Hi "); }

The loop will run forever

4 Which keyword is used to show inheritance in Java?

extends

What is the output of the following code?

f

The keyword "static" means:

something belongs to the class and is globally available to all instances.


संबंधित स्टडी सेट्स

Financial Accounting Mid-Term Exam

View Set

PrepU questions for MS 3 1st exam

View Set

EMT-Chapter 24 -Gynecologic Emergencies

View Set

Psych 5.1 Sensation and Perception

View Set

Ch 3 - Balance Sheet and Disclosure notes

View Set