PRJ311
(b == 0) && (c > 5)
! ((b != 0) || (c <= 5))
Among these expressions, which is(are) of type String?
"0" and "ab" + "cd"
Object oriented inheritance models the
"is a kind of" relationship
27. What relationship does the extends keyword represent?
"is a"
The keyword extends refers to what type of relationship?
"is a"
What relationship does the extends keyword represent?
"is a"
Which of the following are valid mode strings for the RandomAccessFile constructor? (Choose all that apply.)
"r","rw", "rws","rwd"
6. Which of the following are valid mode strings for the RandomAccessFile constructor? (Choose all that apply.)
"r"."rw"."rws"."rwd"
public class StringTest {public static void main(String [] a) { String s1 = "test string";String s2 = "test string"; if (s1 == s2) {System.out.println("same");} else { System.out.println("different");}}}
"same" will be printed out to the console.
Which of the following is the correct expression of character 4
'4'
Which of the following is the correct expression of character 4?
'4'
Which of the following is not a valid String Constant?
'x'
List the following operators in the order that they will be evaluated: -, *, (), %, +, /. Assume that if two operations have the same precedence, the one listed first will be evaluated first
(), *, /, %, -, +
List the following operators in the order that they will be evaluated: -, *, (), %, +, /. Assume that if two operations have the same precedence, the one listed first will be evaluated first.
(), *, /, %, -, +
Which of the following are valid statements?
(1+1); int i=2+'2';
I. int x[] = int[10];. II. int[] y = new int[5];
(I), (III) and (V) above
Which of the following contain error?I. int x[] = int[10];.II. int[] y = new int[5];III. x = y = new int[10];IV. int a[] = {1, 2}; int b[]; b = a;V. int i = new int(10);
(I), (III) and (V) above
I. Random. II. Byte.
(II), (III), (IV) and (V) above
I. Stack. II. Object.
(II), (III), (IV) and (V) above
Which of the following are the wrapper classes?I. Random.II. Byte.III. Integer.IV. Short.V. Double.
(II), (III), (IV) and (V) above
Which of the following classes are available in the java.lang package?I. Stack.II. Object.III. Math.IV. String.V. StringBuffer.Choose the correct option from the following:
(II), (III), (IV) and (V) above
Consider the following code int number[] = new int[5]; After execution of this statement, which of the following is/are true?
(II), (IV) and (V) above
int number[] = new int[5]; After execution of this statement, which of the following is/are true?
(II), (IV) and (V) above
A constructor
(a), (b) and (c) above.
1. Which of the following are legal? (Choose all that apply.)
(i=0,j=1)x2; i<10(String s = ""; s.length()<10; s += '!')
.Runnable (but does not extend Thread). Both classes have no-args constructors. Which of the following cause a thread in the JVM to begin execution? (Choose all correct options.)
(new MyThread()).start();(new Thread(new MyRunnable()))
Which one of the following is not true?
) An abstract class cannot have non-abstract methods
Which of these field declarations are legal within the body of an interface?
) public static int answer=42
Which of these operators can be used to concatenate two or more String objects?
+
Which operator is used for concatenation in java?
+
9. Which of the following operators can perform promotion on their operands? (Choose all that apply.)
+ - ~
Which of the following operators can perform promotion on their operands?
+ - ~
Which of the following operators can perform promotion on their operands? (Choose three.)
+ - ~
operators can perform promotion on their operands
+ - ~(nga)
38
++ /2
Which of the following operators can perform promotion on their operands?
+,-,~
Which operator is used for concatenation in java?
+.
1000
-1
Which of these values is returned by read() method is end of file (EOF) is encountered?
-1
public class A{static int x;public static void main(String[] args) { A that1 = new A();
-1
Which of the following statements are true?
-1 >>> 2&-1 >>> 2&2 >> 1);
A byte can be of what size
-128 to 127
What is -50 >> 2
-13
Assume int[] scores = {1, 20, 30, 40, 50}, what value does
-2
range of values that can be assigned to a variable of type short
-215 through 215 - 1
5. What is -50 >> 1?
-25
What is -50 >> 1
-25
What is -50 >> 1?
-25
The type long can be used to store values in the following range
-263 to 263-1
The type long can be used to store values in the following range:
-263 to 263-1
7. What is the range of values that can be assigned to a variable of type byte?
-27 through 27 - 1
range of values that can be assigned to a variable of type byte
-27 through 27 - 1
What is the range of values that can be assigned to a variable of type byte?
-2^7 through 2^7 - 1
What is -8 % 5
-3
What is -8 % 5?
-3
49. What is -15 % -10?
-5
What is -15 % -10
-5
Which of these values are returns under the case of normal termination of a program?
0
Compilation fails because of an error in line 12
1 2 3
for (int i: someArray) System.out.print(i +" ");
1 2 3
char c = '\u1234'
1 dap an
int x = -1; x = x >>> 5
1 dap an
i += 2
1 , 1
What will be the content of array variable table after executing the following code?
1 0 0 0 1 0 0 0 1
11. public static void main(String[] args) {12. Object obj =new int[] { 1,2,3 };13. int[] someArray = (int[])obj;14. for (int i: someArray) System.out.print(i +" ");
1 2 3
x = 23 % 4;
3
Given the following code, which of the following will compile? (Choose three.)enum Spice { NUTMEG, CINNAMON, CORIANDER, ROSEMARY; }
3 cai dai nhat
default String s ,, abstract double d ,, double hyperbolic
3 dap an
What is the correct order of defining a Class?
3,2,1,5,4
Which is not a valid operator in Java?
<>
Which are the correct statements used for getting connection object to connect to SQL Server database?
="jdbc:odbc:data_source_name"; Connection con = DriverManager.getConnection (url, "user", "password");
Which of these is wildcard symbol?
?
What is the range of values that can be assigned to a variable of type short?
?215 through 215 ? 1
What is the range of values that can be assigned to a variable of type byte?
?27 through 27 ? 1
What is the range of values that can be assigned to a variable of type short?
?2^15 through 2^15 ? 1
What is the range of values that can be assigned to a variable of type byte?
?2^7 through 2^7 ? 1
What is the range of values that can be assigned to a variable of type short
?2mu15 through
What is the range of values that can be assigned to a variable of type byte
?2mu7 through 2mu7 ? 1
1. class Q7 {2. public static void main(String args[]) {3. double d = 12.3;4. Decrementer dec = new Decrementer();5. dec.decrement(d);6. System.out.println(d);7. }8. } 9.10. class Decrementer {11. public void decrement(double decMe) {12. decMe = decMe - 1.0;13. }14. }What value is printed out at line 6?
12.3
Compilation fails because of an error in line: public void process() throws RuntimeException
A Exception
class A {public void process() { System.out.print("A "); }public static void main(String[] args) {try { ((A)new B()).process(); }catch (Exception e) { System.out.print("Exception "); }
A Exception
if (true) throw new RuntimeException(); System.out.print("B");
A Exception
Which of the following is an event source?
A JButton object.
Which of the following statements about a Java interface is NOT true?
A Java interface must contain more than one method.
What does the following code do?smt=con.createStatement();
A Statement object is created to send sql commands to the database
smt=con.createStatement();
A Statement object is created to send sql commands to the database
2. What is the return type of the instanceof operator?
A boolean
What is the return type of the instanceof operator
A boolean
What is the return type of the instanceof operator?
A boolean
Decrementer dec = new Decrementer()
12.3
What is the output for y? int y = 0;for (int i = 0; i<10; ++i) {y += i;}
13
What is the size of the Short integer type in terms of bits?
16
int x=17, y=5;
17, 5, 22, 12, 85, 3, 2
Which of the following are valid declarations? Assume java.util
1Vector 2Set 3Map string,string
System.out.println(a++);
2
1 2 3
2 3
double d = 1.2d and double d = 1.2D
2 dap an
int c = 0xabcd and int d = 0XABCD
2 dap an
int x = 6; if (!(x > 3)) and int x = 6; x = ~x
2 dap an
int y = 9; x += y; and int y = 9; x = x + y;
2 dap an
passed by value and passed by value
2 dap an
String s = "123456789"; s = (s-"123").replace(1,3,"24") - "89"
2.delete(4,6), delete(2,5).insert( 1, "24")
double d = 1.2d5
2.double d = 1.2d, 1.2D
for( int i=0; i< x.length; i++ ) System.out.println(x[i])
2.for(int z : x), dai nhat
int[] ages = { 9, 41, 49 }; int sum = 0
2.i<ages.length, for (int i:ages)
Line 46 will compile if enclosed in a try block, where TestException is caught
2.if the enclosing, is caught
Which of the following are legal import statements
2.import...Vector, Vector.*
int d = 0XABCD
2.int c = 0xabcd, dai nhat
java -ea test file1 file2
2.java -ea test, dai nhat
command line on a Windows system
2.must contain the statement, the file
Which methods return an enum constant's name
2.name(), toString()
Test t = (new Base()).new Test(1)
2.new Test(1), new Test(1, 2)
String x = "Hello"; int y = 9; if (x == y)
2.ngan nhat, x=x+y
Suppose class Supe, in package packagea, has a method called doSomething(). Suppose class Subby, in package packageb, overrides doSomething()
2.public, protected
class bbb.Bbb, which extends aaa.AAA, wants to override callMe(). Which access modes for callMe() in aaa.AAA will allow this
2.public, protected
protected double getSalesAmount() { return 1230.45; }
2.public, protected
Which of the following signatures are valid for the main() method entry point of an application
2.static void...(String arg[])
When you declare a block of code inside a method to be synchronized, you can specify the object on whose lock the block should synchronize
2.the method always, nhat
Which of the following may override a method whose signature is void xyz(float f)
2.void, public void xyz(float f)
int[] x = new int[25]
2.x[24]=0, x.length is 25
System.out.println( - -b * a + c *d - -);
24
Identify, from among the following, the incorrect variable name(s).
2nd
Identify, from among the following, the incorrect variable name(s)
2ndName
1. What is the value of x after the is performed x = 23 % 4
3
5. What is 7 % -4?
3
What is 7 % -4
3
What is 7 % -4?
3
What is the value of x after the following operation is performed
3
public class PassPrimitiveByValue { public static void main(String[] args) {
3
Which of the following statements are true?
A byte can represent between -128 to 127
1. StringBuffer sbuf = new StringBuffer();2. sbuf = null;3. System.gc();
After line 2 executes, the StringBuffer object is eligible for garbage collection.
The string created on line 2 does not become eligible for garbage collection in this code
After line 3
Suppose prim is an int and wrapped is an Integer. Which of the following are legal Java statements?
All
When a negative long is cast to a byte, what are the possible values of the result?
All
Select correct statement(s) about remote class
All It must extend;It must implement;It is the class
Select correct statement about RMI
All allow programmers;use object serialization;RMI applications
Which of these statement is incorrect?
All object of a class are allotted memory for the methods defined in the class.
Which of the following may legally appear as the new type (between the parentheses) in a cast operation
All of
9. When a negative long is cast to a byte, what are the possible values of the result?
All of the above
9. Which of the following may legally appear as the new type (between the parentheses) in a cast operation?
All of the above
Which of the following is considered by the text to be the most important consideration when designing a class?
Each class should represent a single concept or object from the problem domain.
When a negative long is cast to a byte, what are the possible values of the result?
All of the above
Which of the following may legally appear as the new type (between the parentheses) in a cast operation?
All of the above
may legally appear as the new type (between the parentheses) in a cast operation
All of the above
negative long is cast to a byte
All of the above
Which of the following statements is true?
All of the above.
Which of the following constant are defined in Boolean wrapper?
All of the mentioned
Which of the following constant are defined in Character wrapper?
All of the mentioned
Which of these Exception handlers cannot be type parameterized?
All of the mentioned
Which of these can be overloaded?
All of the mentioned
Which of these can be used to diffrentiate two or more methods having same name?
All of the mentioned
Which of these data tupe can be used for a method having a return statement in it?
All of the mentioned
Which of these is static variable defined in Collections?
All of the mentioned
Which of these method is a rounding function of Math class?
All of the mentioned
Which of these methods can be used to convert all characters in a String into a character array?
All of the mentioned
Which of these methods can be used to writing console output?
All of the mentioned
Which of these methods is called when observed object has changed?
All of the mentioned
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?
All of the mentioned
What is the use of try & catch?
All of the mentioned.
Which of the following may legally appear as the new type (between the parentheses) in a cast operation? (Choose one.)
All of the others
An enum definition may contain the main() method of an application
All the above
An enum definition may contain the main() method of an application.
All the above
Select correct statement about RMI
All the above
Select correct statement about RMI. (choose 1)
All the above
Suppose prim is an int and wrapped is an Integer. Which of the following are legal Java statements
All the above
Suppose prim is an int and wrapped is an Integer. Which of the following are legal Java statements? (Choose one.)
All the above
System.out has a println() method
All the above
System.out has a println() method.
All the above
When a negative long is cast to a byte, what are the possible values of the result
All the above
When a negative long is cast to a byte, what are the possible values of the result? (Choose one.)
All the above
Which of the following are methods of the java.util.SortedSet interface
All the above
Which of the following are methods of the java.util.SortedSet interface?
All the above
Which of the following are valid mode strings for the RandomAccessFile constructor
All the above
Which of the following are valid mode strings for the RandomAccessFile constructor? (Choose one.)
All the above
Which of the following calls may be made from a non-static synchronized method
All the above
Which of the following calls may be made from a non-static synchronized method? (Choose one.)
All the above
Select correct statement(s) about remote class
All the others choices
Select correct statement(s) about remote class.(choose one)
All the others choices
Select correct statements about remote interface
All the others choices
Select correct statements about remote interface. (choose 1)
All the others choices
Which of the following is incorrect statement about packages?
All variables are static and methods are public if interface is defined pubic
Which of the following may legally appear as the new type (between the parentheses) in a cast operation?
All: Abstract,Final,Primitives
When a negative long is cast to a byte, what are the possible values of the result?
All:Positive,Zero,Negative
Select from among the following what Java can do?
Either (a) or (b) or (c) above
Select from among the following what Java can do?
Either (a) or (b) or (c) above.
The wrapping up of data and functions into a single unit is called
Encapsulation
What is the process by which we can control what parts of a program can access the members of a class?
Encapsulation
Which of the following best describes the use of the synchronized keyword?
Ensures only one thread at a time may access a method or object
Which of these is wrapper for simple data type float?
Float
The concept of multiple inheritance is implemented in Java by
Extending one class and implementing & Implementing two or more interfaces
Which of the following are true? (Choose all that apply.)
An enum definition may contain the main() ,You can call an enum's toString() method.,You can call an enum's wait() method.,You can call an enum's notify() method.
You want to find out the value of the last element of an array. You write the following code. What will happen when you compile and run it.?public class MyAr{public static void main(String argv[]){int[] i = new int[5];System.out.println(i[5]);}}
An error at run time
An exception is thrown at runtime
An exception
1. import java.util.*;2.3. public class Apple {4. public static void main(String[] a) {5. Set<Apple> set = new TreeSet<Apple>();
An exception is thrown at line 7.
Which of the following is not true?
An interface can implement another interface.
Which most closely matches a description of a Java Map?
An interface that ensures that implementing classes cannot contain d
Which statement is true regarding an object
An object is an instance of a class
Which statement is true regarding an object?
An object is an instance of a class
The program cannot compile because the compiler cannot determine which max method should be invoked
Analyze the following code
Since x is an instance variable, it cannot be directly used inside a main method. However, it can be accessed through an object such as foo in
Analyze the following code and choose the correct answer
Which of the following reference types cannot be generic?
Anonymous inner class
A Java monitor must either extend Thread or implement Runnable
F
A signed data type has an equal number of non-zero positive and negative values available
F
A thread wants to make a second thread ineligible for execution. To do this, the first thread can call the yield() method on the second thread
F
The element method alters the contents of a Queue
F
When using the GridBagLayout manager, each new component requires a new instance of the GridBagConstraints class.
F
the two classes are in different packages, and class X has a protected method called abby(), then any instance of Y may call the abby() method of any
F
11. True or false: If class Y extends class X, the two classes are in different packages, and class X has a protected method called abby(), then any instance of Y may call the abby() method of any other instance of Y.
False
14. Java arrays always start at index 1.
False
14. The developer can force garbage collection by calling System.gc().
False
24. The following line of code is valid. int x = 9; byte b = x;
False
3. A Java monitor must either extend Thread or implement Runnable.
False
A Java monitor must either extend Thread or implement Runnable.
False
A signed data type has an equal number of non-zero positive and negative values
False
A signed data type has an equal number of non-zero positive and negative values available.
False
A thread wants to make a second thread ineligible for execution. To do this, the first thread can call the yield() method on the second thread.
False
If class Y extends class X, the two classes are in different packages, and class X has a protected method called abby(), then any instance of Y may call the abby() method of any other instance of Y.
False
If class Y extends class X, the two classes are in different packages, and class X has a protected method called abby(), then any instance of Y may call the abby() method of anyother instance of Y.
False
Java arrays always start at index 1
False
Java arrays always start at index 1.
False
The developer can force garbage collection by call System.gc()
False
The developer can force garbage collection by calling System.gc().
False
The element method alters the contents of a Queue.
False
Which of the following is the default Layout Manager for an Applet?
FlowLayout
(o instanceof B) && (!(o instanceof C))
Given three classes A,B,C, where B is a subclass of A and C is a subclass of B, which one of these Boolean expressions is true when an object denoted
Which of the following is not necessarily related to RMI?
Graphical User Interface
True or false: If class Y extends class X, the two classes are in different packages, and class X has a protected method called abby(), then any instance of Y may call the abby() method of any other instance of Y.
False
int x = 9; byte b = x
False
int x = 9; byte b = x;
False
Which of these class is not related to input and output stream in terms of functioning?
File
String s1 = "Hello"; String s2 = "Hello";
Hello equals Hello -> true
Give the following declarations: Vector plainVec; Vector<String> fancyVec; If you want a vector in which you know you will only store strings, what are the advantages of using fancyVec rather than plainVec?
Attempting to add anything other than a string to fancyVec results in a compiler error.
If you want a vector in which you know you will only store strings, what are the advantages of using fancyVec rather than plainVec
Attempting to...compiler error
public interface B inheritsFrom A
B extends A
Compilation of class A will fail. Compilation of class B will succeed
B fail, A succeed
class A extends Object; class B extends A; and class C extends B. Of these, only class C implements java.io.Serializable
B must have
Suppose class A extends Object; class B extends A; and class C extends B. Of these, only class C implements java.io.Serializable
B must have a
6. Suppose class A extends Object; class B extends A; and class C extends B. Of these, only class C implements java.io.Serializable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C?
B must have a no-args constructor.
Of these, only class C implements java.io.Serializable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C?
B must have a no-args constructor.
Suppose class A extends Object; class B extends A; and class C extends B. Of these, only class C implements java.io.Serializable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C?
B must have a no-args constructor.
Suppose class A extends Object; class B extends A; and class C extends B. Of these, only class C implements java.io.Serializable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C? (Choose one.)
B must have a no-args constructor.
i = i++ + i
I = 1
Which of these method returns the remainder of dividend / devisor?
IEEEremainder()
Which of these methods is not a Locale class?
INDIA
Which exception is thrown by read() method
IOException
Which of these exception is thrown by close() and read() methods?
IOException
Which is four-step approach to help you organize your GUI thinking.
Identify needed components.Isolate regions of behavior. Sketch the GUI.Choose layout managers.
Which is four-step approach to help you organize your GUI thinking
Identify, Isolate, Sketch
Which of these statement is incorrect?
If a method is returning a value the calling statement must have a varible to store that val
Which of the following is true regarding subclasses?
If a subclass does not call the superclass constructor, it must have a constructor without parameters.
Suppose a method called finallyTest() consists of a try block, followed by a catch block, followed by a finally block
If the JVM doesn't crash
Suppose a method called finallyTest() consists of a try block
If the JVM doesn't crash and
Suppose a method called finallyTest() consists 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?
If the JVM doesn't crash and the code does not execute a System.exit() call, the finally
1. Suppose a method called finallyTest() consists 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?
If the JVM doesn't crash and the code does not execute a System.exit() call, the finally block will always execute.
Suppose a method called finallyTest() consists 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?
If the JVM doesn't crash and the code does not execute a System.exit() call,the finally block will always execute.
Suppose a method called finallyTest() consists of a try block, followed by acatch 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? (Choose one.)
If the JVM doesn't crash and the code does not execute a System.exit() call,the finally block will always execute.
Suppose you want to create a class that compiles and can be serialized and deserialized without causing an exception to be thrown. Which statements are true regarding the class? (Choose all correct options.)
If the class implements java.io.Externalizable, it must have a no-args constructor.,If the class implements java.io.Serializable and does not implement java.io.Externalizable, its nearest superclass that doesn't implement Serializable must have a no-args constructor.
Under which of the following conditions can you have local variables with identical names?
If their scopes do not overlap.
Which of the following is the most appropriate way to handle invalid arguments in a public method
IllegalArgumentException
appropriate way to handle invalid arguments in a public method
IllegalArgumentException
Which of these exceptions is thrown by remover() method?
IllegalStateException
What lines are output if the constructor at line 3 throws a MalformedURLException?
Bad URL , Doing finally part , Carrying on
What lines are output if the constructor at line 3 throws a MalformedURLException
Bad URL, Doing finally, Carrying
1. public class Test extends Base {2. public Test(int j) {3. }4. pu5. super(j, k);6. }7. }
Base() { }.Base(int j, int k) { }
Choose the valid identifiers from those listed here.
BigOlLongString,$int,bytes,$1,finalist
1. Choose the valid identifiers from those listed here. (Choose all that apply.)
BigOlLongStringWithMeaninglessName$int bytes $1 finalist
Choose the valid identifiers from those listed here. (Choose all that apply.)
BigOlLongStringWithMeaninglessName.$int.bytes.1.$.finalist
Given a class named Book, which one of these is a valid constructor declaration for the class
Book(Book b) { }
Given a class named Book, which one of these is a valid constructor declaration for the class?
Book(Book b) { }
Which of these return type of hasNext() method of an iterator?
Boolean
In addition to JDK there are a number of Java commercial development tools
Borland JBuilder
In addition to JDK there are a number of Java commercial development tools available for Java programmers. Select from among the following such Java commercial development tool available.
Borland JBuilder
An abstract class cannot be instantiated. II. Constructors cannot be abstract
Both (I) and (II) above
I. 999. II. (hex)23.
Both (I) and (II) above
Which of the following is/are not hexadecimal numbers?
Both (I) and (II) above
Which of the following statements about abstract methods/classes in Java is/aretrue?
Both (I) and (II) above
I. Float x = 238.88; II. Double y = 0x443;
Both (I) and (III) above
I. boolean a = (boolean) 1; II. boolean b = (false && true);
Both (I) and (III) above
Select the invalid assignment statement(s) from the following:
Both (I) and (III) above
Which of the following expressions will produce errors upon compilation?
Both (I) and (III) above
Examine the following code snippets to identify the legal loop constructs:
Both (I) and (IV) above
I. int number();II. float average[];III. double[] marks;IV. counter int[];V. []double marks;
Both (II) and (III) above
Which of the following statements is/are valid array declarations?
Both (II) and (III) above
Which of the following will produce an error?
Both (III) and (IV) above
Which of the following will produce an error?I. byte a1 = 2, a2 = 4, a3;II. short s = 16;III. a2 = s;IV. a3 = a1 * a2;
Both (III) and (IV) above
Which of the following is/are valid comment(s) in java?
Both (a) and (b)
An overloaded method consists of
Both (a) and (b) above
Study the statements: 1)When a JDBC connection is created, it is in auto-commit mode 2)Once auto-commit mode is disabled, no SQL statements will be committed until you call the method commit explicitly
Both 1 and 2 are true
Study the statements:1)When a JDBC connection is created, it is in auto-commit mode2)Once auto-commit mode is disabled, no SQL statements will be committed until you call the method commit explicitly
Both 1 and 2 are true
When a JDBC connection is created, it is in auto-commit mode
Both 1 and 2 are true
Only object references are converted automatically; to change the type of a primitive, you have to do a cast
Both primitives
1. Which of the following statements is correct? (Choose one.)
Both primitives and object references can be both converted and cast.
Which of the following statements is correct?
Both primitives and object references can be both converted and cast.
Which of the following statements is correct? (Choose one.)
Both primitives and object references can be both converted and cast.
Which statement is true about the following method?int selfXor(int i) { return i ^ i;}
It always returns 0.
int selfXor(int i) { return i ^ i;
It always returns 0.
Which statements are correct about the anchor field?
It is a fi& A valid settt
12. Given the following,Map<String> names = new HashMap<String>();which of the following are legal? (Choose all that apply.)
Iterator<String> iter = names.iterator().for (String s:names)
Map<String> names = new HashMap<String>(); which of the following are legal? (Choose all that apply.)
Iterator<String> iter = names.iterator();, for (String s:names)
Given the following:List<String> names = new ArrayList<String>();which of the following are legal? (Choose two.)
Iterator<String> iter = names.iterator();for (String s:names)
List<String> names = new ArrayList<String>();
Iterator<String> iter = names.iterator();for (String s:names)
is a set of java API for executing SQL statements
JDBC
is a set of java API for executing SQL statements.
JDBC
Which of the following language is Architecture-Neutral
Java
Which of the following language is Architecture-Neutral?
Java
toRadian() and toDegree() methods were added by which version of Java?
Java 2.0
Which is the latest version of the Java language?
Java 5.0
JAR File stands for
Java Archive File
Which of the following is a valid declaration of an object of class Box?
Box obj = new Box();
Which of the following is a character stream?
BufferedInputStream
Which of these class is used to read characters and strings in Java from console?
BufferedReader
You can determine all the keys in a Map in which of the following ways?
By getting a Set object from the Map and iterating through it
You can determine all the keys in a Map in which of the following ways?
By getting a Set object from the Map and iterating through it.
Java compiler javac translates Java source code into
Byte code
Which of these is a type of stream in Java?
Byte stream
Which of the following are legal argument types for a switch statement?
Byte;Int;Char
Which of these class is used to read from byte array?
ByteArrayInputStream.
When you compile a program written in the Java programming language,the compiler converts the human-readable source file into platform- independent code that a Java Virtual Machine can understand. What is this platform-independent code called?
Bytecode
class A extends Object; Class B extends A; and class C extends B. Of these, only class C implements java.io.Externalizable
C must have
Suppose class A extends Object; Class B extends A; and class C extends B. Of these, only class C implements java.io.Externalizable
C must have a
6. Suppose class A extends Object; Class B extends A; and class C extends B. Of these, only class C implements java.io.Externalizable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C?
C must have a no-args constructor.
6. Which of the following are valid arguments to the DataInputStream constructor?
FileInputStream
Which of the following are valid arguments to the DataInputStream constructor
FileInputStream
Which of the following are valid arguments to the DataInputStream constructor?
FileInputStream
Which of the following are valid arguments to the DataInputStream constructor? (Choose one.)
FileInputStream
Which of these class contains the methods used to write in a file?
FileInputStream
Which of these class is used to read and write bytes in a file?
FileInputStream
Which of these class is used to read from a file?
FileInputStream
are valid arguments to the DataInputStream constructor
FileInputStream
Which of these exception is thrown in cases when the file specified for writing it not found
FileNotFoundException
Which of the following is a character stream?
FileReader
Which of these class is used to read characters in a file?
FileReader
1. Suppose you want to read a file that was not created by a Java program. The file contains lines of 8-bit text, and the 8-bit encoding represents the local character set, as represented by the cur- rent default locale. The lines are separated by newline characters. Which strategy reads the file and produces Java strings?
FileReader Pass LineNumberReader. UseLineNumberReader's readLine() method.
The file contains lines of 8-bit text, and the 8-bit encoding represents the local character set, as represented by the cur- rent default locale. The lines are separated by newline characters
FileReader instance
What modifier is to be used If you wish to declare that you want to no longer allow subclasses to override your variables or methods?
Final
To declare a constant MAX_LENGTH as a member of the class, you write
Final static double MAX_LENGTH = 99.98;.
To declare a constant MAX_LENGTH as a member of the class, you write
Final static float MAX_LENGTH = 99.98
What is the process of defining more than one method in a class differentiated by method signature?
Function overloading
What is the process of defining more than one method in a class differentiated by parameters?
Function overloading
How can you force garbage collection of an object
Garbage collection
7. How can you force garbage collection of an object?
Garbage collection cannot be forced.
How can you force garbage collection of an object
Garbage collection cannot be forced.
How can you force garbage collection of an object?
Garbage collection cannot be forced.
How can you force garbage collection of an object? (Choose one.)
Garbage collection cannot be forced.
What are generic methods?
Generic methods are methods that introduce their own type parameters.
Legal at compile time, but might be illegal at runtime
Given the following class definitions and the reference declarations, what can be said about the statement y = (Sub) x
By simply referring to the class as net.basemaster.Base
Given the following class, which of these is valid way of referring to the class from outside of the package net.basemaster?
Field j is accessible in all classes in other packages
Given the following definition of a class, which fields are accessible from outside the package com.corporation.project
Consider the following code: Raccoon rocky;SwampThing pogo;Washer w;rocky = new Raccoon();w = rocky;pogo = w;
Line 7 will not compile; an explicit cast is required to convert a Washer to a SwampThing.
The Point class cannot be instatiated at line 15
Line.Point p = new Line.Point()
10. class Line {11. public static class Point { }12. }13.14. class Triangle {
Line.Point p = new Line.Point();
public static class Point { }
Line.Point p = new Line.Point();
Which of the following classes implements a FIFO Queue
LinkedList
Which of the following classes implements a FIFO Queue?
LinkedList
Which of the following classes implements a FIFO Queue? (Choose one.)
LinkedList
Which of these standard collection classes implements a linked list data structure?
LinkedList
Which of these interface handle sequences?
List
Which of these is an correct way making a list that is upper bounded by class Number?
List
Which of these iterators can be used only with List?
ListIterator
Which of these class produce objects with respect to geographical locations?
Locale
Java compiler javac translates Java source code into
Machine code
The blank space in the following sentence has to be correctly filled
Machine code
Which is a special file that contains information about the files packaged in a JAR file
Manifest file
Which of these object stores association between keys and values?
Map
Which two of the following interfaces are at the top of the hierarchies in the Java Collections Framework?
Map;Collection
In java language error processing is built into the language
Mark the incorrect statement from the following
Which of these class contains only floating point functions?
Math
Which of these class provides various types of rounding functions?
Math
In java, objects are passed as
Memory address
The____class is used to implement a pull-down menu that provides a number of items to select from.
Menu
class is used to implement a pull-down menu that provides a number of items to select from
Menu
number of items to select from.
Menu
What is the process of defining a method in subclass having same name & type signature as a method in its superclass?
Method overriding
Which of the following statements are true?
Methods cannot be overriden to be more private
A dialog prevents user input to other windows in the application unitl the dialog is closed.
Modal
A____dialog prevents user input to other windows in the application unitl the dialog is closed.
Modal
dialog prevents user input to other windows in the application unitl the dialog is closed
Modal
MVC is short call of
Model-View-Controller
Mutator methods exhibit which of the following types of side effect?
Modification of the implicit parameter.
How restrictive is the default accessibility compared to public, protected, and private accessibility?
More restrictive than protected, but less restrictive than private
To override a superclass method in a subclass, the subclass method ____.
Must use the same method name and the same parameter types.
System.out.println("x = " +x); System.out.println("Y = " +y);
MyClass mc=new MyClass();
(3)
MyOtherClass(int n) { m = n; } //(2)
Which of these type parameters is used for a generic class to return and accept a number?
N
Which of these type parameters is used for a generic methods to return and accept a number?
N
What is the stored in the object obj in following lines of code?
NULL
10. class Nav{11. public enum Direction { NORTH, SOUTH, EAST, WEST }12. }13. public class Sprite{
Nav.Direction d = Nav.Direction.NORTH;
public enum Direction { NORTH, SOUTH, EAST, WEST }
Nav.Direction d = Nav.Direction.NORTH;
Nav.Direction d = Nav.Direction.NORTH
Nav.Direction.NORTH
10. When a negative byte is cast to a long, what are the possible values of the result?
Negative
When a negative byte is cast to a long, what are the possible values of the result
Negative
When a negative byte is cast to a long, what are the possible values of the result?
Negative
When a negative byte is cast to a long, what are the possible values of the result? (Choose one.)
Negative
negative byte is cast to a long
Negative
1. When is it appropriate to write code that constructs and throws an error?
Never
When is it appropriate to write code that constructs and throws an error
Never
When is it appropriate to write code that constructs and throws an error?
Never
1. Suppose ob1 and ob2 are references to instances of java.lang.Object. If (ob1 == ob2) is false, can ob1.equals(ob2) ever be true?
No
Can command line arguments be converted into int automatically if required?
No
Suppose ob1 and ob2 are references to instances of java.lang.Object. If (ob1 == ob2) is false, can ob1.equals(ob2) ever be true?
No
Will the following code compile?
No
ob1 == ob2
No
An abstract class must declare that it implements an interface
None
To change the current working directory, call the changeWorkingDirectory() method of the File class
None
When you construct an instance of File, if you do not use the file-naming semantics of the local machine, the constructor will throw an IOException
None
While testing some code that you are developing, you notice that an ArrayIndexOutOf- BoundsException is thrown. What is the appropriate reaction
None
When the application is run, thread hp1 will execute to completion, thread hp2 will execute to completion, then thread hp3 will execute to completion
None of
Which of the following operations might throw an ArithmeticException
None of
1. Given a string constructed by calling s = new String("xyzzy"), which of the calls modifies the string?
None of the above
An abstract class may be instantiated.
None of the above
Given a string constructed by calling s = new String("xyzzy"), which of the calls modifies the string
None of the above
Given a string constructed by calling s = new String("xyzzy"), which of the calls modifies the string?
None of the above
Given a string constructed by calling s = new String("xyzzy"), which of the calls modifies the string? (Choose one.)
None of the above
How do you change the value that is encapsulated by a wrapper class after you have instan- tiated it?
None of the above
Readers have methods that can read and return floats and doubles
None of the above
Readers have methods that can read and return floats and doubles.
None of the above
Select the list of primitives ordered in smallest to largest bit size representation.
None of the above
To change the current working directory, call the setWorkingDirectory() method of the File class.
None of the above
Which of the following are legal loop definitions
None of the above
11. Which of the following statements are true?
None of the above.
16. How do you change the value that is encapsulated by a wrapper class after you have instan- tiated it?
None of the above.
A. Enclose the offending code in a try block, with a catch block for ArrayIndexOutOfBoundsException that does nothing.
None of the above.
A. Readers have methods that can read and return floats and doubles.
None of the above.
A. To change the current working directory, call the setWorkingDirectory() method of the
None of the above.
When you construct an instance of File, if you do not use the file-naming semantics of the local machine, the constructor will throw an IOException.
None of the above.
Which of the following are legal loop definitions? (Choose one.)
None of the above.
Which of the following is true?
None of the above.
Which of the statements below are true? (Choose all that apply.)
None of the above.
While testing some code that you are developing, you notice that an ArrayIndexOutOf- BoundsException is thrown. What is the appropriate reaction?
None of the above.
change the value that is encapsulated by a wrapper class after you have instan
None of the above.
How do you change the value that is encapsulated by a wrapper class after you have instan-tiated it?
None of the above:setXXX(),Parse,equals
What is the return type of Constructors?
None of the mentioned
Which of these data type is returned by every method of OutputStream?
None of the mentioned
Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?
None of the mentioned
Which of the following operations might throw an ArithmeticException?
None of the others
1. How do you generate a string representing the value of a float f in a format appropriate for a locale loc?
NumberFormat nf = NumberFormat.getInstance(loc);String s = nf.format(f);
How do you generate a string representing the value of a float f in a format appropriate for a locale loc
NumberFormat.getInstance(loc)
Which of the following statements is true? (Choose one.)
Objct refences can be conrted in both metod cals and asignmnts, and the rules governing these conersons are idetical.
In Java, every class declared without an extends clause automatically extends which class?
Object
Which of these class is superclass of all other classes?
Object
Which of these class is superclass of every class in Java?
Object class
Which of these method of Object class can clone an object?
Object clone()
6. Which of the following statements is true? (Choose one.)
Object references can be converted in both method calls and assignments, and the rules governing these conversions are identical.
Which of the following statements is true?
Object references can be converted in both method calls and assignments, and the rules governing these conversions are identical.
Which of the following statements is true?
Object references can be converted in both method calls and assignments,and the rules governing these conversions are identical.
Which of these interface is not a member of java.io package?
ObjectFilter
Which of the following stream is used for Object Serialization
ObjectOutputStream
Which of the following stream is used for Object Serialization?
ObjectOutputStream
The code will compile as is. No modification is needed
On line 1, remove
1. final class Aaa2. {3. int xxx;4. void yyy() { xxx = 1; }5. }
On line 1, remove the final modifier.
3. How many locks does an object have?
One
How many locks does an object have
One
How many locks does an object have?
One
How many locks does an object have? (Choose one.)
One
I. Private. II. Public. III. Protected
Only (II) above
Which access specifiers should be implemented in a class for all interface methods?
Only (II) above ,public
Suppose class A extends Object; Class B extends A; and class C extends B. Of these, only class C implements java.io.Externalizable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C?
C must have a no-args constructor.
Suppose class A extends Object; Class B extends A; and class C extends B. Of these, only class C implements java.io.Externalizable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C? (Choose one.)
C must have a no-args constructor.
Suppose class A extends Object; Class B extends A; and class C extends B.Of these, only class C implements java.io.Externalizable. Which of the following must be true in order to avoid an exception during deserialization of an instance of C?
C must have a no-args constructor.
The program has a syntax error on Line 5 because java.util.Calendar is an abstract class
Calendar[] calendars = new Calendar[10];
What would the argument passing method be which is used by the above Program - III
Call by value
What would the argument passing method be which is used by the above Program - III?
Call by value
Which of the following questions should you ask yourself in order to determine if you have named your class properly?
Can I visualize an object of the class?
In Java, a try block should immediately be followed by one or more .................... blocks
Catch
In Java, a try block should immediately be followed by one or more .................... blocks.
Catch
list of primitives ordered in smallest to largest bit size representation
D. char, int, float, long
An abstract data type typically comprises a ............... and a set of .................. respectively
Data representation, operations
Which of the following may follow the static keyword?
Data;Methods;Code blocks enclosed in curly brackets
Which of the following stream is/are used to handle primitive data types?
DataInputStream
There are two classes in Java to enable communication using datagrams
DataPacket and DataSocket
There are two classes in Java to enable communication using datagrams namely
DataPacket and DataSocket
There are two classes in Java to enable communication using datagrams namely.
DataPacket and DataSocket
Every Java applet or application is composed of at least one
Class definition
Which of these method of Object class is used to obtain class of an object at run time?
Class getclass()
How do the imports affect the time required to load the class?
Class loading takes no additional time
Suppose a source file contains a large number of import statements and one class definition.How do the imports affect the time required to load the class?
Class loading takes no additional time
How do the imports affect the time required to load the class?
Class loading takes no additional time.
Suppose a source file contains a large number of import statements and one class definition. How do the imports affect the time required to load the class?
Class loading takes no additional time.
Suppose a source file contains a large number of import statements and one class definition. How do the imports affect the time required to load the class? (Choose one.)
Class loading takes no additional time.
Which of the following is not a valid statement?
Class methods can access instance variables or instance methods directly
If ClassA extends ClassB, then
ClassB is a base class
Which of these exceptions is thrown by compareTo() method defined in double wrapper?
ClassCastException
Which of these class defines how the classes are loaded?
ClassLoader
Which of these Exceptions is thrown by loadClass() method of ClassLoader class?
ClassNotFoundException
4. Which of the following may not be synchronized?
Classes
Which of the following may not be synchronized
Classes
Which of the following may not be synchronized?
Classes
Which of the following may not be synchronized? (Choose one.)
Classes
11. Which of the following may be declared final? (Choose all that apply.)
Classes Data Methods
Which of the following may be declared final? (Choose two.)
Classes Methods
A package is a collection of
Classes and interfaces
.................... are used to document a program and improve its readability
Comments
are used to document a program and improve its readability
Comments
In order for objects in a List to be sorted, those objects must implement which interface and method?
Comparable interface and its compareTo method.
In order for objects in a List to be sorted, those objects must implement which interface and method? (Choose one.)
Comparable interface and its compareTo method.
In order for objects in a List to be sorted, those objects must implement which interface and method
Comparable...compareTo
Suppose a source file contains a large number of import statements. How do the imports affect the time required to compile the source file?
Compilation takes slightly more time.
Suppose a source file contains a large number of import statements. How do the imports affect the time required to compile the source file? (Choose one.)
Compilation takes slightly more time.
MyClass mc = new MyClass();
Consider
Which of these is correct about passing an argument by call-by-value process?
Copy of argument is made into the formal parameter of the subroutine.
Suppose you want to read a file that was not created by a Java program. The file contains lines of 8-bit text, and the 8-bit encoding represents the local character set, as represented by the cur- rent default locale. The lines are separated by newline characters. Which strategy reads the file and produces Java strings?
Create a FileReader instance. Pass it into the constructor of LineNumberReader. UseLineNumberReader's readLine() method.
What does the following line of code do? Textfield text = new Textfield (10);
Creates text object that can hold 10 columns of text
Which of the following calls may be made from a non-static synchronized method?
A call to the same method of the current object.,A call to the same method of a different instance of the current class.,A call to a different synchronized method of the current object.,A call to a static synchronized method of the current class.
A final object's data cannot be changed.
A final object cannot be reassigned a new address in memory.
Which of the following is true?
A finally block is executed whether an exception is thrown or not.
What is Collection in Java?
A group of objects
Which of the following statements describes an assertion?
A logical condition in a program that you believe to be true.
Which of the following is true for method overriding?
A method in the subclass that has the same name, same arguments and same return type as a method in the super class is orverridden
Which of the following most closely describes the process of overriding?
A method with the same name completly replaces the functionality of a method earlier in the hierarchy
Which of the following is incorrect statement about packages?
A package can be renamed without renaming the directory in which the classes are stored
The method getAccountType() is invoked in the code for printBalance().What is the compile-time type of the receiver of this method invocation
Account
The method getAccountType() is invoked in the code for printBalance().What is the compile-time type of the receiver of this method invocation?
Account
When the user selects a menu item, _______ event is generated
Action event
When the user selects a menu item,_____event is generated.
Action event
When the user selects a menu item, event is generated.
Action eventWhen you compile a program written in the Java programming language,the compiler converts the human-readable source file into platform- independent code that a Java Virtual Machine can understand. What is this platform-independent code called?|bytecode
When you use a timer, you need to define a class that implements the ____
ActionListener
Which of the following is the correct syntax for suggesting that the JVM performs garbage collection
System.gc();
Which of the following are true? (Choose all that apply.)
System.out has a println() method.
line prints double d in a left-justified field that is 20 characters wide, with 15 characters to the right of the decimal point
System.out.format("%-20.15f", d)
27. Which line prints double d in a left-justified field that is 20 characters wide, with 15 characters to the right of the decimal point?
System.out.format("%-20.15f", d);
720
System.out.println(" puzzel of 6 is = " + f.puzzel(6));
static int treeNo;
System.out.println("Tree "+ treeNo + " is created!");
The program compiles and runs fine and the output "Value is 2.0" is printed
System.out.println("Value is " + x[1]);
k is 2
System.out.println("i + j is " + i + j);
Which of the following will output -4.0
System.out.println(Math.ceil(-4.7));
The program has a syntax error because the two methods m have the same signature
System.out.println(m(2));
Which of these exceptions is thrown by methods of System class?
SystemException
Which of these exceptions is thrown by remover() method?
SystemException
Which of the following is not a built-in exception found in java API?
SystemFoundException
Which of the following is not a built-in exception found in java API?
SystemFoundException.
58881
T
Swing components cannot be combined with AWT components
T
Which of these type parameters is used for a generic class to return and accept any type of object?
T
Which of these type parameters is used for a generic methods to return and accept any type of object?
T
after execution of line 1, sbuf references an instance of the StringBuffer class. After execution of line 2, sbuf still references the same instance
T
The program has a compilation error because TempClass does not have a constructor with an int argument
TempClass temp = new TempClass(2);
/** Account represents a mutable bank account. **/class Account {double balance;
Temp_val
How does the set collection deal with duplicate elements?
The add method returns false if you attempt to add an element with a duplicate value
The applet's default constructor
The applet's default constructor
When you run an applet, which of the following is invoked first
The applet's default constructor
When you run an applet, which of the following is invoked first
The applet's default constructor.
When you run an applet, which of the following is invoked first?
The applet's default constructor.
1. public class Assertification {2. public static void main(String[] args) {3. assert args.length == 0;4 }5. }
The application must be run The args array must have one or more elements.
Identify, from among the following, the incorrect descriptions related to Java
The arithmetic operations *, /, %, + and - have the same level of precedence
Given the following code, what will be the outcome? public class Funcs extends java.lang.Math{public int add(int x, int y){return x + y;}public int sub(int x, int y){return x - y;}public static void main(String[]a){Funcs f = new Funcs();System.out.println("" + f.add(1, 2));}}
The code does not compile
public class Test {public static void main(String [] a){int [] b = [1,2,3,4,5,6,7,8,9,0]; System.out.println("a[2]=" + a[2]);}}
The code does not compile
Suppose you want to create a custom thread class by extending java.lang.Thread in order to provide some special functionality
Override run()
Suppose you want to create a custom thread class by extending java.lang.Thread in order to provide some special functionality. Which of the following must you do
Override run()
3. Suppose you want to create a custom thread class by extending java.lang.Thread in order to provide some special functionality. Which of the following must you do?
Override run().
Suppose you want to create a custom thread class by extending java.lang.Thread in order to provide some special functionality. Which of the following must you do?
Override run().
Suppose you want to create a custom thread class by extending java.lang.Thread in order to provide some special functionality. Which of the following must you do? (Choose one.)
Override run().
Why can't Java methods change parameters of primitive type?
Parameters of primitive type are considered by Java methods to be local variables.
Which of these is supported by method overriding in Java?
Polymorphism
1. Which of the following are appropriate situations for assertions?
Postconditions of a public method Preconditions of a private method Postconditions of a private method
Which access specifier is used for describing Applet Class?
Public
Which of these access specifiers can be used for a class so that it's members can be accessed by a different class in the different package?
Public
Which of these access specifiers can be used for an interface?
Public
Statement objects return SQL query results as
ResultSet
Statement objects return SQL query results as objects
ResultSet
Statement objects return SQL query results as____objects
ResultSet
Which of the following interfaces does not allow duplicate objects
Set
B b = new A(); b.print();
The code does not compile, the compiler returns a type error
The code compiles and executes; afterward, the current working directory contains a file called datafile
The code fails to compile
1. try {2. RandomAccessFile raf = new3. RandomAccessFile("datafile" ,"rw");4. BufferedOutputStream bos = new BufferedOutputStream(raf);
The code fails to compile.
Which of the following can you perform using the File class?
Return the nam:Delete a file
When does Exceptions in Java arises in code sequence?
Run Time
Select the exception class from among the following which is part of the java.lang package
RunTimeException
Select the exception class from among the following which is part of the java.lang package.
RunTimeException
Which of these interface is implemented by Thread class?
Runnable
Which of these interfaces is implemented by TimerTask class?
Runnable
There will be a compiler error, because class Greebo does not correctly implement the Runnable interface
Runnable interface
Which of these classes encapsulate runtime enviroment?
Runtime
All exception types are subclasses of the built-in class
RuntimeException
The program will compile without error and will throw java.lang.NullpointerException when run
RuntimeException re = null
Which exception is thrown by the getConnection() method of the DriverManager class?
SQLException
Which of the following interfaces does not allow duplicate objects?
Set
Which of these interface must contain a unique element?
Set
You need to create a class that will store unique object elements. You do not need to sort these elements but they must be unique.
Set
When should objects stored in a Set implement the java.util.Comparable interface
Set is a TreeSet
You can determine all the keys in a Map in which of the following ways
Set object from the Map
11. public abstract class Shape {12. int x;13. int y;14. public abstract void draw();15. public void setAnchor(int x, int y) {
Shape s = new Circle(); s.setAnchor(10,10); s.draw();
9. Suppose the type of xarr is an array of XXX, and the type of yarr is an array of YYY. When is the assignment xarr = yarr; legal?
Sometimes
9. When is x & y an int? (Choose one).
Sometimes
Suppose the type of xarr is an array of XXX, and the type of yarr is an array of YYY. When is the assignment xarr = yarr; legal
Sometimes
Suppose the type of xarr is an array of XXX, and the type of yarr is an array of YYY. When is the assignment xarr = yarr; legal?
Sometimes
Suppose the type of xarr is an array of XXX, and the type of yarr is an array of YYY. When is the assignment xarr = yarr; legal? (Choose one.)
Sometimes
When is x & y an int
Sometimes
When is x & y an int?
Sometimes
When is x & y an int? (Choose one).
Sometimes
xarr is an array of XXX, and the type of yarr is an array of YYY
Sometimes
Which of these interface is not a part of Java's collection framework?
SortedLis
Which of these interface is not a part of Java's collection framework?
SortedList
How do you specify what the program should do when the user clicks a button?
Specify the actions to take in a class that implements the ActionListener interface.
Given the following code, which of the following will compile? enum Spice { NUTMEG, CINNAMON, CORIANDER, ROSEMARY; }
Spice sp = Spice.NUTMEG; Object ob = sp;,Spice sp = Spice.NUTMEG; Object ob = (Object)sp;,Object ob = new Object(); Spice sp = (Spice)object;
Which of these data types is used by operating system to manage the Recursion in Java?
Stack
10. public class ClassA {11. public void count(int i) {12. count(++i);13. }14. } And:
StackOverflowError
ClassA a = new ClassA();
StackOverflowError
IllegalArgumentException
StackOverflowError
Which of the following types of side effects potentially violates the rule of minimizing the coupling of classes?
Standard output.
How comments that can be used in Automatic Class Documentation by javadoc tool are represented?
Started with /** and Ended with */
A(n) object is used to submit a query to a database
Statement
A(n)____object is used to submit a query to a database
Statement
object is used to submit a query to a database
Statement
8. Which of the following may be statically imported? (Choose all that apply.)
Static method names Static field names
Which of the following may be statically imported? (Choose two.)
Static method names Static field names
Which of the following may be statically imported?
Static method names,Method-local variable names
Which of the following may be statically imported?
Static method names;Static field names
Which of the following statements are true?
Static methods cannot be overriden to be non static
Which of these class contains all the methods present in Math class?
StrictMath
Which of these class is not a member class of java.io package?
String
Which of these data types is used to store command line arguments?
String
What code at line 3 produces the following output
String delim = "\\d+"
You have been given a design document for a veterinary registration
String markings, boolean neutered
s1 == s2
String s1 = " yes"
Which are the correct statements used for getting connection object to connect to SQL Server database?
String url ="jdbc:odbc:data_source_name"; Connection con = DriverManager.getConnection (url, "user", "password");
Which are the correct statements used for getting connection object to connect to SQL Server database
String url =jdbc:odbc
3. Which of the following expressions are legal? (Choose all that apply.)
String x = "Hello"; int y = 9; x += y; String x = "Hello"; int y = 9; x = x + y;
Which of the following expressions are legal?
String x = "Hello"; int y = 9; x += y;String x = "Hello"; int y = 9; x = x + y;
Which of these constructors is used to create an empty String object?
String()
Which of these is an oncorrect statement?
StringBuffer class is used to store string in a buffer for later use.
Which of these class is used to create an object whose character sequence is mutable?
StringBuffer()
Which of the following are incorrect form of StringBuffer class constructor?
StringBuffer(int size , String str)
Which of the following statements are true? (Choose all correct options.)
StringBuilder encapsulates a mutable string.,StringBuffer is threadsafe.
1. Which of the following statements are true? (Choose all correct options.)
StringBuilder encapsulates a mutable string.StringBuffer is threadsafe.
Which of the following statements are true?
StringBuilder is generally faster than StringBuffer., StringBuffer is threadsafe; StringBuilder is not.
6. Which of the following statements are true?
StringBuilder is generally faster than StringBuffer.StringBuffer is threadsafe; StringBuilder is not.
How do you use the File class to list the contents of a directory
String[] contents
1. How do you use the File class to list the contents of a directory?
String[] contents = myFile.list();
How do you use the File class to list the contents of a directory
String[] contents = myFile.list();
How do you use the File class to list the contents of a directory?
String[] contents = myFile.list();
How do you use the File class to list the contents of a directory? (Choose
String[] contents = myFile.list();
Which of the following statements are incorrect?
Strings in java are mutable.
Given a class named student, which of the following is a valid constructor declaration for the class?
Student (student s)
Given a class named student, which of the following is a valid constructor declaration for the class
Student (student s) { }
Which one of these is a valid constructor declaration for the class named student?
Student(student b) { }
The extends keyword creates a new
Subclass
When an overridden method is called from within a subclass, it will always refer to the version of that method defined by the
Subclass
What lines are output if the methods at lines 3 and 5 complete successfully without throwing any exceptions?
Success , Doing finally part , Carrying on
1. When a byte is added to a char, what is the type of the result?
int
What is the return type of the method getID() defined in AWTEvent class
int
When a byte is added to a char
int
When a byte is added to a char, what is the type of the result
int
When a byte is added to a char, what is the type of the result?
int
Which of the following variable declaration would NOT compile in a java program
int 1_var
Which of the following variable declaration would NOT compile in a java program?
int 1_var;
Given the following member declarations, which statement is true
int a & static int f() { return a; }
public float aMethod(float a, float b) throws Exception
int a,b float p,q
1. public class Test1 {2. public float aMethod(float a, float b) {3. }4.5. }
int aMethod(int,int).float aMethod(float,float,int)throws.private float aMethod(int a, int b, int c) { }
1. public class Test1 {2. public float aMethod(float a, float b) throws IOException {.. }3. }1. public class Test2 extends Test1 {
int aMethod(inta,intb) throws.public float aMethod(float p, float q) {...}
7. Which of the following are legal? (Choose all that apply.)
int c = 0xabcd; int d = 0XABCD;
Which of the following are legal? (Choose two.)
int c = 0xabcd; int d = 0XABCD;
Which of the following are legal?
int c = 0xabcd;int d = 0XABCD;
Which of the following methods is a method of wrapper Integer for obtaining hash code for the invoking object?
int hashCode()
error
int i=0; i<=2; System.out.println(i););
Which of the following lines will compile without warning or error
int i=10
Which of the following are legal loop constructions? (Choose one.)
int j = 0;for (int k=0, j+k != 10; j++,k++) { System.out.println("j=" + j + ", k=" + k);}
Which of the following expressions results in a positive value in x
int x = -1; x = x >>> 5
2. Which of the following expressions results in a positive value in x?
int x = -1; x = x >>> 5;
Which of the following are legal loop constructions? (Choose all that apply.)
intj=0;for(int k=0,j+k!= 10;j++,k++) { Syln("j="+j+",k="+ k)
Which of the following are fields of the GridBagConstraints class?
ipadx fill insets
The keyword extends refers to what type of relationship
is a
The keyword extends refers to what type of relationship?
is a
What relationship does the extends keyword represent
is a
Object oriented inheritance models the
is a kind of" relationship
When does an exception's stack trace get recorded in the exception object
is constructed
Which of these is method for testing whether the specified element is a file or a directory?
isFile()
Which of these method of Double wrapper can be used to check weather a given value is infinite or not?
isInfinite()
Which of these methods is not defined in both Byte and Short wrappers?
isInfinite()
Which of these methods is used to check for infinitely large and small values?
isInfinite()
Which of these methods is used to know whether a given Character object is part of Java's indentifiers?
isJavaIdentifierPart()
Which of these methods can be used to check whether the given value is a number or not?
isNaN()
Which of the following are methods of the Collection interface?
iterator isEmpty toArray
Which of these methods is used to obtain an iterator to the start of collection?
iterator()
What is the extension name of a Java source code file
java
Which of the following package stores all the standard java classes?
java
Which class provides locale-sensitive text formatting for date and time information?
java.text.DateFormat
Which of these packages contain all the collection classes
java.util
Which of the following classes implement java.util.List? (Choose two.)
java.util.ArrayList java.util.Stack
Which of the following classes implement java.util.List?
java.util.ArrayList, java.util.Stack
6. Which of the following classes implement java.util.List?
java.util.ArrayList.java.util.Stack
call returns true if a1 and a2 have the same length, and a1[i].equals(a2[i]) for every legal index i
java.util.Arrays.equals(a1, a2)
6. Given arrays a1 and a2, which call returns true if a1 and a2 have the same length, and a1[i].equals(a2[i]) for every legal index i?
java.util.Arrays.equals(a1, a2);
Given arrays a1 and a2, which call returns true if a1 and a2 have the same length, and a1[i].equals(a2[i]) for every legal index i?
java.util.Arrays.equals(a1, a2);
Given arrays a1 and a2, which call returns true if a1 and a2 have the same length, and a1[i].equals(a2[i]) for every legal index i? (Choose one.)
java.util.Arrays.equals(a1, a2);
The Swing component classes can be found in the
javax.swing
The Swing component classes can be found in the package.
javax.swing
Which of these methods can be used to obtain set of all keys in a map?
keySet()
Which of these method of class String is used to obtain length of String object?
length()
Which of these method of class StringBuffer is used to find the length of current character sequence?
length()
Which of these method of class StringBuffer is used to get the length of sequence of characters?
length()
After line 3 executes, the StringBuffer object is eligible for garbage collection
line 2 executes..collection
1. class SuperDuper2. {3. void aMethod() { }4. }5.6. class Sub extends SuperDuper7. {8. void aMethod() { }9. }
line 3: private; line 8: protected
Given the following code, and making no other changes, which combination of access modifiers (public, protected, or private) can legally be placed before aMethod() on line 3 and be placed before aMethod() on line 8?
line 3: private; line 8: protected
1. Cat sunflower;2. Washer wawa;3. SwampThing pogo;
line 7, because the runtime class of wawa cannot be converted to type SwampThing.
Which of these methods loads the specified dynamic library?
load()
Which of these methods is used to obtain value of invoking object as a long?
long longValue()
Which method can be defined only once in a program?
main method
Which of these method is given parameter via command line arguments
main()
Which of these methods must be made static?
main()
a) max(Collection c)
max(Comparator comp)
A final class may not contain non-final data fields
may not be extended
1. int x = 0, y = 4, z = 5;
message four
What would be the output from this code fragment
message four
What would be the output from this code fragment?
message four
What is process of defining two or more methods within same class that have same name but different parameters declaration?
method overloading
void callMe(String... names)
method, names is an array
Which access modifier allows you to access method calls in libraries not created in Java?
native
access modifier allows you to access method calls in libraries not created in Java
native
Which of the following are Java keywords?
new
Which of these operator is used to generate an instance of an exception than can be thrown by using throw?
new
Which of these operators is used to allocate memory for an object?
new
new class Foo { public int bar() { return 1; } }
new Foo()
10. interface Foo { int bar(); }11. public class Sprite {12. public int fubar( Foo foo) { return foo.bar(); }13. public void testFoo() {14. fubar(
new Foo() { public int bar(){return 1; } }
public int fubar( Foo foo) { return foo.bar(); }
new Foo() { public int bar(){return 1; } }
6. Which of the following are legal? (Choose all that apply.)
new Vector<String>();new Vector<String>();
Which of these methods can be used to move to next element in a collection?
next()
Which of these is a method can generate a boolean output?
nextBoolean()
void doSomething() throws IOException, EOFException
ngan-dai nhat, throws EOFException
Suppose a source file contains a large number of import statements and one class definition. How do the imports affect the time required to load the class
no additional time
Given a string constructed by calling s = new String("xyzzy"), which of the calls modifies the string
none
the string?
none of the above
14. What method call is used to tell a thread that it has the opportunity to run?
notify()
What method call is used to tell a thread that it has the opportunity to run?
notify()
method call is used to tell a thread that it has the opportunity
notify()
Which of these methods calls update() method?
notifyObserver()
Which of these classes are used by Byte streams for input and output operation?
nputStream
Line 13 will not compile because it is a static reference to a private variable
output is x = 104
Lines 5 and 12 will not compile because the method names and return types are missing
output x = 3
Line 12 will not compile, because no version of crunch() takes a char argument
output: int version
public String toString() { return "Point[" +x+ "," +y+ "]";
p = Point[10,20
Which of these keywords is used to define packages in Java?
package
Consider the following code: Cat sunflower;Washer wawa;SwampThing pogo;sunflower = new Cat();wawa = sunflower;pogo = (SwampThing)wawa;
The code will compile but will throw an exception at line 7, because the runtime class of wawa cannot be converted to type SwamThing.
The java.util.Arrays class has a binarySearch(int[] arr, int key) method. Which statements are true regarding this method? (Choose all that apply.)
The method is static.,The return value is the index in the array of key.,The elements of the array must be sorted when the method is called.
Which of the following statements about an inner class is true?
The methods of an inner class can access variables declared in the enclosing scope.
Calendar[] calendars = new Calendar[10];calendars[0] = new Calendar();
The program has a syntax error on Line 5 because java.util.Calendar is an abstract class
Is it possible to define a class called Thing so that the following method can return true under certain circumstances
Y
Is it possible to write code that can execute only if the current thread owns multiple locks
Y
TestThread3 ttt = new TestThread3
Y
1. class TestThread3 extends Thread {2. public void run() {3. System.out.println("Running");4. System.out.println("Done");5. }
Yes
3. Is it possible to write code that can execute only if the current thread owns multiple locks?
Yes
What are the legal types for whatsMyType
There are no possible legal types
10. What are the legal types for whatsMyType? short s = 10; whatsMyType = !s;
There are no possible legal types.
What are the legal types for whatsMyType?
There are no possible legal types.
What are the legal types for whatsMyType?short s = 10; whatsMyType = !s;
There are no possible legal types.
whatsMyType = !s;
There are no possible legal types.
Why is a static variable also referred to as a class variable?
There is a single copy available to all objects of the class.
What is the difference between the rules for method-call conversion and the rules for assignment conversion
There is no difference
difference between the rules for method-call conversion and the rules for assignment conversion
There is no difference
9. What is the difference between the rules for method-call conversion and the rules for assignment conversion?
There is no difference; the rules are the same.
What is the difference between the rules for method-call conversion and the rules for assignment conversion?
There is no difference; the rules are the same.
What is the difference between the rules for method-call conversion and the rules for assignment conversion? (Choose one.)
There is no difference; the rules are the same.
How can you ensure that multithreaded code does not deadlock
There is no single
How can you ensure that multithreaded code does not deadlock?
There is no single technique that can guarantee non-deadlocking code.
How can you ensure that multithreaded code does not deadlock? (Choose
There is no single technique that can guarantee non-deadlocking code.
Greebo g = new Greebo();
There will be a compiler error, because class Greebo does not correctly implement the Runnable interface.
Is it possible to write code that can execute only if the current thread owns multiple locks?
Yes.
1. Which of the following restrictions apply to anonymous inner classes?
They must be defined inside a code block.
Which of the following restrictions apply to anonymous inner classes?
They must be defined inside a code block.
Which of these class is used to make a thread?
Thread
Which of these is not abstract?
Thread
Which of interface contains all the methods used for handling thread related operations in Java?
ThreadHandling interface
Which of the following statements about threads is true
Threads inherit their
3. Which of the following statements about threads is true?
Threads inherit their priority from their parent thread.
Which of the following statements about threads is true?
Threads inherit their priority from their parent thread.
Which of the following statements about threads is true? (Choose one.)
Threads inherit their priority from their parent thread.
1. Which of the following is the most appropriate way to handle invalid arguments in a public method?
Throw java.lang.IllegalArgumentException.
Which of the following is the most appropriate way to handle invalid arguments in a public method?
Throw java.lang.IllegalArgumentException.
All exception types are subclasses of the built-in class
Throwable
Which of these class is related to all the exceptions that are explicitly thrown?
Throwable
Which of these classes is super class of Exception class?
Throwable
Which of these is a super class of all exceptional type classes?
Throwable
Whenever a method does not want to handle exceptions using the try block, the____is used.
Throws
String Firstname[]= new String[5]
Throws an exception
What does the following code do
Throws an exception
Integer i = null;if (i != null & i.intValue() == 5) System.out.println("Value is 5");
Throws an exception.
What does the following code do?Integer i = null;if (i != null & i.intValue() == 5) System.out.println("Value is 5");
Throws an exception.
Which of these classes can schedule task for execution in future?
Timer
You cannot specify accessibility of local variables
To access a method of an object we write <method>.<object>.
Which of the following statements are true?
To be overriden a method must have the same name, parameter and return types
Under what circumstances might you use the yield method of the Thread class
To call from the currently running thre
Why might you define a method as native?
To get to aTo write optimised
Select incorrect statement about ServerSocket class
To make the new object
Select incorrect statement about ServerSocket class. (choose 1)
To make the new object available for client connections, call its accept() method, which returns an instance of ServerSocket
Which of these methods returns the total number of bytes of memory available to the program?
TotalMemory()
4. Which of the following statements is true?
Transient variables are not serialized.
Which of the following statements is true?
Transient variables are not serialized.
Which of the following statements is true? (Choose one.)
Transient variables are not serialized.
How to declare a class which has fields that are not serializable?
Transient.
If you need a Set implementation that provides value-ordered iteration, which class should you use
TreeSet
If you need a Set implementation that provides value-ordered iteration,which class should you use?
TreeSet
If you need a Set implementation that provides value-ordered iteration,which class should you use? (Choose one.)
TreeSet
14. A StringBuffer is slower than a StringBuilder, but a StringBuffer is threadsafe.
True
StringBuffer is slower than a StringBuilder, but a StringBuffer
True
Swing components cannot be combined with AWT components.
True
Unicode characters are all 16 bits.
True
sbuf.insert("-University");
True
sbuf.insert(3, "-University");
True
drivers that are pure Java and implement the network protocol for a specific data source. The client connects directly to the data source
Type 4
drivers that are pure Java and implement the network protocol for a specific data source. The client connects directly to the data source.
Type 4
Which of the following allows us to call generic methods as a normal method?
Type Interface
Which of these coding techniques is used by method isDefined()?
UNICODE
Is it possible to define a class called Thing so that the following method can return true under certain circumstances?boolean weird(Thing s) { Integer x = new Integer(5); return s.equals(x);}
Yes
Is it possible to write code that can execute only if the current thread owns multiple locks?
Yes
boolean weird(Thing s) { Integer x = new Integer(5); return s.equals(x);
Yes
boolean weird(Thing s) { Integer x = new Integer(5); return s.equals(x);}
Yes
A monitor called mon has 10 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thr1
You cannot specify
One of the threads is thr1. How can you notify thr1 so that it alone moves from the Waiting state to the Ready state
You cannot specify
Which statement is true about accessibility of members?
You cannot specify accessibility of local variables
Which of the following is true about the use of modifiers
You cannot specify accessibility of local variables. They are only accessible within the block in which they are declared
A monitor called mon has 10 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thr1. How can you notify thr1 so that it alone moves from the Waiting state to the Ready state?
You cannot specify which thread will get notified.
A monitor called mon has 10 threads in its waiting pool; all these waitingthreads have the same priority. One of the threads is thr1. How can you notify thr1 so that it alone moves from the Waiting state to the Ready state? (Choose one.)
You cannot specify which thread will get notified.
int)(Math.random()*100 % 6) + 3
You may or may not recall that the standard Java computing environment contains a Math class that includes
public static void main(String[] args)throws MyException {System.out.println("Welcome to Java");
You should not declare a class that extends Error, because Error raises a fatal error that terminates the program
Select from among the following character escape code which is notavailable in Java.
\a
Which of the following escape sequences represents carriage return
\r
Which of the following escape sequences represents carriage return?
\r
What will be the value of i for the following loop?int y = 0;for (int i = 0; i<10; ++i) {y += i;}
Undefined.
In Java, a character constant's value is its integer value in the ...........................character set
Unicode
In Java, a character constant's value is its integer value in the ...........................character set.
Unicode
Bytecode characters are all 16 bits
Unicode characters
1. Which of the statements below are true? (Choose all that apply.)
Unicode characters are all 16 bits.
Which of the statements below are true? (Choose one.)
Unicode characters are all 16 bits.
URL stands for
Uniform resource locator
How do you change the current layout manager for a container
Use the setLayout method
output results when the main method of the class Sub is run
Value 5 This value 6
1. public class Base {2. public void method(int i) {3. System.out.print("Value is " + i);4. }5. }1. public class Sub extends Base {
Value is 5This value is 6
Which of the following statements are incorrect?
Variables declared as final occupy memory.
Which of the following are valid declarations? Assume java.util.* is imported.
Vector, Set,Map
Which of the following are valid declarations? Assume java.util.* is imported.
Vector,Set,Map
Which of the following are valid declarations? Assume java.util.* is imported.
Vector<Map> v Set<String> s Map<String, String> m;
Which of these class have only one field 'TYPE'?
Void
SQL keyword ___ is followed by the selection criteria that specify the rows to select in a query
WHERE
SQL keyword is followed by the selection criteria that specify the rows to select in a query
WHERE
SQL keyword____is followed by the selection criteria that specify the rows to select in a query
WHERE
Test.date
What code may be filled in the blank without causing syntax or runtime errors
A protected member can be accessed in
a non-subclass of different package
27. Give the following declarations: Vector plainVec; Vector<String> fancyVec;If you want a vector in which you know you will only store strings, what are the advantages of using fancyVec rather than plainVec?
a string to fancyVec results in a compiler error.
Which of the following method is inherited by Applet from its parent class?
paint
12. public class AssertStuff {14.public static void main(String [] args) {15. int x= 5;16. int y= 7;
passed An AssertionError is thrown with the word "stuff"12. public class Test {
statements about the wait() and notify() methods is true
pool of waiting threads
1. Which are appropriate uses of assertions?
preconditions private.postconditions private method,public method
Which of these is a method of ListIterator used to obtain index of previous element?
previousIndex()
Suppose prim is an int and wrapped is an Integer. Which of the following are legal Java statements? (Choose all that apply.)
prim = wrapped;,wrapped = prim;,prim = new Integer(9);,wrapped = 9;
Wrapper objects can be used anywhere that objects are required instead of ____.
primitive data types
null
print("Main() constructor");
Which of these is method is used for writing bytes to an outputstream?
print()
Which of these methods is used to print stack trace?
printStackTrace()
1. Suppose you are writing a class that will provide custom deserialization. The class implements java.io.Serializable (not java.io.Externalizable). What access mode should the readObject() method have?
private
6. Suppose you are writing a class that will provide custom deserialization. The class implements java.io.Serializable (not java.io.Externalizable). What access mode should the readObject() method have?
private
27. Suppose threads aThread and bThread are both accessing a shared object named sharedOb, and aThread has just executed:sharedOb.wait();
aThread.interrupt();sharedOb.notifyAll();
Which of function return absolute value of a variable?
abs()
A method that has no implementation is called a/an ____ method.
abstract
If a class inheriting an abstract class does not define all of its function then it will be known as?
abstract
Which of these keywords are used to define an abstract class?
abstract
Which of these keywords cannot be used for a class which has been declared final?
abstract
Which of these class relies upon its subclasses for complete implementation of its methods?
abstract class
33. try {34. // some code here35. }catch (NullPointerException e1) {36. System.out.print("a");37. }catch (RuntimeException e2) {
ac
What is the result if a NullPointerException occurs on line 34
ac
method is used to wait for a client to initiate communications.
accept
method is used to wait for a client to initiate communications
accept()
method is used to wait for a client to initiate communications.
accept()
Which of these method of HashSet class is used to add elements to its object?
add()
The addAll() method of that interface takes a single argument, which is a reference to a collection whose elements are compatible with E. What is the declaration of the addAll() method
addAll(Collection<? extends E> c)
Which of the following methods are members of the Vector class and allow you to input a new element
addElement
Which of these method is used to add an element to the start of a LinkedList object?
addFirst()
Method is not defined properly
What is the error in the following class definitions
invalid call
What is the printout of the call Print('a', 4)
x is 5.5 and y is 5.0
What is the printout of the following code
f2.i is 1 f2.s is 2
What is the printout of the second println statement in the main method?
f3.i is 3 f3.s is 1
What is the printout of the third println statement in the main method
Which of the following is incorrect statement regarding the use of generics and parameterized types in Java?
When designing your own collections class
In Java, declaring a class abstract is useful
When it doesn't make sense to have objects of that class
27. When should objects stored in a Set implement the java.util.Comparable interface?
When the Set is a TreeSet
When should objects stored in a Set implement the java.util.Comparable interface?
When the Set is a TreeSet
1. When is it appropriate to pass a cause to an exception's constructor?
When the exception is being thrown in response to catching of a different exception type
When is it appropriate to pass a cause to an exception's constructor?
When the exception is being thrown in response to catching of a different exception type
2. When does an exception's stack trace get recorded in the exception object?
When the exception is constructed
When does an exception's stack trace get recorded in the exception object?
When the exception is constructed
10. Suppose the declared type of x is a class, and the declared type of y is an interface. When is the assignment x = y; legal?
When the type of x is Object
Suppose the declared type of x is a class, and the declared type of y is an interface. When is the assignment x = y; legal?
When the type of x is Object
Suppose the declared type of x is a class, and the declared type of y is an interface. When is the assignment x = y; legal? (Choose one.)
When the type of x is Object
type of x is a class, and the declared type of y is an interface. When is the assignment x = y
When the type of x is Object
Suppose the declared type of x is a class, and the declared type of y is an interface. When is the assignment x = y; legal
When the...x is Object
public class Test {int x;{ x++; } }
When you construct an instance of Test.... of x becomes 1;
Which of the following are true? (Choose all that apply.)
When you declare a method to be synchronized, the method always synchronizes on the lock of the current object.,When you declare a block of code inside a method to be synchronized, you can specify the object on whose lock the block should synchronize.
Default constructor is invoked, then Init method is invoked
When you run the following applet from a browser, what is displayed?
A class has always a constructor (possibly automatically supplied by the java compiler)
Which of the following is TRUE
An interface can implement another interface
Which of the following is not true
A finally block is executed whether an exception is thrown or not
Which of the following is true
Any applet must be an instance of java.awt.Applet.
Which of the following is true
The main() method of a program can declare that it throws checked exceptions
Which of the following is true
To access a method of an object we write <method>.<object>.
Which of the following statement is false
At least one constructor must always be defined explicitly
Which of the following statement is not true
Choose the valid identifiers from those listed here. (Choose all that apply.)
all
shorty is a short and wrapped is a Short
all
A constructor
all 3
Which of the following statements are true? (Choose one.)
an instance of Inner can be constructed like this: new Outer().new Inner()
Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
append()
What is the value of double constant 'E' defined in Math class?
approximately 2.72
6. Suppose you are writing a class that will provide custom serialization. The class implements java.io.Serializable (not java.io.Externalizable). What access mode should the writeObject() method have?
private
Suppose class A has a method called doSomething(), with default access. Suppose class B extends A and overrides doSomething()
private
Suppose class A has a method called doSomething(), with default access. Suppose class B extends A and overrides doSomething(). Which access modes may not apply to B's version of doSomething()?
private
Suppose class A has a method called doSomething(), with default access.Suppose class B extends A and overrides doSomething(). Which access modes may not apply to B's version of doSomething()? (Choose one)
private
Suppose you are writing a class that will provide custom deserialization. The class implements java.io.Serializable (not java.io.Externalizable). What access mode should the readObject() method have?
private
Suppose you are writing a class that will provide custom deserialization. The class implements java.io.Serializable (not java.io.Externalizable). What access mode should the readObject() method have? (Choose one.)
private
Suppose you are writing a class that will provide custom deserialization. What access mode should the readObject() method have
private
Suppose you are writing a class that will provide custom deserialization.The class implements java.io.Serializable (not java.io.Externalizable). What access mode should the readObject() method have?
private
Suppose you are writing a class that will provide custom serialization. The class implements java.io.Serializable (not java.io.Externalizable). What access mode should the writeObject() method have?
private
Suppose you are writing a class that will provide custom serialization. What access mode should the writeObject() method have
private
Which of these is used as default for a member of a class if no access specifier is used for it?
private
Which of the following statements generally describes the scope of a variable?
Which of the following statements generally describes the scope of a variable?
Every java object has a public method named equals
Which of the following statements is true
Static member classes can contain non-static methods.
Which of the following statements is true
The keyword extends is used to specify that an interface inherits from another interface
Which of the following statements is true
The subclass of a non-abstract class can be declared abstract
Which of the following statements is true
Which of these methods are used to read in from file?
Which of these methods are used to read in from file? | read()
An abstract class cannot have non-abstract methods
Which one of the following is not true
All objects have a finalize() method
Which statement is true
If object obj1 can access object obj2 that is eligible for garbage collection, then obj1 is also eligible for garbage collection
Which statement is true
The JVM runs until there is only one non-daemon thread
are no non-daemon
The above program is supplemented with the following command line assuming that the program has been compiled without any errors
args
Which of these is a correct statement about args in this line of code?
args is an array of String
1. Which lines check that x is equal to four? Assume assertions are enabled at compile time and runtime.
assert x == 4;assert x == 4 : "x is not 4";
No output because of compile error at line: System.out.println("b="+b)
b = b * b1
Line labeled (4)
b = new MySubclass(); //(2)
The output: b contains 250
b contains 5
Which of these methods of Boolean wrapper returns boolean equivalent of an object.
booleanValue()
Which of the following statements is true? (Choose one.)
both method calls and assignments,and the rules governing these conversions are identical.
The fields in an interface are implicitly specified as
both static and final
1. Given the following code, what keyword must be used at line 4 in order to stop execution of the for loop?
break
<insert code>
break
Which of the following is method of wrapper Float for converting the value of an object into byte?
byte bytevalue()
Which of the following is method of wrapper Integer for converting the value of an object into byte?
byte bytevalue()
Which of the following are legal argument types for a switch statement?
byte int
1. Which of the following are legal argument types for a switch statement?
byte int char
Which of the following are legal argument types for a switch statement?
byte,INT,CHAR
Java programming language, the compiler converts the human-readable source file into platform-independent code that a Java Virtual Machine can understand
bytecode
What is Recursion in Java?
calls other methods repeatedly.
Which of the following statements about the wait() and notify() methods is true
calls wait() goes into
Which of these keywords are used for the block to handle the exceptions generated by try block?
catch
Which of these keywords must be used to handle the exception thrown by try block in some rational manner?
catch
char chars[] = { 'a', 'b', 'c', 'd', 'e', 'f'};
cde
'G'
ch = (char) System.in.read();
9. Which of the following are legal?
char c = '\u1234';
Which of the following are legal?
char c = '\u1234';
Which of the following assignment statement(s) is/are correct?
char c = 'd'. char c = 100;
Which of the following are legal? (Choose two.)
char c = 0x1234; char c = '\u1234';
Which of the following assignment statement(s) is/are correct
char c = 100; & char c = 'd'
14. Select the list of primitives ordered in smallest to largest bit size representation.
char, int, float, long
Select the list of primitives ordered in smallest bit size representation.
char,int,float,long
Which of these method of String class is used to obtain character at specified index?
charAt()
Which of these method of class String is used to extract a single character from a String object?
charAt()
Lemon lem = new Lemon(); Citrus cit = new Citrus();Which lines compile without error? (Choose all that apply.)
cit = lem;lem = (Lemon)cit;cit = (Citrus)lem;
String in Java is a?
class
Which of these keywords is used to make a class?
class
Which of these is correct way of inheriting class A by class B?
class B extends A {}
interface A { int a=5; int b=10;} Which of the following is possible for the above?
class B implements A{int x;void add(){ x= a+b; }}
Which Man class properly represents the relationship "Man has the best friend who is a Dog"?
class Man { private Dog bestFriend; }
Which Man class properly represents the relationship "Man has the best friend who is a Dog"? (Choose one.)
class Man { private Dog bestFriend; }
Object references can be converted in both method calls and assignments, but the rules governing these conversions are very different
conversions are identical
6. What method of the java.io.File class can create a file on the hard drive?
createNewFile
What method of the java.io.File class can create a file on the hard drive
createNewFile()
What method of the java.io.File class can create a file on the hard drive?
createNewFile()
method of the java.io.File class can create a file on the hard drive
createNewFile()
Which of the following is method of System class is used to find how long a program takes to execute?
currentTimeMillis()
Which of these methods of Byte wrapper can be used to obtain Byte object from a string?
decode()
1. Which of the following declarations are illegal? (Choose all that apply.)
default String s;abstractdouble d;abstractfinaldoublehyperbolicCosine();
Which of the following declarations are illegal?
default String s;public final;abstract final double hyperbolicCosine();
Why are generics used?
detectable at compile time.
Which of these is specified by a File object?
directory in disk
You read the following statement in a Java program that compiles and executes
dive must be a method
You read the following statement in a Java program that compiles and executes
dive must be a method.
13. public class Pass {14. public static void main(String [] args) {15. int x = 5;16. Pass p = new Pass();17. p.doStuff(x);18. System.out.print(" main x = "+ x);19. }
doStuff x = 5 main x = 5
System.out.print("doStuff x = "+ x++);
doStuff x = 5 main x = 5
doStuff x = 6 main x = 6
doStuff x =5 main x =5
14. public static void main(String [] args) {15. int x = 5;16. Pass p = new Pass();17. p.doStuff(x);
doStuffx = 5 main x = 5
class A extends java.util.Vector { private A(int x)
does not create a default
Which keyword can protect a class in a package from accessibility by the classes outside the package
don't use any keyword at all (make it default)
Which keyword can protect a class in a package from accessibility by the classes outside the package?
don't use any keyword at all (make it default)
Which of these method return a smallest whole number greater than or equal to variable X?
double ciel(double X)
8. Which of the following are legal? (Choose all that apply.)
double d = 1.2d; double d = 1.2D;
Which of the following are legal? (Choose two.)
double d = 1.2d; double d = 1.2D;
Which of the following are legal?
double d = 1.2d;double d = 1.2D;
Which of these method return a largest whole number less than or equal to variable X?
double floor(double X)
Which of the following are Java key words
double instan
Which of the following methods Byte wrapper return the value as a double?
doubleValue()
Which of the following methods return the value as a double?
doubleValue()
Assuming any exception handling has been set up, which of the following will create an instance of the RandomAccessFile class
e("myfile.txt","rw");
What is the string contained in s after following lines of code?
ello
Which of these method can be used to increase the capacity of ArrayList object manually
ensureCapacity()
Which of the following are legal enums?
enum Animals { LION, TIGER, BEAR }
Which of the following types are legal arguments of a switch statement
enums, bytes
Which of the following types are legal arguments of a switch statement?
enums,bytes
1. Which of the following types are legal arguments of a switch statement?
enums.bytes
Which of these method of String class can be used to test to strings for equality?
equals()
Which of these method of class String is used to compare two String objects for their equality?
equals()
Compilation fails because of an error in line 15
error in line 19
Compilation succeeds, although the import on line 1 is not necessary. During execution, an exception is thrown at line 3
fails at line 2
Which of these method is used to make all elements of an equal to specified value?
fill()
Which of these methods sets every element of a List to a specified object?
fill()
The ____ reserved word in a method definition ensures that subclasses cannot override this
final
To prevent any method from overriding, we declare the method as
final
Which of these keywords can be used to prevent Method overriding?
final
Which of these keywords can be used to prevent inheritance of a class?
final
Which of these keywords is used to prevent content of a variable from being modified?
final
Which one of the following class definitions is a valid definition of a class that
final class Link { }
11. public interface Status {12. /* insert code here */ int MY_VALUE = 10;13. }
final static public
public interface Status {
final;static;public
The java run time system automatically calls this method while garbage collection
finalize()
The java run time system automatically calls this method while garbage collection.
finalize()
Which function is used to perform some action when the object is to be destroyed?
finalize()
Which of the following statements are incorrect?
finalize() method is called when a object goes out of scope and is no longer needed.
Which of these methods return a class object given its name?
findSystemClass()
6. Which of the following are methods of the java.util.SortedSet interface?
first
2. When a short is added to a float, what is the type of the result?
float
When a short is added to a float
float
When a short is added to a float, what is the type of the result
float
When a short is added to a float, what is the type of the result?
float
Which of the following is illegal statement?
float f=1.01;
Which of these is a method to clear all the data present in output buffers?
flush()
1. Suppose salaries is an array containing floats. Which of the following are valid loop control statements for processing each element of salaries?
for (float f:salaries)
Suppose salaries is an array containing floats
for (float f:salaries)
Suppose salaries is an array containing floats. Which of the following are valid loop control statements for processing each element of salaries
for (float f:salaries)
Suppose salaries is an array containing floats. Which of the following are valid loop control statements for processing each element of salaries?
for (float f:salaries)
Suppose salaries is an array containing floats. Which of the following are valid loop control statements for processing each element of salaries? (Choose one.)
for (float f:salaries)
Which of the following are legal loop constructions
for (int k=0, j+k != 10; j++,k++)
static void foo(int...x) {
for(int z : x) System.out.println(z);for( int i=0; i< x.length; i++ ) System.out.println(x[i]);
10. public class Bar {11. static void foo(int...x) {12. // insert code here13. }14. }
for(int z : x); for( int i=0; i< x.length; i++)
Which of these methods initiates garbage collection?
gc()
For what values respectively of the variables gender and age would the Java expression gender == 1 && age >= 65 become true
gender = 1, age = 65
For what values respectively of the variables gender and age would the Java expression gender == 1 && age >= 65 become true?
gender = 1, age = 65
1. for (int i = 0; i < 2; i++) {2. for (int j = 0; j < 3; j++) {3. if (i == j) {4. continue;
i = 0 j = 1.i = 0 j = 2.i = 1 j = 0.i = 1 j = 2
1. outer: for (int i = 0; i < 2; i++) {2. for (int j = 0; j < 3; j++) {3. if (i == j) {4. continue outer;5. }
i = 1 j = 0
outer: for (int i = 0; i < 2; i++)
i = 1 j = 0
7. Which of the following are legal import statements?
import java.util.Vector; import static java.util.Vector.*;
Which of the following are legal import statements? (Choose two.)
import java.util.Vector; import static java.util.Vector.*;
Which of the following are legal import statements?
import java.util.Vector;import static java.util.Vector.*;
Which of the following is correct way of importing an entire package 'pkg'?
import pkg.*
When is it appropriate to pass a cause to an exception's constructor
in response to catching
it also has a method called chopWoodAndCarryWater(), which just calls the other two methods
inappropriate cohesion, inappropriate coupling
27. Suppose class Home has methods chopWood() and carryWater(); it also has a method called chopWoodAndCarryWater(), which just calls the other two methods. Which statements are true? (Choose all that appl
inappropriate cohesion.inappropriate coupling.
1. How is IllegalArgumentException used? (Choose all correct options.)
indicate that preconditions have been violated.public methods have been violated.
What is the sequence of major events in the life of an applet
init, start, stop, destroy
What is the sequence of major events in the life of an applet?
init, start, stop, destroy
restrictions apply to anonymous inner classes
inside a code block
1. Suppose class X contains the following method:void doSomething(int a, float b) { ... }
public void doSomething(int a, float b) { ... }
Suppose class X contains the following method:void doSomething(int a, float b) { ... }Which of the following methods may appear in class Y, which extends X? (Choose one.)
public void doSomething(int a, float b) { ... }
void doSomething(int a, float b) { ... }
public void doSomething(int a, float b) { ... }
A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these ways
public void logIt(String... msgs)
A programmer needs to create a logging method that can accept an arbitrary number of arguments. For example, it may be called in these wayslogIt("log message 1 ");logIt("log message2","log message3");logIt("log message4", "log message5", "log message6");
public void logIt(String... msgs)
you are writing a class that will provide custom deserialization. The class implements java.io.Serializable (not java.io.Externalizable)
private
you are writing a class that will provide custom serialization. The class implements java.io.Serializable (not java.io.Externalizable)
private
Man has the best friend who is a Dog
private Dog bestFriend
A class member declared protected becomes member of subclass of which type?
private member
Which of the following statements are incorrect?
private members of class can be inherited by a sub class, and become protected members in sub class.
14. Suppose you are writing a class that provides custom deserialization. The class implements java.io.Serializable (and not java.io.Externalizable). What method should imple- ment the custom deserialization, and what is its access mode?
private readObject
Suppose you are writing a class that provides custom deserialization. The class implements java.io.Serializable (and not java.io.Externalizable). What method should imple- ment the custom deserialization, and what is its access mode?
private readObject
The class implements java.io.Serializable (and not java.io.Externalizable)
private readObject
URL referring to databases use the form
protocol:subprotocol:datasoursename
URL referring to databases use the form:
protocol:subprotocol:datasoursename
Which of these access specifiers must be used for main() method?
public
10. abstract public class Employee {11. protected abstract double getSalesAmount();12. public double getCommision() {13. return getSalesAmount() * 0.15;
public double{ return 1230.45;}.protected double{ return 1230.45; }
1. public interface A {2. String DEFAULT_GREETING = "Hello World";3. public void method1();4. }
public interface B extends A { }
String DEFAULT_GREETING = "Hello World";
public interface B extends A { }
Which of these is an correct way of defining generic method?
public name { /* ... */ }
Which of the following are Java modifiers?
public private transient
11. Suppose class Supe, in package packagea, has a method called doSomething(). Suppose class Subby, in package packageb, overrides doSomething(). What access modes may Subby's version of the method have? (Choose all that apply.)
public protected
Suppose class Supe, in package packagea, has a method called doSomething(). Suppose class Subby, in package packageb, overrides doSomething(). What access modes may Subby's version of the method have? (Choose two.)
public protected
11. Suppose class A has a method called doSomething(), with default access. Suppose class B extends A and overrides doSomething(). Which access modes may apply to B's version of doSomething()? (Choose all that apply.)
public protected Default
General Java variable naming conventions would suggest that a variable named NICKEL_VALUE would most probably be declared using which of the following combinations of modifiers?
public static final double
Which of these field declarations are legal within the body of an interface
public static int answer=42
Which of the following signatures are valid for the main() method entry point of an application?(Choose all that apply.)
public static void
Check(sweat(a[3]), x);
public static void Check(char c, Funny f)
1. Which of the following signatures are valid for the main() method entry point of an application? (Choose all that apply.)
public static void main(String arg[]) public static void main(String[] args)
Which of the following signatures are valid for the main() method entry point of an application?
public static void main(String arg[]),(String args[])
How the main method header is written in Java
public static void main(String[] args)
How the main method header is written in Java?
public static void main(String[] args)
What is the correct signature of the main method?
public static void main(String[] args)
signatures are valid for the main() method entry point of an application
public static void main(String[] args)
public class Test { public static void main(String[] args) { String s = new String("Welcome to Java");
s, o, and d reference the same String object
containing "Java", which of the following could you use?
s.indexOf('v');
Which line of code tells a scanner called sc to use a single digit as a delimiter
sc.useDelimiter("\\d")
line of code tells a scanner called sc to use a single digit as a delimiter
sc.useDelimiter("\\d")
6. Which line of code tells a scanner called sc to use a single digit as a delimiter?
sc.useDelimiter("\\d");
Which line of code tells a scanner called sc to use a single digit as a delimiter?
sc.useDelimiter("\\d");
Which line of code tells a scanner called sc to use a single digit as a delimiter? (Choose one.)
sc.useDelimiter("\\d");
Which of these method Map class is used to obtain an element in the map having specified key?
search()
Select incorrect statement about Socket class
server through UDP
An Applet has its Layout Manager set to the default of FlowLayout. What code would be correct to change to another Layout Manager
setLayout(new GridLayout(2,2));
Which of these method can set the out stream to oStream?
setOut()
Suppose shorty is a short and wrapped is a Short. Which of the following are legal Java state- ments? (Choose all correct options.)
shorty = wrapped;,wrapped = shorty;,shorty = new Short((short)9);,shorty = 9;
1. Suppose shorty is a short and wrapped is a Short. Which of the following are legal Java state- ments? (Choose all correct options.)
shorty=wrapped;wrapped=shorty;shorty=newShort((short)9);shorty = 9;
Which of these methods can randomize all elements in a list?
shuffle()
Which of these methods can convert an object into a List?
singletonList()
Which of these method of ArrayList class is used to obtain present size of an object?
size()
Which of these method of Thread class is used to suspend a thread for a period of time?
sleep()
Which of the following statement is not defined in the Object class?
sleep(long milliseconds)
Which of the following method is a static in java.lang.Thread?
sleep(long)
Suppose a source file contains a large number of import statements. How do the imports affect the time required to compile the source file
slightly more time
Which of these method of Array class is used sort an array or its subset?
sort()
Assume you are using release 5.0
source 1.5 flag,enabling flag, more elements.
Which of these is the method which is executed first before execution of any other thing takes place in a program?
static method
Select from among the following the correct option which assign the variable str with the value "The sum of 5 + 7 = 12"?
str = "The sum of "+ a +" + "+ b +" =" + (a + b);
Which of these is used to perform all input & output operations in Java?
streams
Suppose you want to write a class that offers static methods to compute hyperbolic trigonometric functions. You decide to subclass java.lang.Math and provide the new functionality as a set of static methods
subclass java.lang.Math
Which of these method of class String is used to extract a substring from a String object?
substring()
Which of these method of class StringBuffer is used to extract a substring from a String object?
substring()
Compilation fails at line 1 because the String constructor must be called explicitly
succeeds. No exception
1. Which of the following keywords is used to invoke a method in the parent class?
super
The ____reserved word is used to deactivate polymorphism and invoke a method of the superclass.
super
Which of the following keywords are used for lower bounding a wild card?
super
Which of the following keywords is used to invoke a method in the parent class?
super
Which of these keyword can be used in subclass to call the constructor of superclass?
super
Which of these keywords is used to refer to member of base class from a sub class?
super
keywords is used to invoke a method in the parent class
super
Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B?
super();
accurately describes how variables are passed to methods
that are primitive type are passed by value
When an applet container encounters an HTML file that specifies an applet to execute, the applet container automatically loads ________ of the applet from the same directory as that of the HTML file
the .class file
When an applet container encounters an HTML file that specifies an applet to execute, the applet container automatically loads ________ of the applet from the same directory as that of the HTML file.
the .class file
Java Bytecode is
the Java virtual machine version of machine code
Java Bytecode is
the Java virtual machine version of machine code.
When designing a hierarchy of classes, features and behaviors that are common to all classes are placed in ____.
the superclass
Which of these method is used to reduce the capacity of an ArrayList object?
trimToSize()
A final class may not have any abstract methods
true
Which of these keywords are used for the block to be examined for exceptions?
try
Which of these keywords is used to manually throw an exception?
try
Which of these keywords must be used to monitor for exceptions?
try
Which of these statements is incorrect?
try need not to be followed by anything.
What is the return type of a method that does not returns any value?
void
Which of these class have only one field?
void
Which of the following method of Process class can terminate a process?
void destroy()
When the user attempts to close the frame window, _______ event in generated
window closing
When the user attempts to close the frame window, event in generated.
window closing
When the user attempts to close the frame window,_____event in generated.
window closing
Select incorrect statement about Socket class
with a server through UDP.
An overloaded method consists of
with different types of parameters & with different number of parameters
Which of these methods is used to write() into a file?
write()
When comparing java.io.BufferedWriter to java.io.FileWriter, which capability exists as a method in only one of the two
writing a line
When comparing java.io.BufferedWriter to java.io.FileWriter, which capability exists as a method in only one of the two?
writing a line separator to the stream
When comparing java.io.BufferedWriter to java.io.FileWriter, which capability exists as a method in only one of the two? (Choose one.)
writing a line separator to the stream
Is it possible to write code that can execute only if the current thread owns multiple locks
yes
ttt.start();
yes
Which of the following are methods of the Thread class?
yield() sleep stop()
Which of the following operations might throw an ArithmeticException?
/
Which of the following is NOTa valid comment
/* comment
Which of the following is NOTa valid comment:
/* comment
Which of the following is/are valid comment(s) in java?
/* comment
The default value of a static integer variable of a class in Java is
0
int MY_VALUE = 10
3.final, static, public
public float aMethod(float a, float b, int c) throws Exception
3.int a,b. float a,b-int c. private
Which of the following declarations are illegal
3.ngan-dai nhat, double d
Which of the following are legal enums
3.ngan-dai nhat, lion int weight
When an application begins running, there is one non-daemon thread, whose job is to execute main()
3.nhat, thread, non-daemon thread
14. How many bits does a float contain?
32
How many bits does a float contain
32
How many bits does a float contain?
32
What is the bit size of int in java?
32
What is the value of the x after the following line is executed? x = 32 * (31 - 10 *3)
32
What is the value of x after the following line is executed
32
x = 32 (31 - 10 3);
32
x = 32 * (31 - 10 * 3);
32
31. // some code here32. try {33. // some code here34. } catch (SomeException se) {35. // some code here
33 throws an exception.35 throws an exception.31 throws an exception.
can legally be placed before aMethod() on line 3 and be placed before aMethod() on line 8
3: private; 8: protected
System.out.println (c=c++)
4
System.out.println (c=c++);
4
What does the expression (int)(76.0252175 * 100) / 100 evaluate to
76
What does the expression (int)(76.0252175 * 100) / 100 evaluate to?
76
1. try {2. FileOutputStream fos = newFileOutputStream("dest");3. DataOutputStream dos = new DataOutputStream(fos);4. dos.writeInt(3);
8
The number of bytes depends on the underlying system
8
dos.writeFloat(0.0001f);
8
What will be the result of the expression 13 & 25
9
What will be the result of the expression 13 & 25?
9
int i=3, j=7, k=11 -i +i + i++
9
Which of the following applet tags is legal to embed an applet class named Test into a Web page?
< applet> code = Test.class width = 200 height = 100>
Which of the following applet tags is legal to embed an applet class named Test into a Web page?
< appletcode = Test.class width = 200 height = 100>
4. What is -8 % 5?
A. -3
What does AWT stands for?
Abstract Window Toolkit
AWT stands for
Abstract Windowing Tool Kit
A class that cannot be instantiated is called a/an ____.
Abstract class.
A process that involves recognizing and focusing on the important characteristics of a situation or object is known as
Abstraction
How do you prevent shared data from being corrupted in a multithreaded environment
Access the variables
you prevent shared data from being corrupted in a multithreaded environment
Access the variables
3. How do you prevent shared data from being corrupted in a multithreaded environment?
Access the variables only via synchronized methods.
How do you prevent shared data from being corrupted in a multithreaded environment?
Access the variables only via synchronized methods.
How do you prevent shared data from being corrupted in a multithreaded environment? (Choose one.)
Access the variables only via synchronized methods.
15. Which of the following statements accurately describes how variables are passed to methods?
Arguments that are primitive type are passed by value.
Which of the following statements accurately describes how variables are passed to methods?
Arguments that are primitive type are passed by value.
Which of the following statements accurately describes how variables are passed to methods?
Arguments that are primitve type are passed by value
Which of the following exception is caused when a math error such as division by zero occurs?
ArithmaticException
Which of these classes is not included in java.lang?
Array
Which of these data type cannot be type parameterized?
Array
Which of these standard collection classes implements all the standard functions on list data structure?
Array
Which of these methods can be used to obtain a static array from an ArrayList object?
Array()
Which class manages a sequence of objects whose size can change?
ArrayList
Which of these standard collection classes implements a dynamic array?
ArrayList
Which of these class can generate an array which can increase and decrease in size automatically?
ArrayList()
Which of the following classes implement java.util.List?
ArrayList;Stack
What is the type of a variable that references an array list of strings?
ArrayList<String>
Which of the following statements are true?
Arrays are initialized to default values wherever they are created
Which class and static method can you use to convert an array to a List
Arrays.asList
Which class and static method can you use to convert an array to a List?
Arrays.asList
Given arrays a1 and a2, which call returns true if a1 and a2 have the same length, and a1[i].equals(a2[i]) for every legal index i
Arrays.equals(a1, a2)
Which of the following statement is not true?
At least one constructor must always be defined explicitly
A thread's run() method includes the following lines:1. try {2. sleep(100);3. } catch (InterruptedException e) { }
At line 2, the thread will stop running. It will resume running some time after 100 milliseconds have elapsed.
Which of these interface declares core method that all collections will have?
Collection
Which of these is Basic interface that all other interface inherits?
Collection
How do the imports affect the time required to compile the source file
Compilation takes slightly more time
Which of the following is not true?
Every time the class is instantiated, a new copy of each of the class variables is created
Which of the following is not true?
Every time the class is instantiated, a new copy of each of the instance variables is created
Which of these class is related to all the exceptions that can be caught by using catch?
Exception
Which of these classes is used to define exceptions?
Exception
14. Assertions are used to enforce all but which of the following?
Exceptions
Assertions are used to enforce all but which
Exceptions
Assertions are used to enforce all but which of the following?
Exceptions
Which of the following events will cause a thread to die?
Execution of the run( ) method ends
How many arguments can be passed to main()?
Infinite
In object oriented programming new classes can be defined by extending existing
Inheritance
In object oriented programming new classes can be defined by extending existing classes
Inheritance
In object oriented programming new classes can be defined by extending existing classes.
Inheritance
In object-oriented programming, the process by which one object acquires the properties of another object is called
Inheritance
Polymorphism
Is not supported by Java,Refers to the ability of two or more
Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five interface methods. Which are true? (Choose two.)
compile if it is declared abstract. The class may not be instantiated.
Which of the following is a method having same name as that of it's class?
constructor
Which of the following is a method having same name as that of its class?
constructor
Which of the following statements are true
constructors cannot be overriden
An enum may be subclassed.
contain public method definitions. An enum may contain private data.
1. Which of the following are true? (Choose all that apply.)
contain public method definitions.contain private data
To create a subclass, use the ____ keyword.
extends
Which of these keyword must be used to inherit a class?
extends
Which of these keywords is used to upper bound a wildcard?
extends
The code compiles, and prints out >>null<<
out >>null<<
There is no output because the code throws an exception at line 1
output is i = 20
Which of these method converts radians to degrees?
toDegree()
Which of the following statements are true? (Choose one.)
A final class may not be extended.
2. Which of the following statements is true?
A final class may not have any abstract methods.
Which of the following statements is true?
A final class may not have any abstract methods.
Which of the following statements are true?
A final object cannot be reassigned a new address in memory
1. Which of the following operations might throw an ArithmeticException?
/
Which of the following are appropriate situations for assertions?
-Preconditions of a public method
Which of the following are legal?
-for (int i=0, float j=1; ; i++, j++)
What is the extension name of a Java source code file?
.java
Which is the four steps are used in working with JDBC?
1)Connect to the database 2)Create a statement and execute the query
Which is the four steps are used in working with JDBC?
1)Connect2)Create3)Look4)Close
Which of the following code snippets compile
1.Integer 2.Integer 3.byte
ArithmeticException
1.None of these 2./
may be statically imported
1.Static method names 2.Static field names
Select the valid primitive data type
1.boolean 2.char 3.float
legal import statements
1.import java.util.Vector 2.import static java.util.Vector
What does the following code print?public class A{static int x;public static void main(String[] args) { A that1 = new A();A that2 = new A(); that1.x = 5; that2.x = 1000;x = -1; System.out.println(x);}}
1000
1. class Q6 {public static void main(String args[]) {Holder h = new Holder();h.held = 100;System.out.println(h.held);h.bump(h);}}class Holder {public int held;public void bump(Holder theHolder) {theHolder.held++; }}}What value is printed out at line 6?
101
Holder h = new Holder()
101
What is the value of result after the following Java statements execute?int a, b, c, da = 4;b = 12;c = 37;d = 51;result = d % a * c + a % b + a;
119
int a, b, c, d; a = 4; b = 12; c = 37; d = 51;
119
char c = 0x1234
2.0x.., '\u1234'
Which of the following may appear on the right-hand side of an instanceof operator
2.A class, An interface
Which of the following classes implement java.util.List
2.ArrayList, Stack
Base(int j, int k, int l)
2.Base(), Base(int j, int k)
Which of the following may be declared final
2.Classes, Methods
Yen and Euro both return correct Country value
2.Euro returns, error at line 25
You would like to write code to read back the data from this file. Which solutions will work
2.FileInputStream, RandomAccessFile
List<String> names = new ArrayList<String>()
2.Iterator, for
you want to use a DateFormat to format an instance of Date. What factors influence the string returned by DateFormat's format() method
2.LONG, or FULL, The locale
Vector <String> theVec = new Vector<String>()
2.List...<String>(), dai nhat
Which two of the following interfaces are at the top of the hierarchies in the Java Collections Framework
2.Map, Collection
Which of the following may be statically imported
2.Static method, Static field
Which two code fragments correctly create and initialize a static array of int elements
2.a = { 100,200 }, static
sharedOb.wait()
2.aThread.interrupt, sharedOb.notifyAll
Which lines check that x is equal to four? Assume assertions are enabled at compile time and runtime
2.assert x == 4
Date vaccinationDue
2.boolean, String
Primitives are passed by reference
2.by value
How is IllegalArgumentException used
2.certain methods, public methods
An enum definition should declare that it extends java.lang.Enum
2.contain public, private
What interfaces can be implemented in order to create a class that can be serialized
2.dai nhat, ngan nhat
you want to create a class that compiles and can be serialized and deserialized without causing an exception to be thrown. Which statements are true regarding the class
2.dai nhat, ngan nhat
int x = 6; if (!(x > 3))
2.dai nhat, x = ~x
Which statements about JDBC are NOT true
2.database system, DBMS
Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five interface methods
2.declared abstract, may not be
The code on line 33 executes successfully
3.33 throws, 35 throws, 33 executes
Line 16 creates a directory named "d" and a file 'f' within it in the file system
3.An exception, Line 13, line 14
Which of the following may follow the static keyword
3.Data, Methods, Code blocks
Assuming the class does not perform custom serialization, which fields are written when an instance of Xyz is serialized
3.Public, Private, Volatile
NUTMEG, CINNAMON, CORIANDER, ROSEMARY
3.Spice sp, Spice, String
If lines 24, 25 and 26 were removed, the code would compile and the output would be 1
3.The code, would be 1, 2
Which of the following are legal argument types for a switch statement
3.byte, int, char
Lemon lem = new Lemon(); Citrus cit = new Citrus()
3.cit = lem, cit=(Citrus), lem=(lemon)
Which of the following operators can perform promotion on their operands
3.cong, tru, xap xi
What is Math.rint(3.5)
4.0
for (int i = 0; i < 2; i++)
4.i0,j12 - i1,j02
int twoDMatrix [ ][ ] = new int [4][6];
6
4. Which of the following may appear on the right-hand side of an instanceof operator? (Choose all that apply.)
A class An interface
Which of the following may appear on the right-hand side of an instanceof operator? (Choose two.)
A class An interface
Which of the following is TRUE?
A class has always a constructor (possibly automatically supplied by the java compiler
Which of the following describes an immutable class?
A class that has accessor methods, but does not have mutator methods.
Which of the following statements is true?
A class that has one abstract method must be abstract class
Which of the following may appear on the right-hand side of an instanceof operator?
A class,An interface
Which of the following may appear on the right-hand side of an instanceof operator?
A class; An interface
Which of the following may appear on the right-hand side of an instanceof operator?
A class;An interface
Select incorrect statement about RMI server
A client accesses
Select incorrect statement about RMI server.
A client accesses a remote object by specifying only the server name.
Select incorrect statement about RMI server.(choose 1)
A client accesses a remote object by specifying only the server name.
Which of the following most closely describes a bitset collection?
A collection for storing bits as on-off information, like a vector of bits
Which of the following is not true for a constructor?
A constructor can be declared abstract
12. Which of the following statements are true?
A final class may not be extended.
Which of the following statements are true?
A final class may not be extended.
Which statement is not true in java language
A private member of a class cannot be accessed by the methods of the same class
Which statement is not true in java language?
A private member of a class cannot be accessed by the methods of the same class.
-10, 75, 10000, 15000, 20000, 25000, 30000, 40000
A proposed graduated state income tax applies the following rate schedule to net income after deductions
3. Which of the following may appear on the left-hand side of an instanceof operator?
A reference
Which of the following may appear on the left-hand side of an instanceof operator
A reference
Which of the following may appear on the left-hand side of an instanceof operator?
A reference
Select correct statements about remote interface.
A remote;All remote interfaces;All methods;The type of
Which of the following statements describes a precondition?
A requirement that the caller of a method must meet.
How can you ensure that multithreaded code does not deadlock?
A, B, and C do not ensure that multithreaded code does not deadlock.
Which of the following is true regarding subclasses?
A subclass inherits methods and instance variables from its superclass.
Which of the following is true regarding inheritance?
A superclass can force a programmer to override a method in any subclass it creates.
Select the correct statement about JDBC two-tier processing model
A user's commands
Select the correct statement about JDBC two-tier processing model.
A user's commands are delivered to the database or other data source, and the results of those statements are sent back to the user.
3. How can you ensure that multithreaded code does not deadlock?
A, B, and C do not ensure that multithreaded code does not deadlock.
1. After execution of the following code fragment, what are the values of the variables x, a, and b? 1. int x, a = 6, b = 7;2. x = a++ + b++;
A. x = 13, a = 7, b = 8
passed An AssertionException is thrown without the word "stuff" added to the stack trace
An AssertionError...with the
Which of the following statements about abstract methods is true?
An abstract method has a name, parameters, and a return type, but no code in the body of the method.
Which of the following statements about a superclass is true?
An abstract method may be used in a superclass when there is no good default method for the superclass that will suit all subclasses' needs.
Which of the following are true?
An anonymous inner class may implement at most one interface., An anonymous inner class may extend a parent class other than Object.
File file = new File(directory,"f");
An exception is thrown at runtime;File object named "d.";Line 14 creates a File object named "f.'
Which of these will happen if recursive method does not have a base case?
An infinite loop occurs
Which of the following is true?
Any applet must be an instance of java.awt.Applet.
Which of the following can Java run from a Web browser exclusively
Applets
Which of the following can Java run from a Web browser exclusively?
Applets
Which of the following is true in regard to applet execution
Applets loaded and executing locally have none of the restrictions faced by applets that get
Which of the following is true in regard to applet execution?
Applets loaded and executing locally have none of the restrictions faced by applets that get loaded from the network.
The program will compile without error and print 2 when run.
B ref2 = (B) ref1;
force garbage collection by calling System.gc().
B. False
I1 b = obj3;
C3 obj3
Which of these class can be used to implement input stream that uses a character array as the source?
CharArrayReader
Which of these is wrapper for simple data type char?
Character
Which of these stream contains the classes which can work on character stream?
Character Stream
What is the fundamental unit of information of writer streams
Characters
What is the fundamental unit of information of writer streams?
Characters
1. Which of the following should always be caught?
Checked exceptions
What must A method declare to throw
Checked exceptions
What must A method declare to throw?
Checked exceptions
Which of the following should always be caught
Checked exceptions
Which of the following should always be caught?
Checked exceptions
Which of the following should always be caught? (Choose one.)
Checked exceptions
Which are appropriate uses of assertions?
Checking preconditions in a private method,Checking postconditions in a private method,Checking postconditions in a public method
Which of these class encapsulate the run time state of an object or an interface?
Class
Which of these classes encapsulate run-time state of an object?
Class
Which of the following may be declared final?
Classes;Data;Methods
Which of the following may be declared final?
Classes;Methods
11. public static void main(String[] args) {12. try {13. args=null;14. args[0] = "test";15. System.out.println(args[0]);16. }catch (Exception ex) {
Compilation fails
A NumberFormatException is thrown by the parse method at runtime
Compilation fails
An exception is thrown at runtime
Compilation fails
NullPointerException
Compilation fails
Which one statement is true about the following code fragment?
Compilation fails at line 2.
11. static class A {12. void process() throws Exception { throw new Exception(); }13. }14. static class B extends A {15. void process() { System.out.println("B "); }
Compilation fails because of an error in line 19.
23. Object [] myObjects = {24. new Integer(12),25. new String("foo"),26. new Integer(5),27. new Boolean(true)
Compilation fails due to an error in line 29.
java.util.Array.sort(myObjects);
Compilation fails due to an error in line 29.
11. String test = "This is a test";12. String[] tokens = test.split("\s");13. System.out.println(tokens.length);
Compilation fails.
11. public static Iterator reverse(List list) {12. Collections.reverse(list);13. return list.iterator();14. }15. public static void main(String[] args) {
Compilation fails.
11. public static void parse(String str) {12. try {13. float f= Float.parseFloat(str);14. } catch (NumberFormatException nfe) {15. f = 0;16. } finally {17. System.out.println(f);18. }
Compilation fails.
System.out.println("NullPointerException");
Compilation fails.
System.out.println(tokens.length);
Compilation fails.
} catch (NumberFormatException nfe) {
Compilation fails.
The value of all four objects prints in natural order
Compilation fails...line 29
StringBuffer s1 = new StringBuffer("FPT");
Compilation succeeds. No exception is thrown during execution.
Which of the following events will cause a thread to die
Component
Which is the four steps are used in working with JDBC
Connect, Create, Look
Interface helps manage the connection between a Java program and adatabase.
Connection
Interface____helps manage the connection between a Java program and a database.
Connection
helps manage the connection between a Java program and a database
Connection
Which of the following is valid to open a database connection?
Connection con (url, userid, password
Which of the following is valid to open a database connection?
Connection con = DriverManager.getConnection(url, userid, password);
Three.java
Consider the following program written in Java
An identifier does not begin with a digit & The execution of Java applications
Consider the following statement(s) about Java
mint[0]= System.in.read(double)
Consider the following statements:double mint[ ];
i = 1; j = 1.0f; k = true;
Consider the following variable declarations
a = 5 s = Blue
Consider the two methods (within the same class)
In a class definition, the special method provided to be called to create an instance of that class is known as a/an
Constructor
Which of the following statements are true?
Constructors are not inherited
Which of the following are appropriate situations for assertions
DAP AN SAI : Preconditions of a public method
11. Which of the following may follow the static keyword? (Choose all that apply.)
Data Methods Code blocks enclosed in curly brackets
Which of the following may follow the static keyword? (Choose three.)
Data Methods Code blocks enclosed in curly brackets
Which of these handles the exception when no catch is used?
Default handler
A method within a class is only accessible by classes that are defined within the same
Do not declare the method with any accessibility modifiers
A method within a class is only accessible by classes that are defined within the same package as the class of the method. Which one of the following is used to enforce such restriction?
Do not declare the method with any accessibility modifiers
How do you indicate where a component will be positioned using Flowlayout?
Do nothing, the FlowLayout wi
What lines are output if the method at line 5 throws an OutOfMemoryError?
Doing finally part
The wrapper class for the primitive type double is ____________________.
Double
A(n) object is uses to obtain a Connection to a Database
DriverManager
A(n)____object is uses to obtain a Connection to a Database
DriverManager
The class is the primary class that has the driver information.
DriverManager
The____class is the primary class that has the driver information.
DriverManager
class is the primary class that has the driver information
DriverManager
object is uses to obtain a Connection to a Database
DriverManager
abstract class can contain methods with declared bodies.
E. public, protected, default, private
Which of these class is related to all the exceptions that cannot be caught?
Error
____ are generated when the user presses a key, clicks a button, or selects a menu item.
Events.
Which of these statement is incorrect?
Every class must contain a main() method.
Which of these classes provide implementation of map interface?
HashMap
Which of these classes implements Set interface?
HashSet
Object ob2= new Object()
Have a nice day
System.out.println("Have a nice day!");
Have a nice day!
public class Test{public static void main(String[] args){ Object ob1= new Object(); Object ob2= new Object();if(ob1.equals(ob2)) System.out.println("ob1 equals ob2"); if(ob1==ob2) System.out.println("ob1==ob2"); System.out.println("Have a nice day!");
Have a nice day!
What interfaces can be implemented in order to create a class that can be serialized? (Choose all that apply.)
Have the class declare that it implements java.io.Serializable. There are no methods in the interface.,Have the class declare that it implements java.io.Externalizable, which defines two methods: readExternal and writeExternal
Mark the incorrect statement from the following:
In java language error processing is built into the language
Which of these class is implemented by FilterInputStream class?
InputStream
Which of these classes are used by Byte streams for input and output operation?
InputStream
Which of these classes is used for input and output operation when working with bytes?
InputStream
When we invoke repaint () for a java.awt.Component object, the AWT invokes the method
Insert()
What is the return type of the method getID() defined in AWTEvent class
Int
Consider the following data types in Java
Int, Boolean, Double
Consider the following data types in Java
Int, boolean, double above
Which of these is a wrapper for data type int?
Integer
14. Which of the following code snippets compile?
Integer i = 7; Integer i = new Integer(5); int j = i; byte b = 7;
Which of the following code snippets compile?
Integer i = 7;Interger i = new Integer(5);byte b=7
Which of the following code snippets compile?
Integeri=7,Integeri=new,byteb=7
Which of these can be used to fully abstract a class from its implementation?
Interfaces
How is IllegalArgumentException used? (Choose all correct options.)
It is thrown by certain methods of certain core Java classes to indicate that preconditions have been violated.,It should be used by programmers to indicate that preconditions of public methods have been violated.
What is use of wildcards?
It is used in cases when type being operated upon is not known.
What is use of Observable class?
It is used to create classes that other part of program can observe.
Which statements about JDBC are NOT true?
Java database;Java API for connecting
String s2 = "xyz"
Line 4, Line 6
How restrictive is the default accessibility compared to public, protected, and private accessibility
Less restrictive than protected from within a package, and more restrictive than protected from outside a package
1. public class A {2. public String doit(int x, int y) {3. return "a";4. }5.6. public String doit(int... vals) {7. return "b";8. }9. }Given:25. A a=new A();26. System.out.println(a.doit(4, 5));What is the result? (Choose one.)
Line 26 prints "a" to System.out.{// assume s is previously definedURL u = new URL(s);// in is an ObjectInputStreamObject o = in.readObject();System.out.println("Success");7. }8. catch (MalformedURLException e) {9. System.out.println("Bad URL");10. }11. catch (StreamCorruptedException e) 12. System.out.println("Bad file contents");13. }14. catch (Exception e) {15. System.out.println("General exception");16. }17. finally {18. System.out.println("Doing finally part");19. }20. System.out.println("Carrying on");Where:IOException extends Exception StreamCorruptedException extends IOException MalformedURLException extends IOExceptionWhat lines are output if the constructor at line 3 throws aMalformedURLException? (Choose three.)|Bad URL.Doing finally part.Carrying on
System.out.println(a.doit(4, 5))
Line 26 prints a to System.out
public class Test{ public static void main(String[] args){ String s1 = "xyz";String s2 = new String(s1);s2=s2.intern();if (s1 == s2) System.out.println("Line 4");if (s1.equals(s2)) System.out.println("Line 6");
Line 4 Line 6
public class Test{public static void main(String[] args){ String s1 = "xyz";String s2 = "xyz";if (s1 == s2) System.out.println("Line 4"); if (s1.equals(s2)) System.out.println("Line 6");
Line 4 Line 6
String s2 = "xyz";
Line 4;Line 6
s2=s2.intern();
Line 4;Line 6
The following program takes any number of numeric arguments & returns the sum & the average of those arguments. When this program run, is it throws an error? Find which line number is to be modified to give the correct output?
Line 5
55. int []x= {1, 2,3,4, 5};56. int y[] =x;57. System.out.println(y[2]);
Line 57 will print the value 3.
int []x= {1, 2,3,4, 5};
Line 57 will print the value 3.
Compilation will fail because of an error in line 55
Line 57...value 3
1. Object ob = new Object();2. String[] stringarr = new String[50];3. Float floater = new Float(3.14f);4. ob = stringarr;5. ob = stringarr[5];6. floater = ob;7. ob = floater;
Line 6
Consider the following code. Which line will not compile?
Line 6
Consider the following code. Which line will not compile?Object ob = new Object();String[] stringarr = new String[50];Float floater = new Float(3.14f);ob = stringarr;ob = stringarr[5];floater = ob;ob = floater;
Line 6
Float floater = new Float(3.14f)
Line 6
String s1 = "xyz";
Line 6
String s1 = "xyz";String s2 = new String(s1);s2.intern();if (s1 == s2) System.out.println("Line 4");if (s1.equals(s2)) System.out.println("Line 6");
Line 6
String s2 = new String("xyz")
Line 6
String s2 = new String("xyz");
Line 6
String s2 = new String(s1)
Line 6
Which one line in the following code will not compile?
Line 6
Which one line in the following code will not compile?byte b = 5;char c = '5';short s = 55;int i = 555;float f = 555.5f;b = s;i = c;if (f > b) f = i;
Line 6
byte b = 5;2. char c = '5';3. short s = 55;4. int i = 555;
Line 6
public class Test{public static void main(String[] args){ String s1 = "xyz";String s2 = new String("xyz");if (s1 == s2) System.out.println("Line 4"); if (s1.equals(s2)) System.out.println("Line 6");
Line 6
Line 4 executes and line 6 does not
Line 6 executes
String s1 = "abc" + "def";
Line 6 executes and line 4 does not.
The code will compile but will throw an exception at line 7, because runtime conversion from an interface to a class is not permitted
Line 7 will not compile
1. Raccoon rocky;2. SwampThing pogo;3. Washer w;4.5. rocky = new Raccoon();
Line 7 will not compile; an explicit cast is required to convert a Washer to a SwampThing.
A new directory called dirname and a new file called filename are created, both in the current working directory
No directory
1. File f1 = new File("dirname");
No directory is created, and no file is created.
6. You execute the following code in an empty directory. What is the result?1. File f1 = new File("dirname");2. File f2 = new File(f1, "filename");
No directory is created, and no file is created.
The code causes Java to throw int number = Integer.MAX_VALUE + 1
No exceptions
The code causes Java to throw int number = Integer.MAX_VALUE + 1;
No exceptions
byte b = 2; byte b1 = 3; b = b * b1;
No output because of compile error at line: b = b * b1;
public class Test{public static void main(String[] args){byte b = 2; byte b1 = 3; b = b * b1;System.out.println("b="+b);
No output because of compile error at line: b = b * b1;
Which of the following are legal loop definitions?
None of them are legal.
1. Which of the following operations might throw an ArithmeticException?
None of these
Which of the following operations might throw an ArithmeticException?
None of these
Polymorphism
Not simplifies code manintenance
Which of the following is not the reserved words in java
Num
Which of the following is not the reserved words in java?
Num.
Which of these is a super class of Character wrapper?
Number
Which of these is a super class of wrappers Byte and short wrappers?
Number
Which of these is a super class of wrappers Double & Integer?
Number
Which of these is a super class of wrappers Double and Float?
Number
Which of these is a super class of wrappers Long, Character & Integer?
Number
What information may be obtained from a ResultSetMetaData object
Number of columns in the result set
What information may be obtained from a ResultSetMetaData object?
Number of columns in the result set
class Selection{public static void main(String args[]){ int x=7; if(x==2); //? Note the semicolon
Number seven Not seven
A static method can have which of the following types of parameters?
Only explicit parameters.
Which of the following statements are true about a variable created with the static modifier?
Only one instance of a static variable will exist for any amount of class instances
An abstract class may not have any final methods
Only statement 2
Which of the following statements are true? 1)An abstract class may not have any final methods. 2)A final class may not have any abstract methods.
Only statement 2
Which of the following statements are true?1)An abstract class may not have any final methods.2)A final class may not have any abstract methods.
Only statement 2
Which of the following has a method names flush( )?
Output Stream
Which of the following cannot be Type parameterized?
Oveloaded Methods
Which of the following does not belong: If a class inherits from some other class, it should
Over-ride all the methods of its parent class
Suppose we now wish to print the balance information for an account with the following code:Account myAccount = new OverdraftAccount(5, 10);myAccount.printBalance();Which of the following statement is true?
OverdraftAccount: $5"
The correct order of the declarations in a Java program is
Package declaration, import statement, class declaration
If all three top-level elements occur in a source file, they must appear in which order
Package declaration, imports
If all three top-level elements occur in a source file, they must appear in which order?
Package declaration, imports, class/interface/enum
three top-level elements occur in a source file, they must appear
Package declaration, imports, class/interface/enum definitions
1. If all three top-level elements occur in a source file, they must appear in which order?
Package declaration, imports, class/interface/enum definitions.
If all three top-level elements occur in a source file, they must appear in
Package declaration, imports, class/interface/enum definitions.
If all three top-level elements occur in a source file, they must appear in which order?
Package declaration, imports, class/interface/enum definitions.
If all three top-level elements occur in a source file, they must appear in which order?
Package declaration,imports,class/interface/enum definitions.
Which of these is a mechanism for naming and visibility control of a class and its content?
Packages
Which of the following is not appropriate situations for assertions
Preconditions of a public method
Which of the following is not appropriate situations for assertions?
Preconditions of a public method
7. Which of the following are true? (Choose all that apply.)
Primitives are passed by value. References are passed by value.
Primitives are passed by reference.
Primitives are passed by value. References are passed by value.
Which of these class contains the methods print() & println()?
PrintStream
What does each of the following code samples do:A a = new B();
Prints "bye"
The blank space in the following sentence has to be correctly filled
Private
Which statement is true about accessibility of members
Private members can only be accessed by code from within the class
We would like to make a member of a class visible in all subclasses regardless of what package they are in. Which one of the following keywords would achieve this?
Private or protected
Which of these class can encapsulate an entire executing program?
Process
Which of these classes can return more than one character to be returned to input stream?
PushbachReader
Which of the following is a member of the java.lang package?
Queue
Which of these classes is not part of Java's collection framework?
Queue
Which of the following provides the naming services for the server to register the object and for the client to locate the object
RMI Registry
Which of the following provides the naming services for the server to register the object and for the client to locate the object?
RMI Registry
Which of these class can generate pseudorandom numbers?
Random
Which of the following statements about Java Threads is correct
Ready, running and sleeping are three states that a thread can be in during its life cycle
What is the process of defining a method in terms of itself, that is a method that calls itself?
Recursion
Which of these is not a correct statement?
Recursion is managed by Java's Run
Which of the following exceptions is thrown by every method of Runtime class?
SecurityException
The initial name given for Java is Oak
Select the correct statement from among the following
public void setAnchor(int x, int y) {
Shape s = new Circle(); s.setAnchor(10,10); s.draw();
Circle c = new Circle(); c.Shape.setAnchor(10,10); c.Shape.draw()
Shape s = new Circle...s.draw()
Which is identified as the first ever Object Oriented Programming Language?
Simula 67
What lines are output if the methods at lines 3 and 5 complete successfully without throwing any exceptions? (Choose all that apply.)
Success Doing finally part Carrying on
What lines are output if the methods at lines 3 and 5 complete successfully without throwing any exceptions
Success, Doing, Carrying
A class that represents the most general entity in an inheritance hierarchy is called a/an ____.
Superclass.
Test. java
Suppose you define a Java class as follows:
Which of the following is not a component of Java Integrated Development Environment (IDE)?
Symantec's Visual Caf
Which of the following is not a component of Java Integrated Development Environment
Symantec's Visual Café
System.out.println (-2U * ( g - k ) +c);
Syntax
System.out.println (-2U * ( g - k ) +c)
Syntax error
Standard output variable 'out' is defined in which class?
System
Which of these class holds a collection of static methods and variables?
System
Which of the following statements are true?
The + operator is overloaded for concatenation for the String class
How can you change the current working directory using an instance of the File class called FileName?
The File class does not support directly changing the cu
3. Which of the following are true?
The JVM runs until there are no non-daemon threads.
Which of the following are true?
The JVM runs until there are no non-daemon threads.
Which of the following statements are true?
The Set is designed for unique elements.
For a class defined inside a method, what rule governs access to the variables of the enclosing method?
The class can only access final variables
11. Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five interface methods. Which is/are true?
The class will compile if it is declared abstract.The class may not be instantiated.
Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five interface methods. Which are true?
The class will compile if it is declared abstract;The class may not be instantiated.
Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five interface methods. Which is/are true?
The class will compile;The class may not be instantiated.
Inty but does not provide implementations for any of the five interface methods. Which is/are true?
The class will declared abstract,not be instantiated.
What happens when you try to compile and run the following code? public class Q15 { static String s;public static void main(String[] args) {System.out.println(">>" + s + "<<");}}
The code compiles, and prints out >>null<<
public class Q {static String s;public static void main(String[] args) { System.out.println(">>" + s + "<<");
The code compiles, and prints out >>null<<
1. class Cruncher {2. void crunch(int i) {3. System.out.println("int version");
The code will compile and produce the following output: int version.
Consider the following class:
The code will compile and produce the following output: int version.
Consider the following class:class Cruncher {void crunch(int i) {System.out.println("int version");}void crunch(String s) {System.out.println("String version");} 8.public static void main(String args[]) {Cruncher crun = new Cruncher();char ch = 'p';crun.crunch(ch);}}
The code will compile and produce the following output: int version.
The code will compile and run, but the cast in line 6 is not required and can be eliminated
The code will compile and run
1. Dog rover, fido;2. Animal anim;3. 4. rover = new Dog();
The code will compile and run.
14. Given the following code, which of the results that follow would you expect? package mail; interface Box { protected void open(); void close(); public void empty(); }
The code will not compile because of line 4.
1. Given the following class:class A extends java.util.Vector { private A(int x) { super(x); }}
The compiler does not create a default constructor.
Which of the following statements are true regarding the finalize( ) method?
The finalize ( ) method can be overloaded
Which of the following statements are true?
The following statement will produce a result of zero, System.out.println(1 >>1);
Which of the following statements are true?
The garbage collection algorithm in Java is vendor implemented
Select the correct statement from among the following:
The initial name given for Java is Oak
Which of the following statements are true?
The instanceof operator can be used to determine if a reference is an instance of a particular primitive wrapper class
Select incorrect statement about Socket class. (choose 1)
The java.net.Socket class contains code that knows how to find and communicate with a server through UDP.
In object oriented programming, composition relates to
The organization of components interacting to achieve a coherent, common behavior
What does the following code do?Integer i = null;if (i != null & i.intValue() == 5) System.out.println("Value is 5");Throws an exception.1. FileOutputStream fos = new FileOutputStream("xx");2. for (byte b=10; b<50; b++)3. fos.write(b);4. fos.close();
The output is i = 20.
Which statement is true about the following code fragment?
The output would be the text value is two followed by the text value is three.
case 2 + 1:
The output would be the text value is two followed by the text value is three.
1. public class Xor {
The output: b contains 5
1. public class Xor {2. public static void main(String args[]) {3. byte b = 10; // 00001010 binary4. byte c = 15; // 00001111 binary5. b = (byte)(b ^ c);6. System.out.println("b contains " + b);7. }8. }
The output: b contains 5
What results from running the following code?public class Xor {public static void main(String args[]) {byte b = 10; // 00001010 binary byte c = 15; // 00001111 binary b = (byte)(b ^ c);System.out.println("b contains " + b);}}
The output: b contains 5
1. public class Conditional {2. public static void main(String args[]) {3. int x = 4;
The output: value is 9.0
1. public class Conditional {2. public static void main(String args[]) {3. int x = 4;4. System.out.println("value is " +5. ((x > 4) ? 99.99 : 9));6. }7. }
The output: value is 9.0
System.out.println("value is " + ((x > 4) ? 99.99 : 9));
The output: value is 9.0
What results from attempting to compile and run the following code?public class Conditional {public static void main(String args[]) {int x = 4;System.out.println("value is " +((x > 4) ? 99.99 : 9));}}
The output: value is 9.0
The setCardlnformation method breaks encapsulation
The ownerName
13. public class Pass {20. public class CreditCard {22. private String cardlD;23. private Integer limit;24. public String ownerName;26. public void setCardlnformation(String cardlD,
The ownerName variable breaks encapsulation.
public void setCardlnformation(String cardlD,String ownerName,Integer limit)
The ownerName variable breaks encapsulation.
Account myAccount = new OverdraftAccount(5, 10);
The printed output is the string "OverdraftAccount: $5"
What can cause a thread to stop executing?
The pro The prio A call to the s
Compilation of Nightingale will succeed, but an exception will be thrown at line 10, because method fly() is protected in the superclass
The program...After: 2
Which of the following is a good indicator that a class is overreaching and trying to accomplish too much?
The public interface refers to multiple concepts
Which of the following is not true for a java thread?
The run method calls start method
Suppose you want to write a class that offers static methods to compute hyperbolic trigonometric functions. You decide to subclass java.lang.Math and provide the new functionality as a set of static methods. Which one
The strategy fails because you cannot add static methods to a subclass.
Suppose you want to write a class that offers static methods to compute hyperbolic trigonometric functions. You decide to subclass java.lang.Math and provide the new functionality as a set of static methods. Which one statement is true about this strategy?
The strategy fails because you cannot add static methods to a subclass.
3. Suppose you want to write a class that offers static methods to compute hyperbolic trigonometric functions. You decide to subclass java.lang.Math and provide the new functionality as a set of static methods. Which one statement is true about this strategy?
The strategy fails because you cannot subclass java.lang.Math.
Suppose you want to write a class that offers static methods to compute hyperbolic trigonometric functions. You decide to subclass java.lang.Math and provide the new functionality as a set of static methods. Which one statement is true about this strategy?
The strategy fails because you cannot subclass java.lang.Math.
static methods. Which one statement is true about this strategy?
The strategy fails because you cannot subclass java.lang.Math.
What is the result of the expression 75.22 + "5.2"?
The string is "75.225.2"
Suppose you want to use a DateFormat to format an instance of Date. What factors influence the string returned by DateFormat's format() method?
The style, which is one of SHORT, MEDIUM, LONG, or FULL ,The locale
1. Suppose you want to use a DateFormat to format an instance of Date. What factors influence the string returned by DateFormat's format() method?
The style, which is one of SHORT, MEDIUM, LONG, or FULL.The locale
3. Which of the following statements about the wait() and notify() methods is true?
The thread that calls wait() goes into the monitor's pool of waiting threads.
Which of the following statements about the wait() and notify() methods is true?
The thread that calls wait() goes into the monitor's pool of waiting threads.
Which of the following statements about the wait() and notify() methods is true? (Choose one.)
The thread that calls wait() goes into the monitor's pool of waiting threads.
What is byte code in the context of Java
The type of code generated by a Java compiler
What is byte code in the context of Java?
The type of code generated by a Java compiler
6. In the following code fragment, after execution of line 1, sbuf references an instance of the StringBuffer class. After execution of line 2, sbuf still references the same instance.1. StringBuffer sbuf = new StringBuffer("abcde");2. sbuf.append("xyz");
True
6. In the following code fragment, after execution of line 1, sbuf references an instance of the StringBuffer class. After execution of line 2, sbuf still references the same instance.1. StringBuffer sbuf = new StringBuffer("abcde");2. sbuf.insert(3, "xyz");
True
A StringBuffer is slower than a StringBuilder, but a StringBuffer is threadsafe.
True
After execution of line 2, sbuf still references the same instance.1. StringBuffer sbuf = new StringBuffer("FPT");2. sbuf.append("-University");
True
After execution of line 2, sbuf still references the same instance.1. StringBuffer sbuf = new StringBuffer("FPT");2. sbuf.insert(3, "-University");
True
An abstract class can contain methods with declared bodies.
True
How many bytes a Java character uses for storing
Two bytes
How many bytes a Java character uses for storing?
Two bytes
Single-line comments that should be ignored by the compiler are denoted using
Two forward slashes ( // )
JDBC supports ______ and ______ models
Two-tier and three-tier
JDBC supports and models.
Two-tier and three-tier
JDBC supports___and___models.
Two-tier and three-tier
drivers that implement the JDBC API as a mapping to another data access API, such as ODBC. Drivers of this type are generally dependent on a native library, which limits their portability
Type 1
drivers that implement the JDBC API as a mapping to another data access API, such as ODBC. Drivers of this type are generally dependent on a native library, which limits their portability.
Type 1
drivers that implement the JDBC API as a mapping to another data access API, such as ODBC. Drivers of this type are generally ependent on a native library, which limits their portability.
Type 1
drivers that are written partly in the Java programming language and partly in native code. These drivers use a native client library specific to the data source to which they connect
Type 2
drivers that are written partly in the Java programming language and partly in native code. These drivers use a native client library specific to the data source to which they connect. Again, because of the native code, their portability is limited.
Type 2
drivers that use a pure Java client and communicate with a middleware server using a database-independent protocol. The middleware server then communicates the client's requests to the data source
Type 3
drivers that use a pure Java client and communicate with a middleware server using a database-independent protocol. The middleware server then communicates the client's requests to the data source.
Type 3
Select INCORRECT statement about deserialize
We use readObject
Select INCORRECT statement about deserialize.
We use readObject() method of ObjectOutputStream class to deserialize.
Select INCORRECT statement about deserialize. (choose 1)
We use readObject() method of ObjectOutputStream class to deserialize.
A compilation error will occur at (3), since the class does not have a constructor which takes one argument of type int
What will be the result of attempting to compile the following program?
of
What would be the output of the statement indicated in line number 06 when the program is executed
true
What would be the output of the statement indicated in line number 07 when the program is executed
There is nothing wrong with the code
What would be the result of attempting to compile and run the following
The program will fail to compile if break is simply removed
What, if anything, is wrong with following code
What is the difference between yielding and sleeping?
When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.
What is garbage collection in the context of Java
When all references to an object are gone, the memory used by the object is automatically
What is garbage collection in the context of Java
When all references to an object are gone, the memory used by the object is automatically reclaimed.
What is garbage collection in the context of Java?
When all references to an object are gone, the memory used by the object is automatically reclaimed.
Select INCORRECT statement about serialization
When an Object Output
Select INCORRECT statement about serialization. (choose 1)
When an Object Output Stream serializes an object that contains references
Which of the following are true? (Choose all that apply.)
When an application begins running, there is one non-daemon thread, whose job is to execute main().,A thread created by a daemon thread is initially also a daemon thread.,A thread created by a non-daemon thread is initially also a non-daemon thread.
If you create a TextField with a constructor to set it to occupy 5 columns, what difference will it make if you use it with a proportional font (ie Times Roman) or a fixed pitch typewriter style font (Courier)
With a fixed font you will see 5 characters, with a proportional it will
Which of the following statements are true regarding the following method? void callMe(String... names) { }
Within the method, names is an array containing Strings.
void callMe(String... names) { }
Within the method, names is an array containing Strings.
Which of these classes are used by character streams for input and output operations?
Writer
Which of these classes are used by character streams output operations?
Writer
What would the output be of the above Program - III before and after it is called?
a and b before call : 15 20 a and b after call : 15 20
When an array is created, all elements are initialized with ___.
a fixed value that depends on the element type
1. public class Outer {2. public int a = 1. private int b = 2;4. public void method(final int c) {5. int d = 3, f=10;
a.b.c.e
IdentifyMyParts a = new IdentifyMyParts();
a.y = 5 b.y = 6 a.x = 2 b.x = 2
Which of these methods can be used to search an element in a list?
binaryserach()
What is the return type of the instanceof operator
boolean
Which of these data type value is returned by equals() method of String class?
boolean
14. Select the valid primitive data types. (Select all that apply.)
boolean float char
A pet has an owner, a registration date, and a vaccination-due date. A cat is a pet that has a flag indicating whether it has been neutered, and a textual description of its markings
boolean, string
Select the valid primitive data types. (Select all that apply.)
boolean,char, float
Select the valid primitive data types.
boolean,char,float
may appear on the right-hand side of an instanceof operator
class and interface
Which of the following is correct way of implementing an interface salary by class manager?
class manager implements salary {}
Which of these is an correct way of defining generic class?
class name { /* ... */ }
Which of these methods deletes all the elements from invoking collection
clear()
Which of these method of Object class can generate duplicate copy of the object on which it is called?
clone()
Which two are true if a NullPointerException is thrown on line 3 of class C
code on line 29, The exception
13. public enum Dogs {collie, harrier};14. public static void main(String [] args) {15. Dogs myDog = Dogs.collie;16. switch (myDog) {
collie harrier
System.out.print("collie ");
collie harrier
collie
collie harrier
Select INCORRECT statement about serialization
dai nhat
Select incorrect statement about ServerSocket class.
dai nhat
The application must be run with the -enableassertions flag or another assertionenabling flag
dai nhat, one or more
Compilation of Parrot.java fails at line 7 because method getRefCount() is static in the superclass, and static methods may not be overridden to be nonstatic
dai nhat: nonstatic
Both primitives and object references can be both converted and cast
dap an
and the rules governing these conversions are identical
dap an
When the exception is being thrown in response to catching of a different
exception type
Re-implementing an inherited method in a sub class to perform a different task from the parent class is called
extending
You access array list elements with an integer index, using the __________.
get method
Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?
getBytes()
Which of these method of class String is used to extract more than one character at a time a String object?
getChars()
Which of these methods returns the class of an object?
getClass()
Which of these method of Locale class can be used to obtain country of operation?
getDisplayCountry()
Which of these methods return localized description of an exception?
getLocalizedMessage()
Which of these methods return description of an exception?
getMessage()
Every event object has the ________ method
getSource()
Every event object has the ________ method.
getSource()
Which of these methods of Character wrapper can be used to obtain the char value contained in Character object.
getValue()
Which of the following are methods of the java.util.SortedMap interface
headMap, tailMap, subMap
Which of the following are methods of the java.util.SortedMap interface?
headMap,tailMap,subMap
7. Which of the following are methods of the java.util.SortedMap interface?
headMap.tailMap.subMap
Given the following class:public class Xyz implements java.io.Serializable {public int iAmPublic; private int iAmPrivate; static int iAmStatic; transient int iAmTransient; volatile int iAmVolatile;}Assuming the class does not perform custom serialization, which fields are written when an instance of Xyz is serialized? (Choose three.)
iAmPublic.iAmPrivate.iAmVolatile
public class Xyz implements java.io.Serializable
iAmPublic;iAmPrivate;iAmVolatile
The tens' digit of n is 3
if (n / 10 % 10 == 3) System.out.println("Bingo!");
Which one statement is true about the following code?
if (s1 == s2)
E Which one statement is true about the following code fragment?
if (s1.equals(s))
1. Suppose x and y are of type TrafficLightState, which is an enum. What is the best way to test whether x and y refer to the same constant?
if (x == y)
Suppose x and y are of type TrafficLightState, which is an enum. What is the best way to test whether x and y refer to the same constant
if (x == y)
Suppose x and y are of type TrafficLightState, which is an enum. What is the best way to test whether x and y refer to the same constant?
if (x == y)
Suppose x and y are of type TrafficLightState, which is an enum. What is the best way to test whether x and y refer to the same constant? (Choose one.)
if (x == y)
30
if (x%2 = = 0) result + = x
Which of the following are keywords or reserved words in Java?
if goto while case
MerryMerrMerOh no!
if( i++ == 0 ) System.out.print("Merry");
An anonymous inner class may implement arbitrarily many interfaces.
implement at most one interface. extend a parent class other than Object.
1. Which of the following are true?
implement at most one interface.extend a parent class other than Object.
An anonymous inner class that implements several interfaces may extend a parent class other than Object
implement at most, class may extend
Which of these keywords is used by a class to use an interface defined previously?
implements
Which of the following are legal import statements?
import java.util.Vector,import static java.util.Vector.*
Which of the following expressions results in a positive value in x?
int x = -1; x = x >>> 5;
1. Which of the following expressions are legal? (Choose all that apply.)
int x = 6; if (!(x > 3)) {} int x = 6; x = ~x;
Which of the following expressions are legal? (Choose two.)
int x = 6; if (!(x > 3)) {} int x = 6; x = ~x;
Which of the following expressions are legal?
int x = 6; if (!(x > 3)) {};int x = 6; x = ~x;
Which of the following expressions are legal? (Choose two.)
int y = 9; x += y
Which of the following will compile correctly
int z = 015;
1. byte b = 11;2. short s = 13;3. result = b * ++s;
int, long, float, double
In the following code, what are the possible types for variable result? (Choose the most complete true answer.)
int, long, float, double
In the following code, what are the possible types for variable result? byte b = 11;short s = 13;result = b * ++s;
int, long, float, double
result = b * ++s;
int, long, float, double
what are the possible types for variable result
int, long, float, double
What is the type of a variable that references an array of integers?
int[]
The program displays 1 2 3 4 5
int[] oldList = {1, 2, 3, 4, 5};
The program has a runtime error because the last statement in the main method causes ArrayIndexOutOfBoundsException
int[] x = new int[5];
2 1
int[] y = {1, 2, 3, 4, 5};
Which of these keywords is used to define interfaces in Java?
interface
8. public class test {9. public static void main(String [] a) {10. assert a.length == 1;11. }12.}
java -ea test. java -ea test file1 file2
Which of the follows JDK command is correct to run a Java application in ByteCode.class
java ByteCode
Which of the follows JDK command is correct to run a Java application in ByteCode.class?
java ByteCode
java server page is an extension of
java servlet.
Which of these packages contain classes and interfaces used for input & output operations of a program?
java.io
File class is included in which package
java.io package
File class is included in which package?
java.io package
Basic Java language functions are stored in which of the following java package
java.lang
Basic Java language functions are stored in which of the following java package?
java.lang
Which of the following package is automatically imported to your program file?
java.lang
Which of these class is superclass of String and StringBuffer class?
java.lang
Which of these is not a correct statement?
java.lang
Which of these packages contains the exception Stackoverflow in Java?
java.lang
you want to write a class that offers static methods to compute hyperbolic trigonometric functions. You decide to subclass java.lang.Math and provide the new functionality as a set of static methods
java.lang.Math
14. Which class provides locale-sensitive text formatting for date and time information?
java.text.DateFormat
Which class provides locale-sensitive text formatting for date and time information
java.text.DateFormat
Which of the following restrictions apply to anonymous inner classes
must be defined
Which of the following is not a valid Java identifier?
my Value
When the application runs, what are the values of n and w.x after the call to bump() in the main
n is 10, w.x is 11
Which methods return an enum constant's name? (Choose two.)
name() toString()
Which methods return an enum constant's name
name(), toString()
Which methods return an enum constant's name?
name(),toString()
Which methods return an enum constant's name?
name();toString()
Object ob2= ob1
ob1 equals ob2, ob1==ob2
Arrays in Java are implemented as?
object
Which of these cannot be declared static?
object
Which of the following statements are true? (Select all that apply.)
object cannot reassigned
Multiple inheritance means
one class inheriting from more super classes
What will s2 contain after following lines of code?
onetwo
1. Given a class with a public variable theTint of type Color, which of the following methods are consistent with the JavaBeans naming standards?
public Color getTheTint()
Given a class with a public variable theTint of type Color, which of the following methods are consistent with the JavaBeans naming standards
public Color getTheTint()
Given a class with a public variable theTint of type Color, which of the following methods are consistent with the JavaBeans naming standards?
public Color getTheTint()
Which of the following are legal clone() methods in a class called Q13 that extends Object?
public Object clone() throws CloneNotSupportedException { return super.clone(); },public Q13 clone() throws CloneNotSupportedException { return (Q13)super.clone(); }
The declaration of the java.util.Collection interface is interface Collection <E> The addAll() method of that interface takes a single argument, which is a reference to a collection whose elements are compatible with E. What is the declaration of the addAll() method?
public boolean addAll(Collection<? extends E> c)
protected class Cat extends Owner
public class Cat extends Pet
Suppose class Supe, in package packagea, has a method called doSomething(). Suppose class Subby, in package packageb, overrides doSomething(). What access modes may Subby's version of the method have?
public, protected
Select the order of access modifiers from least restrictive to most restrictive.
public, protected, default, private
Suppose class aaa.Aaa has a method called callMe(). Suppose class bbb.Bbb, which extends aaa.AAA, wants to override callMe(). Which access modes for callMe() in aaa.AAA will allow this?
public,protected
Select the order of access modifiers from least restrictive to most restrictive.
public,protected,default,private
void doSomething(int a, float b)
public...(int a, float b)
27. Suppose class aaa.Aaa has a method called callMe(). Suppose class bbb.Bbb, which extends aaa.AAA, wants to override callMe(). Which access modes for callMe() in aaa.AAA will allow this?
public.protected
Suppose class Supe, in package packagea, has a method called doSomething(). Suppose class Subby, in package packageb, overrides doSomething(). What access modes may Subby's version of the method have?
public;protected
protected abstract double getSalesAmount();
public;protected
Suppose class A has a method called doSomething(), with default access. Suppose class B extends A and overrides doSomething(). Which access modes may apply to B's version of doSomething()?
public;protected;Default
Which of these method is used add an element and corresponding key to a map?
put()
are valid mode strings for the RandomAccessFile constructor
r, rw, rws, rwd
Which of these method return a pseudorandom number?
random()
Which of these method of FileReader class is used to read characters from a file?
read()
Which of these method of InputStream is used to read integer representation of next available byte input?
read()
Which of these is used to read a string from the input stream?
readLine()
Which of these method is used to change an element in a LinkedList Object?
redo()
may appear on the left-hand side of an instanceof operator
reference
Which of these methods is used to compare a specific region inside a string with another specific region in another string?
regionMatches()
Which of these method is used to remove all keys/values pair from the invoking map?
remove()
Which of these methods can be used to delete the last element in a LinkedList object?
removeLast()
Which of the following statement is correct?
replace() method replaces all occurrences of one character in invoking string with another character.
The returned value varies depending on the argument
returns 0
Given below is the syntax of the method declaration in java.Syntax: modifier returnType MethodName (parameter List) { statement(s);}
returntype, methodname and parameter list
Syntax: modifier returnType MethodName (parameter List) {statement(s);}
returntype, methodname and parameter list
Which of these method of class StringBuffer is used to reverse sequence of characters?
reverse()
Which of the following statement is correct?
reverse() method reverses all characters
Which of the following statement is correct?
reverse() method reverses all characters.
Which of these method is a rounding function of Math class?
rint()
Which of the following are methods of the Runnable interface
run
Which of the following is not an Applet method?
run()
catch (InterruptedException e)
running some time
Which method that executes immediately after the init () method in an applet
start()
Which method that executes immediately after the init () method in an applet?
start()
Which of these method of class String is used to check weather a given object starts with a particular string literal?
startsWith()
Which of these is used to access member of class before object of that class is created?
static
The fields in an interface are implicitly specified as
static and final
4. Which of the following methods in the Thread class are deprecated?
suspend() and resume()
Which of the following methods in the Thread class are deprecated
suspend() and resume()
Which of the following methods in the Thread class are deprecated?
suspend() and resume()
methods in the Thread class are deprecated
suspend() and resume()
Which of these combinations of switch expression types and case label value types are legal within a switch statement
switch expression of type int and case label value of type char
3. Which of the following are true? (Choose all that apply.)
synchronizes on the lock of the current object.the object on whose lock the block
1. Which of the following are true? (Choose all that apply.)
the main() method of an application.toString() method.wait() method.notify() method.
first second first third snootchy 420
third second first snootchy 420
Which keyword is used by method to refer to the object that invoked it?
this
Which of these keywords are used for generating an exception manually?
throw
Which of these keywords is used to generate an exception explicitly?
throw
Which of these keywords is used to manually throw an exception?
throw
Which of these keywords is not a part of exception handling?
thrown
An exception is thrown at line 6
thrown at line 7
What happens when you try to compile and run the following application
thrown at line 9
appropriate to pass a cause to an exception's constructor
thrown in response to catching of a different exception type
Whenever a method does not want to handle exceptions using the try block, the
throws
Whenever a method does not want to handle exceptions using the try block, the is used.
throws
Which of these keywords is used to by the calling function to guard against the exception that is thrown by called function?
throws
BigOlLongStringWithMeaninglessName
tick all
Which of the following is legal valid variable name?
timeOfDay
Which of the following is not a reason to place classes into a package?
to make it easier to include a set of frequently used but unrelated classes
Which of these methods return string equivalent of Boolean object?
toString()
1. Which methods return an enum constant's name?
toString().name()
Breaking down a large complex procedure into a number of smaller procedures is referred to as
top down decomposition.
8. Which modifier or modifiers should be used to denote a variable that should not be written out as part of its class's persistent state? (Choose the shortest possible answer.)
transient
What keyword is used to prevent an object from being serialized
transient
What keyword is used to prevent an object from being serialized?
transient
Which modifier or modifiers should be used to denote a variable that should not be written out as part of its class's persistent state
transient
Which modifier or modifiers should be used to denote a variable that should not be written out as part of its class's persistent state?
transient
Which modifier or modifiers should be used to denote a variable that should not be written out as part of its class's persistent state? (Choose the shortest possible answer.)
transient
denote a variable that should not be written out as part of its class's persistent state
transient
Which of the following are Java keywords?
transient volatile
Which of these method of class String is used to remove leading and trailing whitespaces?
trim()
Which JDBC processing model that requires a JDBC driver that can communicate with the particular data source being accessed
two-tier
Which JDBC processing model that requires a JDBC driver that can communicate with the particular data source being accessed?
two-tier
The code will compile but will throw an exception at line 7, because runtime conversion from an interface to a class is not permitted
type SwampThing
Which of these is a process of converting a simple data type into a class?
type wrapping
Which of these is true about unmodifiableCollection() method?
unmodifiableCollection() method is available only for List and Set.
When we invoke repaint () for a java.awt.Component object, the AWT invokes the method
update()
Which of these methods is used to notify observer the change in observed object?
update()
The output: value is 99.99
value is 9.0
The acceptable types for the variable j, as the argument to the switch() construct, could be any of byte, short, int, or long
value is three
What is the value returned by function compareTo() if the invoking string is less than the string compared?
value less than zero
What is the value returned by unction compareTo() if the invoking string is less than the string compared?
value less than zero
Which of these methods is used to know whether a string contains "true"?
valueOf()
Transient methods may not be overridden
variables are not
Which of the following are legal identifiers
varible2 _whave_3_ $anoervar
Which of the following signatures are valid for the main() method entry point of an application? (Choose two.)
void main(String arg[]) public static void main(String[] args)
Which one of these is a valid method declaration
void method2()
Which one of these is a valid method declaration?
void method2()
1. Which of the following may override a method whose signature is void xyz(float f)?
void xyz(float f) public void xyz(float f)
Which of the following may override a method whose signature is void xyz(float f)? (Choose two.)
void xyz(float f) public void xyz(float f)
Which of the following statements are incorrect?
when object of class is declared, each object contains its own copy of static variables.
1. int x, a = 6, b = 7;2. x = a++ + b++;
x = 13, a = 7, b = 8
int x, a = 6, b = 7; x = a++ + b++;
x = 13, a = 7, b = 8
What is the output of the following code? class Bitwise {
x&y=4 x|y=7 x^y=3
After execution of the following code fragment, what are the values of the variables x, a, and b
x13, a7, b8
What is the output of the following code? class SpecialArithmetic {
x=19 a=17 x=19 b=19 x=18 a=19 x=17 b=17
System.out.println("x>>>1=" +(x>>>1));
x>>>1=3
int[] x = new int[25]
x[24] is 0 and x.length is 25
int[] x = new int[25]; After execution, which statements are true? (Choose all that apply.)
x[24] is 0 x.length is 25
int[] x = new int[25];
x[24] is 0,x.length is 25
int[] x = new int[25];
x[24] is 0;x.length is 25
int x=7, y=11, z=11;
y<=z = true