U02

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

final

A .... method is implemented in a super class can not be overridden in derived classes. private default final protected public

private

A method in a super class is implemented using the default modifier, this method can not be overridden in subclasses using the ..... modifier. public protected default private

Exceptions

Errors beyond the control of a program are called ......... Syntax errors Assertions. Exceptions All of the others.

a

If a Java source code contains an assert as an identifier and it will be compiled with JDK version 1.4 or higher, .... The option "-source 1.4" must be specified when it is compiled. The option "-source 1.4 version" must be specified when it is compiled. The option "-enableassertion" must be specified when it is run. None of the others.

a

If the following code is executed. What is the output? int[] a= {1,2,3,4}; System.out.println(a[6]); ArrayIndexOutOfBoundsException A compile-time exception because they must be put in the try catch block. 0 A non-predictable value.

a

Java compiler allows ....... Implicit widening conversions. Implicit narrowning conversions No conversions. type casting only.

a

Select an operation which may cause an unchecked exception. Accessing an element of an array. Accessing data in a file. Accessing a remote resource. Accessing data in a database. Controlling the state of a running thread.

1, 3

Select correct statements. (1) A public member of a class can be accessed in all classes. (2) A default member of a class can be accessed in all classes. (3) A protected member of a class can be accessed in the package containing this class. (4) A private member of a class can be accessed in the package containing this class. 1, 2 1, 3 1, 4 1, 2, 3 2, 3, 4

1, 4, 5

Select incorrect Java program entry point declarations. (1) public static void main() (2) public static void main(String [] args) (3) public static void main(String args[]) (4) public static void main(string [] args) (5) public static void main(String args) 1, 2, 3 2, 3, 4 1, 4, 5 3, 4, 5 All of the others.

a

Select the correct syntax for throwing an exception when declaring a method. [Modifier] {Return type] Identifier (Parameters) throws TypeOfException [Modifier] {Return type] Identifier (Parameters) throw TypeOfException [Modifier] {Return type] Identifier (Parameters) {throw TypeOfException ; [Modifier] {Return type] Identifier (Parameters) {throws TypeOfException ; None of the others

0

Study the following Java code: int n= 256; byte x= (byte) n; Suppose that the above code is executed, the value of the variable x is ...... 25 258 128 0 None of the others

d

Suppose a method called finallyTest() method consisting of a try block, followed by a catch block, followed by a finally block. Assuming the JVM doesn't crash and the code does not execute a System.exit() call, under what circumstances will the finally block not begin to execute? The try block throws an exception, and the catch block also throws an exception. The try block throws an exception that is not handled by the catch block. The try block throws an exception, and the catch block calls finallyTest() in a way that causes another exception to be thrown. If the JVM doesn't crash and the code does not execute a System.exit() call, the finally block will always execute.

none

The default access modifier in Java is ....... public private static protected None of the others.

class

The private and protected modifiers are not applied on ..... methods of a class class data members of a class contructors of a class.

a

The protected modifier cannot be applied to which of the following declarations? static class A { } static int x = 10; static double = 23.2; static string = "123";

a

The try... catch statements must be used to contain statements that ...... may cause checked exceptions. may cause unchecked exceptions. may cause compile-time errors. may cause run-time errors.

>>

What is NOT a comparison operator? == != >> instanceof

/

What is NOT a unary operator? -- / ~ ++

Negative value

When a negative byte is cast to a long, what are the possible values of the result? Positive value. Zero. Negative value. All of the others.

none

When handling exceptions, how many catch{} blocks can be used for one try{} block? None of the others 1 only. 2 only 3 only

transient

Which modifiers on instance variables will announce to the compiler that these variables are not stored as part of its object's persistent state. public native volatile transient synchronized

3, 4

Which of the following Java operations cause compile-time errors? int m=5, n=7; float x = m; //1 double y= n; //2 m = y; // 3 n = x; // 4 1, 3 3, 4 2, 4 1, 2, 3, 4

default

Which of the following access modifiers does not allow a class to be accessed outsite its package? default protected public final

final

Which of the following access modifiers makes a class cannot be inherited? final static private protected

b

Which of the following declarations is not correct? private int i; public protected String myString; public class MyMoney { } class ParserNum {}

a

Which of the following declarations is not valid? private int[] ar3 = new int[2]{1, 2}; private int ar2[] = new int[2]; private int ar1[] = {1,2,3,4}; private int[] ar = new int[]{1,2,3,4};

final

Which of the following modifiers can assure that a class is not inherited by other classes? abstract transient volatile final

protected

Which of the following modifiers cannot be applied for a class? public No modifier (default) protected final

final

Which of the following modifiers does not allow a method to be overridden? final abstract public protected

final

Which of the following modifiers is not an access modifier? public private protected final None of the others

private

Which of the following modifiers is valid for a constructor? static private synchronized final

volatile

Which of the following modifiers makes a variable can be modified asynchronously? synchronized transient native volatile

c

Which of the following statement is NOT correct about protected access modifier? Only variables and methods may be declared as protected. Different package sub-classes may override protected method of the super class. Protected variables of a class can only be accessed by its sub-class in the same package None of the others.

a

Which of the following statement is not correct about default access modifier? To declare a variable that have default access modifier, we use the default keyword. For example: default String myString; A class's data and methods may be default, as well as the class itself. A class that has default access modifier can be accessed by any class in the same package. A default method may be overridden by any subclass that is in the same package as the super class.

b

Which of the following statements are true? 1)An abstract class can not have any final methods. 2)A final class may not have any abstract methods. Only statement 1. Only statement 2. Both statement 1 and 2 None of the others.

a

Which of the following statements is correct? For value types, narrowing conversion is not allowed. For value types, widening conversion is not allowed. A boolean can be converted to any other type. None of the others

c

With respect to access modifier overridden, the right order is: private, default, protected, public default, private, protected, public private, protected, default, public public, protected, default, private

a

int x=2; //1 long z=3; //2 double t=5.4;//3 x=t; //4 z=x; //5 Which statement causes an error? The statements (4) and (5). The statement (4) only. The statement (5) only. None of the others.


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

Pharmacology Module 4 - RESPIRATORY

View Set

Principles of economics ch. 33,34

View Set

Physiological Psych. Module 1.2 Quiz

View Set

CHAPTER #1 INTERACTIVE ASSIGNMENT- NUTRITION 1325-01

View Set