You can determine all the keys in a Map in which of the following ways? | By ge tting a Set object from the Map and iterating through it. What keyword is used to prevent an object from being serialized? | transient An abstract class can contain methods with declared bodies. | True Select the order of access modifiers from least restrictive to most restrictive | public, protected, default, private Which access modifier allows you to access method calls in libraries not create d in Java? | native Which of the following statements are true? (Select all that apply.) | D. A final object cannot be reassigned a new address in memory. The keyword extends refers to what type of relationship? | A. is a Which of the following keywords is used to invoke a method in the parent clas s? | B. super public static void main(String [] a) { Funcs f = new Funcs(); System.out.pri ntln("" + f.add(1, 2)); | C. The code does not compile. public static void main(String [] a) { int [] b = [1,2,3,4,5,6,7,8,9,0]; Syst em.out.println("a[2]=" + a[2]); | D. The code does not compile. What is the value of x after the following operation is performed? x = 23 % 4; | D. 3 Given the following code, what keyword must be used at line 4 in order to stop execution of the for loop? boolean b = true; for (;;) { if (b) { | C. break What method call is used to tell a thread that it has the opportunity to run? | B. notify() Given the following code, which of the results that follow would you expect? p ackage mail; interface Box { protected void open(); void close(); public void empty(); | A. The code will not compile because of line 4. Assertions are used to enforce all but which of the following? | C. Exceptio ns The developer can force garbage collection by calling System.gc(). | B. False Select the valid primitive data types. (Select all that apply.) | boolean char f loat How many bits does a float contain? | 32 What is the value of x after the following line is executed? x = 32 * (31 10 * 3); | 32 A StringBuffer is slower than a StringBuilder, but a StringBuffer is threadsafe. | A. True Select the list of primitives ordered in smallest to largest bit size represent ation. | D. char, int, float, long Which class provides locale-sensitive text formatting for date and time informat ion? | D. java.text.DateFormat The following line of code is valid. int x = 9; byte b = x; | B. False Which of the following code snippets compile? | A. Integer i = 7; B. Integer i = new Integer(5); int j = i; C. byte b = 7; What will be the output of the following code? public class StringTest { public static void main(String [] a) { String s1 = "test string"; String s2 = "tes t string"; if (s1 == s2) { System.out.println("same"); } else { System.out.pr intln("different"); | D. same will be printed out to the console. Java arrays always start at index 1. | False Which of the following statements accurately describes how variables are passe d to methods? | C. Arguments that are primitive type are passed by value. How do you change the value that is encapsulated by a wrapper class after you have instan- tiated it? | D. None of the above. Suppose you are writing a class that provides custom deserialization. The class implements java.io.Serializable (and not java.io.Externalizable). What method s hould imple- ment the custom deserialization, and what is its access mode? | A. private readObject A signed data type has an equal number of non-zero positive and negative value s available. | B. False Choose the valid identifiers from those listed here. (Choose all that apply.) | A. BigOlLongStringWithMeaninglessName B. $int C. bytes D. $1 E.
finalist Which of the following signatures are valid for the main() method entry point of an application? (Choose all that apply.) | B. public static void main(String arg[]) D. public static void main(String[] args) If all three top-level elements occur in a source file, they must appear in whi ch order? | D. Package declaration, imports, class/interface/enum definitions. Consider the following line of code: int[] x = new int[25]; After execution, which statements are true? (Choose all that apply.) | A. x[24] is 0 E. x.length is 25 Consider the following application: class Q6 { public static void main(String args[]) { Holder h = new Holder(); h.held = 100; h.bump(h); System.out.println (h.held); } } class Holder { public int held; public void bump(Holder theHolde r) { theHolder.held++; } Consider the following application: class Q7 { public static void main(String args[]) { double d = 12.3; Decrementer dec = new Decrementer(); dec.decrement (d); System.out.println(d); } } class Decrementer { public void decrement(doub le decMe) { decMe = decMe - 1.0; | C. 12.3 How can you force garbage collection of an object? | A. Garbage collection cann ot be forced. What is the range of values that can be assigned to a variable of type short? | D. -215 through 215 - 1 What is the range of values that can be assigned to a variable of type byte? | D . -27 through 27 - 1 Suppose a source file contains a large number of import statements. How do the imports affect the time required to compile the source file? | B. Compilat ion takes slightly more time Suppose a source file contains a large number of import statements and one cl ass definition. How do the imports affect the time required to load the class? | A. Class loading takes no additional time. Which of the following are legal import statements? | A. import java.uti l.Vector; C. import static java.util.Vector.*; Which of the following may be statically imported? (Choose all that apply.) | B. Static method names C. Static field names What happens when you try to compile and run the following code? public class Q 15 { static String s; public static void main(String[] args) { System.out.pr The code compiles, and prints out >>null<< intln( >> + s + << ); | C. Which of the following are legal? (Choose all that apply.) | C. int c = 0xabcd ; D. int d = 0XABCD; Which of the following are legal? (Choose all that apply.) | A. double d = 1.2 d; B. double d = 1.2D; Which of the following are legal? | C. char c = \u1234 ; Consider the following code: StringBuffer sbuf = new StringBuffer(); sbuf = nu ll System.gc(); | C. After line 2 executes, the StringBuffer object is eligib le for garbage collection. Which of the following are true? (Choose all that apply.) | B. Primitives are p assed by value. D. References are passed by value. After execution of the following code fragment, what are the values of the var iables x, a, and b? int x, a = 6, b = 7; x = a++ + b++; | C. x = 13, a = 7, b = 8 Which of the following expressions are legal? (Choose all that apply.) | B. int x = 6; if (!(x > 3)) {} C. int x = 6; x = ~x; Which of the following expressions results in a positive value in x? | A. int x = 1; x = x >>> 5; Which of the following expressions are legal? (Choose all that apply.) | A. String x = "Hello"; int y = 9; x += y; C. String x = "Hello"; int y = 9; x = x + y; What is -8 % 5? | A. -3 What is 7 % -4? | B. 3 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); | B. The output: b contains 5 What results from attempting to compile and run the following code? public class Conditional { public static void main(String args[]) { int x = 4; System.ou t.println("value is " + ((x > 4) ? 99.99 : 9)); | C. The output: value is 9. 0 What does the following code do? Integer i = null; if (i != null & i.int Value() == 5) System.out.println( Value is 5 ); | B. Throws an exception. 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); | A. Yes Suppose ob1 and ob2 are references to instances of java.lang.Object. If (ob1 = = ob2) is false, can ob1.equals(ob2) ever be true? | B. No When a byte is added to a char, what is the type of the result? | C. int When a short is added to a float, what is the type of the result? | C. float Which statement is true about the following method? int selfXor(int i) { retur n i ^ i; | A. It always returns 0. Which of the following operations might throw an ArithmeticException? | D. / What is the return type of the instanceof operator? | D. A boolean Which of the following may appear on the left-hand side of an instance of oper ator? | A. A reference Which of the following may appear on the right-hand side of an instance of opera tor? (Choose all that apply.) | B. A class C. An interface What is -50 >> 1? | D. -25 Which of the following declarations are illegal? (Choose all that apply.) | A. d efault String s; D. abstract double d; E. abstract final double hyperbolicCos ine(); Which of the following statements is true? | B. A final class may not have any abstract methods. What is the minimal modification that will make this code compile correctly? fin al class Aaa { int xxx; void yyy() { xxx = 1; } } class Bbb extends Aaa { fin al Aaa finalref = new Aaa(); final void yyy() { System.out.println("In metho d yyy()"); finalref.xxx = 12345; } } | A. On line 1, remove the final modifier. 4. Which of the following statements is true? | E. Transient variables are not serialized 5. Which statement is true about this application? class StaticStuff { sta tic int x = 10; static { x += 5; } public static void main(String args[]) { System.out.println("x = " + x); } static {x /= 5; } } | E. The code compiles an d execution produces the output x = 3. 6. Which statement is true about this code? class HasStatic { private stat ic int x = 100; public static void main(String args[]) { HasStatic hs1 = new HasStatic(); hs1.x++; HasStatic hs2 = new HasStatic(); hs2.x++; hs1 = new HasS tatic(); hs1.x++; HasStatic.x++; System.out.println("x = " + x); } } | E. The pr ogram compiles and the output is x = 104. 7. Given the following code, and making no other changes, which combination of access modifiers (public, protected, or private) can legally be placed befor e aMethod() on line 3 and be placed before aMethod() on line 8? class SuperDuper { void aMethod() { } } class Sub extends SuperDuper { void aMethod() { } } | D. line 3: private; line 8: protected 8. Which modifier or modifiers should be used to denote a variable that sho uld not be written out as part of its class s persistent state? (Choose the short est possible answer.) | D. transient 11. Suppose class Supe, in package packagea, has a method called doSomething (). Suppose class Subby, in package packageb, overrides doSomething(). What ac cess modes may Subby s version of the method have? (Choose all that apply.) | A. public B. protected 12. Which of the following statements are true? | F. None of the above. 13. Suppose interface Inty defines five methods. Suppose class Classy decla res that it implements Inty but does not provide implementations for any of the
five interface methods. Which is/are true? | C. The class will compile if it is declared abstract. D. The class may not be instantiated. 14. Which of the following may be declared final? (Choose all that apply.) | A. Classes B. Data C. Methods 15. Which of the following may follow the static keyword? (Choose all that apply.) | B. Data C. Methods D. Code blocks enclosed in curly brackets 16. 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.) | A. public C. pro tected D. Default 17. True or false: If class Y extends class X, the two classes are in differ ent packages, and class X has a protected method called abby(), then any insta nce of Y may call the abby() method of any other instance of Y. | B. False 18. Which of the following statements are true? | D. A final class may not be extended. 1. Which of the following statements is correct? (Choose one.) | D. Both primitives and object references can be both converted and cast. 5. float f = 555.5f; 6. b = s; 7. i = c; | F. Line 6 4. In the following code, what are the possible types for variable result? (Choose the most complete true answer.) 1. byte b = 11; 2. short s = 13; 3. result = b * ++s; | E. int, long, float, double 6. Which of the following statements is true? (Choose one.) | D. Object r eferences can be converted in both method calls and assignments, and the rule s governing these conversions are identical. is a set of java API for executing SQL statements. | JDBC method is used to wait for a client to initiate communications. | accept() 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 sour ce to which they connect. Again, because of the native code, their portability i s limited. | Type 2 drivers that are pure Java and implement the network protocol for a specific da ta source. The client connects directly to the data source. | Type 4 drivers that use a pure Java client and communicate with a middleware server us ing a database-independent protocol. The middleware server then communicates the client's requests to the data source. | Type 3 drivers that implement the JDBC API as a mapping to another data access API, su ch as ODBC. Drivers of this type are generally dependent on a native library, wh ich limits their portability. | Type 1 26. System.out.println(a.doit(4, 5)); | Line 26 prints a to System.out. Which two are true if a NullPointerException is thrown on line 3 of class C? (Ch oose two.) | b. The code on line 29 will be executed. e. The exception wi ll be propagated back to line 27. dialog prevents user input to other windows in the application unitl the dialog is closed. | Modal A Java monitor must either extend Thread or implement Runnable. | False A monitor called mon has 10 threads in its waiting pool; all these waiting threa ds have the same priority. One of the threads is thr1. How can you notify thr1 s o that it alone moves from the Waiting state to the Ready state? (Choose one.) | You cannot specify which thread will get notified. 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 An object is used to submit a query to a database | Statement An object is uses to obtain a Connection to a Database | Driver Manager Given a string constructed by calling s = new String("xyzzy"), which of the call s modifies the string? (Choose one.) | None of the above Given arrays a1 and a2, which call returns true if a1 and a2 have the same lengt h, and a1[i].equals(a2[i]) for every legal index i? (Choose one.) | java.util.Ar rays.equals(a1, a2);
A programmer wants to create an interface called B that has A as its parent. Whi ch interface declaration is correct? | public interface B extends A { } How can you force garbage collection of an object? (Choose one.) | Garbage colle ction cannot be forced. How do you prevent shared data from being corrupted in a multithreaded environme nt? (Choose one.) | Access the variables only via synchronized methods. How do you use the File class to list the contents of a directory? (Choose one.) | String[] contents = myFile.list(); How many locks does an object have? (Choose one.) | 1 If all three top-level elements occur in a source file, they must appear in whic h order? (Choose one.) | Package declaration, imports, class/interface/enum defi nitions. 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 abb y() method of any other instance of Y. | False If you need a Set implementation that provides value-ordered iteration, which cl ass should you use? (Choose one.) | TreeSet 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 me thod. Interface ... helps manage the connection between a Java program and a databas e. | Connection Is it possible to write code that can execute only if the current thread owns mu ltiple locks? | Yes DBC supports ... and ... models. | Two-tier and three-tier MVC is short call of | Model-View-Controller Select correct statement about RMI. (choose 1) | All the above Select correct statement(s) about remote class.(choose one) | All the others cho ices Select correct statements about remote interface. (choose 1) | All the others ch oices Select INCORRECT statement about serialization. (choose 1) | When an Object Out put Stream serializes an object that contains references to another object, ever y referenced object is not serialized along with the original object. Select INCORRECT statement about deserialize. (choose 1) | We use readObject() m ethod of ObjectOutputStream class to deserialize. Select incorrect statement about RMI server.(choose 1) | A client accesses a rem ote object by specifying only the server name. Select incorrect statement about ServerSocket class. (choose 1) | To make the ne w object available for client connections, call its accept() method, which retur ns an instance of ServerSocket 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. Select the correct statement about JDBC two-tier processing model. | A user's co mmands are delivered to the database or other data source, and the results of th ose statements are sent back to the user. SQL keyword ... is followed by the selection criteria that specify the rows to select in a query | WHERE Statement objects return SQL query results as ... objects | ResultSetSupp ose a source file contains a large number of import statements and one class def inition. How do the imports affect the time required to load the class? (Choose one.) | Class loading takes no additional time. Suppose a source file contains a large number of import statements. How do the i mports affect the time required to compile the source file? (Choose one.) | Comp ilation takes slightly more time. Suppose class A extends Object; Class B extends A; and class C extends B. Of the se, 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 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 prim is an int and wrapped is an Integer. Which of the following are leg al Java statements? (Choose one.) | All the above 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) Suppose the declared type of x is a class, and the declared type of y is an inte rface. When is the assignment x = y; legal? (Choose one.) | When the type of x i s Object 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 Suppose x and y are of type TrafficLightState, which is an enum. What is the bes t way to test whether x and y refer to the same constant? (Choose one.) | if (x == y) Suppose you are writing a class that will provide custom deserialization. The cl ass implements java.io.Serializable (not java.io.Externalizable). What access mo de should the readObject() method have? (Choose one.) | private Suppose you want to create a custom thread class by extending java.lang.Thread i n order to provide some special functionality. Which of the following must you d o? (Choose one.) | Override run(). Suppose you want to write a class that offers static methods to compute hyperbol ic trigonometric functions. You decide to subclass java.lang.Math and provide th e new functionality as a set of static methods. Which one statement is true abou t this strategy? | The strategy fails because you cannot add static methods to a subclass. Swing components cannot be combined with AWT components. | true The ... class is the primary class that has the driver information. | D river Manager The ... class is used to implement a pull-down menu that provides a num ber of items to select from. | Menu The element method alters the contents of a Queue. | False The Swing component classes can be found in the package. | javax.swing There are two classes in Java to enable communication using datagrams namely. | DataPacket and DataSocket URL referring to databases use the form: | protocol:subprotocol:datasoursename What is -50 >> 2 | -13 What is 7 % -4? | 3 What is -8 % 5? | -3 What is the difference between the rules for method-call conversion and the rule s for assignment conversion? (Choose one.) | There is no difference; the rules a re the same. 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 return type of the instanceof operator? | A boolean What method of the java.io.File class can create a file on the hard drive? | cre ateNewFile() When a byte is added to a char, what is the type of the result? | int When a negative byte is cast to a long, what are the possible values of the resu lt? | Negative When a negative long is cast to a byte, what are the possible values of the resu lt? | All the above When a short is added to a float, what is the type of the result? | float When comparing java.io.BufferedWriter to java.io.FileWriter, which capability ex ists as a method in only one of the two? | writing a line separator to the strea m When does an exception's stack trace get recorded in the exception object? | Whe n the exception is constructed 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 write code that constructs and throws an error? | neve r When is x & y an int? | sometimes When the user attempts to close the frame window, ... event in generated. | w indow closing When the user selects a menu item, ... event is generated. | Action event When you compile a program written in the Java programming language, the compile r converts the human-readable source file into platform- independent code that a Java Virtual Machine can understand. What is this platform-independent code cal led? | bytecode Whenever a method does not want to handle exceptions using the try block, the .. . is used. | throws Which class and static method can you use to convert an array to a List? | Array s.asList Which is four-step approach to help you organize your GUI thinking. | Identify n eeded components. Isolate regions of behavior. Sketch the GUI. Choose layout man agers. Which is the four steps are used in working with JDBC? | Connect to the database Create a statement and execute the query Look at the result set Close connectio n Which JDBC processing model that requires a JDBC driver that can communicate wi th the particular data source being accessed? | two-tier Which line of code tells a scanner called sc to use a single digit as a delimite r? | sc.useDelimiter("\\d"); Which Man class properly represents the relationship "Man has the best friend wh o is a Dog"? | class Man { private Dog bestFriend; } Which methods return an enum constant s name? | name() toString() 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 of the following are legal argument types for a switch statement? | byte i nt char Which of the following are legal loop definitions? | None of the above. Which of the following are methods of the java.util.SortedSet interface? | All t he above Which of the following are true? | The JVM runs until there are no non-daemon t hreads. Which of the following are true? | An enum may contain public method definition s. An enum may contain private data. Which of the following are true? | Primitives are passed by value. References a re passed by value. Which of the following are true? | An anonymous inner class may implement at mo st one interface. An anonymous inner class may extend a parent class other than Object. Which of the following are valid arguments to the DataInputStream constructor? | FileInputStream Which of the following are valid mode strings for the RandomAccessFile construct or? | All the above Which of the following calls may be made from a non-static synchronized method? | All the above Which of the following classes implement java.util.List? | java.util.ArrayList java.util.Stack Which of the following classes implements a FIFO Queue? | LinkedList Which of the following expressions results in a positive value in x? | int x = 1; x = x >>> 5; Which of the following interfaces does not allow duplicate objects? | set Which of the following is not appropriate situations for assertions? | Precondit ions of a public method Which of the following is NOTa valid comment: | /* comment Which of the following is the most appropriate way to handle invalid arguments i
n a public method? | Throw java.lang.IllegalArgumentException. Which of the following may appear on the left-hand side of an instance of operat or? | A reference Which of the following may appear on the right-hand side of an instance of opera tor? (Choose two.) | Class interface Which of the following may be declared final? (Choose two.) | Classes Methods Which of the following may be statically imported? (Choose two.) | Static method names Static field names Which of the following may legally appear as the new type (between the parenthes es) in a cast operation? (Choose one.) | All of the others Which of the following may not be synchronized? (Choose one.) | Classes Which of the following methods in the Thread class are deprecated? (Choose one.) | suspend() and resume() Which of the following operations might throw an ArithmeticException? (Choose on e.) | None of these Which of the following operations might throw an ArithmeticException? (Choose on e.) | / Which of the following operators can perform promotion on their operands? (Choos e three.) | + - ~ Which of the following restrictions apply to anonymous inner classes? (Choose on e.) | They must be defined inside a code block. Which of the following should always be caught? (Choose one.) | Checked exceptio ns Which of the following signatures are valid for the main() method entry point of an application? (Choose two.) | public static void main(String[] args) public s tatic void main(String arg[]) 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 wait ing threads. Which of the following statements about threads is true? (Choose one.) | Threads inherit their priority from their parent thread. Which of the following statements are true? (Choose one.) | A final class may no t be extended. Which of the following statements are true? (Choose one.) | Given that Inner is a nonstatic class declared inside a public class Outer and that appropriate cons tructor forms are defined, an instance of Inner can be constructed like this: ne w Outer().new Inner() Which of the following statements is correct? (Choose one.) | Both primitives an d object references can be both converted and cast. Which of the following statements is true? (Choose one.) | Transient variables a re not serialized. Which of the following statements is true? (Choose one.) | Object references can be converted in both method calls and assignments, and the rules governing thes e conversions are identical. Which of the statements below are true? (Choose one.) | Unicode characters are a ll 16 bits. is a set of java API for executing SQL statements | JDBC method is used to wait for a client to initiate communications | accept() drivers that are written partly in the Java programming language and partly in n ative code. These drivers use a native client library specific to the data sourc e to which they connect | Type 2 drivers that are pure Java and implement the network protocol for a specific dat a source. The client connects directly to the data source | Type 4 drivers that use a pure Java client and communicate with a middleware server usi ng a database-independent protocol. The middleware server then communicates the client's requests to the data source | Type 3 drivers that implement the JDBC API as a mapping to another data access API, suc h as ODBC. Drivers of this type are generally dependent on a native library, whi ch limits their portability | Type 1 System.out.println(a.doit(4, 5)) | Line 26 prints a to System.out
Which two are true if a NullPointerException is thrown on line 3 of class C | co de on line 29, The exception What lines are output if the constructor at line 3 throws a MalformedURLExceptio n | Bad URL, Doing finally, Carrying What lines are output if the methods at lines 3 and 5 complete successfully with out throwing any exceptions | Success, Doing, Carrying 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 An exception is thrown at runtime | An exception first second first third snootchy 420 | third second first snootchy 420 dialog prevents user input to other windows in the application unitl the dialog is closed | Modal You would like to write code to read back the data from this file. Which solutio ns will work | 2.FileInputStream, RandomAccessFile A Java monitor must either extend Thread or implement Runnable | F A monitor called mon has 10 threads in its waiting pool; all these waiting threa ds have the same priority. One of the threads is thr1 | You cannot specify A programmer needs to create a logging method that can accept an arbitrary numbe r of arguments. For example, it may be called in these ways | public void logIt( String... msgs) 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 catch (InterruptedException e) | running some time object is used to submit a query to a database | Statement object is uses to obtain a Connection to a Database | DriverManager After execution of the following code fragment, what are the values of the varia bles x, a, and b | x13, a7, b8 Yen and Euro both return correct Country value | 2.Euro returns, error at line 25 BigOlLongStringWithMeaninglessName | tick all Compilation of class A will fail. Compilation of class B will succeed | B fail, A succeed Line 46 will compile if enclosed in a try block, where TestException is caught | 2.if the enclosing, is caught Holder h = new Holder() | 101 Decrementer dec = new Decrementer() | 12.3 Test t = (new Base()).new Test(1) | 2.new Test(1), new Test(1, 2) Base(int j, int k, int l) | 2.Base(), Base(int j, int k) Line 12 will not compile, because no version of crunch() takes a char argument | output: int version output results when the main method of the class Sub is run | Value 5 This value 6 Float floater = new Float(3.14f) | Line 6 The application must be run with the -enableassertions flag or another assertion enabling flag | dai nhat, one or more After line 3 executes, the StringBuffer object is eligible for garbage collectio n | line 2 executes..collection The code will compile but will throw an exception at line 7, because runtime con version from an interface to a class is not permitted | type SwampThing 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 for (int i = 0; i < 2; i++) | 4.i0,j12 - i1,j02 outer: for (int i = 0; i < 2; i++) | i = 1 j = 0 The code will compile but will throw an exception at line 7, because runtime con version from an interface to a class is not permitted | Line 7 will not compile int[] x = new int[25] | 2.x[24]=0, x.length is 25 public float aMethod(float a, float b) throws Exception | int a,b float p,q public float aMethod(float a, float b, int c) throws Exception | 3.int a,b. floa
t a,b-int c. private Given a string constructed by calling s = new String("xyzzy"), which of the call s modifies the string | None of the above Given arrays a1 and a2, which call returns true if a1 and a2 have the same lengt h, and a1[i].equals(a2[i]) for every legal index i | Arrays.equals(a1, a2) Assuming the class does not perform custom serialization, which fields are writt en when an instance of Xyz is serialized | 3.Public, Private, Volatile can legally be placed before aMethod() on line 3 and be placed before aMethod() on line 8 | 3: private; 8: protected NUTMEG, CINNAMON, CORIANDER, ROSEMARY | 3.Spice sp, Spice, String List
names = new ArrayList() | 2.Iterator, for Compilation fails because of an error in line 15 | error in line 19 1 2 3 | 2 3 public interface B inheritsFrom A | B extends A protected double getSalesAmount() { return 1230.45; } | 2.public, protected Line 16 creates a directory named d and a file f within it in the file system | 3.An exception, Line 13, line 14 Nav.Direction d = Nav.Direction.NORTH | Nav.Direction.NORTH new class Foo { public int bar() { return 1; } } | new Foo() IllegalArgumentException | StackOverflowError Circle c = new Circle(); c.Shape.setAnchor(10,10); c.Shape.draw() | Shape s = ne w Circle...s.draw() Compilation fails because of an error in line 12 | 1 2 3 NullPointerException | Compilation fails A NumberFormatException is thrown by the parse method at runtime | Compilation f ails An exception is thrown at runtime | Compilation fails passed An AssertionException is thrown without the word stuff added to the stack t race | An AssertionError...with the collie | collie harrier doStuff x = 6 main x = 6 | doStuff x =5 main x =5 The setCardlnformation method breaks encapsulation | The ownerName The value of all four objects prints in natural order | Compilation fails...line 29 The code on line 33 executes successfully | 3.33 throws, 35 throws, 33 executes What is the result if a NullPointerException occurs on line 34 | ac Compilation will fail because of an error in line 55 | Line 57...value 3 java -ea test file1 file2 | 2.java -ea test, dai nhat String s = 123456789 ; s = (s- 123 ).replace(1,3, 24 ) - 89 | 2.delete(4,6), delete(2,5) rt( 1, 24 ) The Point class cannot be instatiated at line 15 | Line.Point p = new Line.Point () for( int i=0; i< x.length; i++ ) System.out.println(x[i]) | 2.for(int z : x), dai nhat int MY_VALUE = 10 | 3.final, static, public Compilation fails because of an error in line: public void process() throws Runt imeException | A Exception How can you ensure that multithreaded code does not deadlock | There is no singl e How can you force garbage collection of an object | Garbage collection How do you prevent shared data from being corrupted in a multithreaded environme nt | Access the variables How do you use the File class to list the contents of a directory | String[] con tents The number of bytes depends on the underlying system | 8 How many locks does an object have | One If all three top-level elements occur in a source file, they must appear in whic h order | Package declaration, imports the two classes are in different packages, and class X has a protected method ca lled abby(), then any instance of Y may call the abby() method of any | F
TestThread3 ttt = new TestThread3 | Y If you need a Set implementation that provides value-ordered iteration, which cl ass should you use | TreeSet In order for objects in a List to be sorted, those objects must implement which interface and method | Comparable...compareTo 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 what are the possible types for variable result | int, long, float, double helps manage the connection between a Java program and a database | Connection Is it possible to define a class called Thing so that the following method can r eturn true under certain circumstances | Y Is it possible to write code that can execute only if the current thread owns mu ltiple locks | Y JDBC supports ______ and ______ models | Two-tier and three-tier MVC is short call of | Model-View-Controller No output because of compile error at line: System.out.println("b="+b) | b = b * b1 Object ob2= new Object() | Have a nice day Object ob2= ob1 | ob1 equals ob2, ob1==ob2 String s2 = "xyz" | Line 4, Line 6 String s2 = new String("xyz") | Line 6 String s2 = new String(s1) | Line 6 Select correct statement about RMI | All the above Select correct statement(s) about remote class | All the others choices Select correct statements about remote interface | All the others choices Select INCORRECT statement about serialization | When an Object Output Select INCORRECT statement about deserialize | We use readObject Select incorrect statement about RMI server | A client accesses Select incorrect statement about ServerSocket class | To make the new object Select incorrect statement about Socket class | server through UDP Select the correct statement about JDBC two-tier processing model | A user's com mands SQL keyword ___ is followed by the selection criteria that specify the rows to s elect in a query | WHERE Statement objects return SQL query results as | ResultSet When a JDBC connection is created, it is in auto-commit mode | Both 1 and 2 are true Suppose a method called finallyTest() consists of a try block, followed by a cat ch block, followed by a finally block | If the JVM doesn't crash 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 Suppose a source file contains a large number of import statements. How do the i mports affect the time required to compile the source file | slightly more time Suppose class A extends Object; Class B extends A; and class C extends B. Of the se, only class C implements java.io.Externalizable | C must have a Suppose class A extends Object; class B extends A; and class C extends B. Of the se, only class C implements java.io.Serializable | B must have a Suppose class A has a method called doSomething(), with default access. Suppose class B extends A and overrides doSomething() | private Suppose class Supe, in package packagea, has a method called doSomething(). Supp ose class Subby, in package packageb, overrides doSomething() | 2.public, protec ted void doSomething(int a, float b) | public...(int a, float b) Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five inte rface methods | 2.declared abstract, may not be Suppose prim is an int and wrapped is an Integer. Which of the following are leg al Java statements | All the above 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 the declared type of x is a class, and the declared type of y is an inte rface. When is the assignment x = y; legal | When the...x is Object 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 x and y are of type TrafficLightState, which is an enum. What is the bes t way to test whether x and y refer to the same constant | if (x == y) Suppose you are writing a class that will provide custom deserialization. What a ccess mode should the readObject() method have | private Suppose you are writing a class that will provide custom serialization. What acc ess mode should the writeObject() method have | private Suppose you want to create a custom thread class by extending java.lang.Thread i n order to provide some special functionality | Override run() Suppose you want to write a class that offers static methods to compute hyperbol ic trigonometric functions. You decide to subclass java.lang.Math and provide th e new functionality as a set of static methods | subclass java.lang.Math Swing components cannot be combined with AWT components | T class is the primary class that has the driver information | DriverManager class is used to implement a pull-down menu that provides a number of items to s elect from | Menu The element method alters the contents of a Queue | F The Swing component classes can be found in the | javax.swing There are two classes in Java to enable communication using datagrams namely | D ataPacket and DataSocket Compilation of Parrot.java fails at line 7 because method getRefCount() is stati c in the superclass, and static methods may not be overridden to be nonstatic | dai nhat: nonstatic 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 void doSomething() throws IOException, EOFException | ngan-dai nhat, throws EOFE xception URL referring to databases use the form | protocol:subprotocol:datasoursename What are the legal types for whatsMyType | There are no possible legal types What does the following code do | Throws an exception There is no output because the code throws an exception at line 1 | output is i = 20 1000 | -1 What happens when you try to compile and run the following application | thrown at line 9 The code compiles, and prints out >>null<< | out >>null<< An exception is thrown at line 6 | thrown at line 7 What is -50 >> 2 | -13 What is 7 % -4 | 3 What is -8 % 5 | -3 What is the difference between the rules for method-call conversion and the rule s for assignment conversion | There is no difference The code will compile as is. No modification is needed | On line 1, remove What is the range of values that can be assigned to a variable of type byte | ?2 mu7 through 2mu7 ? 1 What is the range of values that can be assigned to a variable of type short | ? 2mu15 through The code compiles and executes; afterward, the current working directory contain s a file called datafile | The code fails to compile What is the return type of the instanceof operator | A boolean What method of the java.io.File class can create a file on the hard drive | crea teNewFile() The output: value is 99.99 | value is 9.0 The output: b contains 250 | b contains 5
What would be the output from this code fragment | message four When a byte is added to a char, what is the type of the result | int When a negative byte is cast to a long, what are the possible values of the resu lt | Negative When a negative long is cast to a byte, what are the possible values of the resu lt | All the above When a short is added to a float, what is the type of the result | float When comparing java.io.BufferedWriter to java.io.FileWriter, which capability ex ists as a method in only one of the two | writing a line When does an exception's stack trace get recorded in the exception object | is c onstructed When is it appropriate to pass a cause to an exception's constructor | in respon se to catching When is it appropriate to write code that constructs and throws an error | Never When is x & y an int | Sometimes When the user attempts to close the frame window, _______ event in generated | w indow closing When the user selects a menu item, _______ event is generated | Action event Java programming language, the compiler converts the human-readable source file into platform-independent code that a Java Virtual Machine can understand | byte code Whenever a method does not want to handle exceptions using the try block, the | throws Which are the correct statements used for getting connection object to connect t o SQL Server database | String url =jdbc:odbc Which class and static method can you use to convert an array to a List | Arrays .asList Which is four-step approach to help you organize your GUI thinking | Identify, I solate, Sketch Which is the four steps are used in working with JDBC | Connect, Create, Look Which JDBC processing model that requires a JDBC driver that can communicate wi th the particular data source being accessed | two-tier Which line of code tells a scanner called sc to use a single digit as a delimite r | sc.useDelimiter("\\d") Man has the best friend who is a Dog | private Dog bestFriend Which methods return an enum constant s name | 2.name(), toString() 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 of the following are legal argument types for a switch statement | 3.byte, int, char Which of the following are legal enums | 3.ngan-dai nhat, lion int weight Which of the following are legal import statements | 2.import...Vector, Vector.* Which of the following are legal loop constructions | for (int k=0, j+k != 10; j ++,k++) Which of the following are legal loop definitions | None of the above double d = 1.2d5 | 2.double d = 1.2d, 1.2D int d = 0XABCD | 2.int c = 0xabcd, dai nhat char c = 0x1234 | 2.0x.., '\u1234' Vector theVec = new Vector() | 2.List...(), dai nhat Which of the following are methods of the java.util.SortedMap interface | headMa p, tailMap, subMap Which of the following are methods of the java.util.SortedSet interface | All th e above System.out has a println() method | All the above The JVM runs until there is only one non-daemon thread | are no non-daemon When an application begins running, there is one non-daemon thread, whose job is to execute main() | 3.nhat, thread, non-daemon thread When you declare a block of code inside a method to be synchronized, you can spe cify the object on whose lock the block should synchronize | 2.the method always , nhat
An enum definition should declare that it extends java.lang.Enum | 2.contain pub lic, private Primitives are passed by reference | 2.by value An anonymous inner class that implements several interfaces may extend a parent class other than Object | implement at most, class may extend Which of the following are valid arguments to the DataInputStream constructor | FileInputStream Which of the following are valid mode strings for the RandomAccessFile construct or | All the above Which of the following calls may be made from a non-static synchronized method | All the above Which of the following classes implement java.util.List | 2.ArrayList, Stack Which of the following classes implements a FIFO Queue | LinkedList Which of the following declarations are illegal | 3.ngan-dai nhat, double d int x = 6; if (!(x > 3)) | 2.dai nhat, x = ~x String x = "Hello"; int y = 9; if (x == y) | 2.ngan nhat, x=x+y Which of the following expressions results in a positive value in x | int x = 1; x = x >>> 5 Which of the following interfaces does not allow duplicate objects | Set Which of the following is not appropriate situations for assertions | Preconditi ons of a public method Which of the following is NOTa valid comment | /* comment Which of the following is the most appropriate way to handle invalid arguments i n a public method | IllegalArgumentException Readers have methods that can read and return floats and doubles | None of the a bove An enum definition may contain the main() method of an application | All the abo ve Which of the following may appear on the left-hand side of an instanceof operato r | A reference Which of the following may appear on the right-hand side of an instanceof operat or | 2.A class, An interface Which of the following may be declared final | 2.Classes, Methods Which of the following may be statically imported | 2.Static method, Static fiel d Which of the following may follow the static keyword | 3.Data, Methods, Code blo cks Which of the following may legally appear as the new type (between the parenthes es) in a cast operation | All of Which of the following may not be synchronized | Classes Which of the following may override a method whose signature is void xyz(float f ) | 2.void, public void xyz(float f) Which of the following methods in the Thread class are deprecated | suspend() an d resume() Which of the following operations might throw an ArithmeticException | None of Which of the following operators can perform promotion on their operands | 3.con g, tru, xap xi Which of the following restrictions apply to anonymous inner classes | must be d efined Which of the following should always be caught | Checked exceptions Which of the following signatures are valid for the main() method entry point of an application | 2.static void...(String arg[]) Which of the following statements about the wait() and notify() methods is true | calls wait() goes into Which of the following statements about threads is true | Threads inherit their A final class may not contain non-final data fields | may not be extended An abstract class must declare that it implements an interface | None An abstract class may not have any final methods | Only statement 2 Only object references are converted automatically; to change the type of a prim itive, you have to do a cast | Both primitives
Transient methods may not be overridden | variables are not Object references can be converted in both method calls and assignments, but the rules governing these conversions are very different | conversions are identica l Bytecode characters are all 16 bits | Unicode characters To change the current working directory, call the changeWorkingDirectory() metho d of the File class | None When you construct an instance of File, if you do not use the file-naming semant ics of the local machine, the constructor will throw an IOException | None When the application is run, thread hp1 will execute to completion, thread hp2 w ill execute to completion, then thread hp3 will execute to completion | None of Compilation succeeds, although the import on line 1 is not necessary. During exe cution, an exception is thrown at line 3 | fails at line 2 Compilation fails at line 1 because the String constructor must be called explic itly | succeeds. No exception Line 4 executes and line 6 does not | Line 6 executes There will be a compiler error, because class Greebo does not correctly implemen t the Runnable interface | Runnable interface The acceptable types for the variable j, as the argument to the switch() constru ct, could be any of byte, short, int, or long | value is three The returned value varies depending on the argument | returns 0 Lines 5 and 12 will not compile because the method names and return types are mi ssing | output x = 3 Line 13 will not compile because it is a static reference to a private variable | output is x = 104 Which statements about JDBC are NOT true | 2.database system, DBMS Which two code fragments correctly create and initialize a static array of int elements | 2.a = { 100,200 }, static Which two of the following interfaces are at the top of the hierarchies in the J ava Collections Framework | 2.Map, Collection A new directory called dirname and a new file called filename are created, both in the current working directory | No directory protected class Cat extends Owner | public class Cat extends Pet Date vaccinationDue | 2.boolean, String What is -15 % -10 | -5 command line on a Windows system | 2.must contain the statement, the file The string created on line 2 does not become eligible for garbage collection in this code | After line 3 When the application runs, what are the values of n and w.x after the call to bu mp() in the main | n is 10, w.x is 11 The addAll() method of that interface takes a single argument, which is a ref erence to a collection whose elements are compatible with E. What is the declar ation of the addAll() method | addAll(Collection extends E> c) 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 er ror When should objects stored in a Set implement the java.util.Comparable interfac e | Set is a TreeSet What relationship does the extends keyword represent | is a class bbb.Bbb, which extends aaa.AAA, wants to override callMe(). Which access m odes for callMe() in aaa.AAA will allow this | 2.public, protected Lemon lem = new Lemon(); Citrus cit = new Citrus() | 3.cit = lem, cit=(Citrus), lem=(lemon) it also has a method called chopWoodAndCarryWater(), which just calls the other two methods | inappropriate cohesion, inappropriate coupling sharedOb.wait() | 2.aThread.interrupt, sharedOb.notifyAll 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) \\d+ What code at line 3 produces the following output | String delim =
How do you generate a string representing the value of a float f in a format a ppropriate for a locale loc | NumberFormat.getInstance(loc) you want to use a DateFormat to format an instance of Date. What factors influ ence the string returned by DateFormat s format() method | 2.LONG, or FULL, The lo cale 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 you are writing a class that will provide custom deserialization. The class impl ements java.io.Serializable (not java.io.Externalizable) | private What interfaces can be implemented in order to create a class that can be serial ized | 2.dai nhat, ngan nhat The file contains lines of 8-bit text, and the 8-bit encoding represents the lo cal character set, as represented by the cur- rent default locale. The lines are separated by newline characters | FileReader instance shorty is a short and wrapped is a Short | all How is IllegalArgumentException used | 2.certain methods, public methods While testing some code that you are developing, you notice that an ArrayIndexO utOf- BoundsException is thrown. What is the appropriate reaction | None Which lines check that x is equal to four? Assume assertions are enabled at com pile time and runtime | 2.assert x == 4 int[] ages = { 9, 41, 49 }; int sum = 0 | 2.i
Which of the following may not be synchronized | Classes statements about the wait() and notify() methods is true | pool of waiting th reads methods in the Thread class are deprecated | suspend() and resume() A Java monitor must either extend Thread or implement Runnable | F 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 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 Which methods return an enum constant s name | name(), toString() restrictions apply to anonymous inner classes | inside a code block 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 d escription of its markings | boolean, string Which of the following are valid declarations? Assume java.util | 1Vector 2Set 3 Map string,string You can determine all the keys in a Map in which of the following ways | Set ob ject from the Map What keyword is used to prevent an object from being serialized | transient abstract class can contain methods with declared bodies. | E. public, protecte d, default, private access modifier allows you to access method calls in libraries not created in J ava | native Which of the following statements are true? (Select all that apply.) | object c annot reassigned The keyword extends refers to what type of relationship | is a keywords is used to invoke a method in the parent class | super What is the value of x after the following operation is performed | 3 method call is used to tell a thread that it has the opportunity | notify() Assertions are used to enforce all but which | Exceptions force garbage collection by calling System.gc(). | B. False Select the valid primitive data type | 1.boolean 2.char 3.float How many bits does a float contain | 32 What is the value of x after the following line is executed | 32 StringBuffer is slower than a StringBuilder, but a StringBuffer | True list of primitives ordered in smallest to largest bit size representation | D. char, int, float, long Which class provides locale-sensitive text formatting for date and time informat ion | java.text.DateFormat int x = 9; byte b = x | False Which of the following code snippets compile | 1.Integer 2.Integer 3.byte Java arrays always start at index 1 | False accurately describes how variables are passed to methods | that are primitive t ype are passed by value change the value that is encapsulated by a wrapper class after you have instan | None of the above. The class implements java.io.Serializable (and not java.io.Externalizable) | pri vate readObject A signed data type has an equal number of non-zero positive and negative value s | False signatures are valid for the main() method entry point of an application | publi c static void main(String[] args) three top-level elements occur in a source file, they must appear | Package decl aration, imports, class/interface/enum definitions int[] x = new int[25] | x[24] is 0 and x.length is 25 How can you force garbage collection of an object | Garbage collection cannot be forced. range of values that can be assigned to a variable of type short | -215 through 215 - 1 range of values that can be assigned to a variable of type byte | -27 through 2
7 - 1 How do the imports affect the time required to compile the source file | Compi lation takes slightly more time How do the imports affect the time required to load the class? | Class loading takes no additional time legal import statements | 1.import java.util.Vector 2.import static java.ut il.Vector may be statically imported | 1.Static method names 2.Static field names int c = 0xabcd and int d = 0XABCD | 2 dap an double d = 1.2d and double d = 1.2D | 2 dap an char c = \u1234 | 1 dap an passed by value and passed by value | 2 dap an int x = 6; if (!(x > 3)) and int x = 6; x = ~x | 2 dap an int x = 1; x = x >>> 5 | 1 dap an int y = 9; x += y; and int y = 9; x = x + y; | 2 dap an What is -8 % 5 | -3 What is 7 % -4? | 3 ob1 == ob2 | No When a byte is added to a char | int When a short is added to a float | float ArithmeticException | 1.None of these 2./ What is the return type of the instanceof operator | boolean may appear on the left-hand side of an instanceof operator | reference may appear on the right-hand side of an instanceof operator | class and interfa ce What is -50 >> 1 | -25 default String s ,, abstract double d ,, double hyperbolic | 3 dap an A final class may not have any abstract methods | true denote a variable that should not be written out as part of its class s persistent state | transient Both primitives and object references can be both converted and cast | dap an and the rules governing these conversions are identical | dap an may legally appear as the new type (between the parentheses) in a cast operati on | All of the above type of x is a class, and the declared type of y is an interface. When is the as signment x = y | When the type of x is Object xarr is an array of XXX, and the type of yarr is an array of YYY | Sometimes When is x & y an int | Sometimes negative long is cast to a byte | All of the above negative byte is cast to a long | Negative operators can perform promotion on their operands | + - ~(nga) difference between the rules for method-call conversion and the rules for assign ment conversion | There is no difference Which of the following are appropriate situations for assertions | DAP AN SAI : Preconditions of a public method appropriate way to handle invalid arguments in a public method | IllegalArgumen tException Suppose salaries is an array containing floats | for (float f:salaries) Suppose a method called finallyTest() consists of a try block | If the JVM does n t crash and appropriate to pass a cause to an exception s constructor | thrown in response to catching of a different exception type Which of the following should always be caught | Checked exceptions When does an exception s stack trace get recorded in the exception object | is c onstructed A dialog prevents user input to other windows in the application umtl the dialog is closed | Modal public float aMethod(float x. float y) {} | 1 Runtime Exception | 1 What is the output of the following code class Main { static intk- 10; static {k
?- 5;} public static void main(Strmg argsQ){ System outpnntln(k).}static {k 5;} } | 20 Assuming any exception handling has been set up. which of the following will cre ate an instance of the RandomAccessFile class? | RandomAccessFile raf-new Random AccessFilefmyfile txr."rW) How do you prevent shared data from being corrupted in a | Access the variables only via synchronized mothods Compile time error | 1 A thread's run() method includes the following lines 1 try{ 2 sleep(IOO);3.} c atch (InterruptedException e) {} | At line 2. the thread will stop running It wi ll resume running some time after 100 milliseconds have elapsed When a user selects a menu,______is generated | Action event When you compile a program written in the Java programming language, the compile r converts the human-readable source file into platform-independent code that a Java Virtual Machine can understand What is this platform-independent code calle d? | bytecode Which of the following operators can perform promotion on their operands? (Selec t two) | + Select INCORRECT statement about FlowLayout | The Flow layout manager always hon ors a component's preferred size D The Flow layout manager arranges components i n horizontal rows Which line contains only legal statements? | int x=6 x = ~x Which Man class properly represents the relationship 'Man has the best friend wh o is a Dog'? | class Man {private BestFnend dog;} 99 100 102 | 1 Select the most correct statement | A thread is in the ready state after it has been created and started Which of the following statements) is(are) true? 1)An abstract class can not hav e any final methods 2)A final class may not have any abstract methods | Both sta tement 1 and 2 What is the return type of the instanceof operator? | boolean Study the statements: 1) When a JDBC connection is created, it is in auto -commit mode 2) 0nce auto-commit mode is disabled, no SQL statements will be com mitted until you call the method commit explicitly | both 1 and 2 are true the code on line 29 will be executed | 1 No such file found. Doing finally.-1 | 1 Which of the following is true about Wrapped classes? | Wrapper classes are. Boo lean. Char. Byte. Short. Integer. Long. Float and Double Which of the followings statements is true? | The GndBagLayout manager is the de fault manager for JFrame What is the range of values that can be assigned to a variable of type short? | 2 mu 15 through 2 mu 15 -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 Which of the statements below is true"? | When you construct an instance of File , the file will not be created even if the corresponding file does not exist on the local file system Which of the following may follow the static keyword9 (Select two) | Methods and Code blocks endosed in curly brackets Which of the following statements is true | Constructors are not inherited public interface B inheritsFrom A {} | 1 Which of the following statements is true | A for statement can loop infinitely, for example for(;;); Select INCORRECT statement about deserialize (choose 1) | We use readObjectO met hod of ObjectOutputStream dass to deserialize a#b, a==c | 1 Is it possible to define a dass called Thing so that the following method can re turn true under certain drcumstances? boolean weirdfThing s) {Integer x = new ln teger(5); return s.equals(x);} | yes A(n)_____object is uses to obtain a Connection to a Database | DnverManager
Study the following Java statements:String sl= Hetlo ;String s2= Hello";String s3= He llo";String s4= new Stnng( Hello");How many strings, specified by the above code, are stored in the memory of the program | 2 What is the difference between a TextArea and a TextField | A TextArea can handl e multiple lines of text You have been given a design document for a veterinary registration system for i mplementation in Java. It states"A pet has an owner, a registration date, and a vacdnation-due date A cat is a pet that has a flag indicating whether it has bee n neutered, and a textual description of its markings"Given that the Pet class h as already been defined, which of the following fields would be appropriate for inclusion in the Cat class as members9 (Select the most appropriate two declarat ions) | String markings boolean neutered; A___dialog prevents user input to other windows in the application unitl the dia log is closed.|Modal. A value variable contains data's value.|True. A reference variable contains the address of data.|True. The Reader/Writer class hierarchy is character-oriented, and the InputStream/Out putStream class hierarchy is byte-oriented.|True. String s = new String("Bicycle"); int iBegin = 1; char iEnd = 3; System.out.prin tln(s.substring(iBegin, iEnd));|Bic. Which of the following layout manager will present components with the same size .|java.awt.GridLayout. Object references can be converted in both method calls and assignments, and the rules goverming these conversions are identical.|True. The Reader/Writer class hierarchy is character-oriented, and the InputStream/Out putStream class hierarchy is byte-oriented.|True. String s = new String("Bicycle"); int iBegin = 1; char iEnd = 3; System.out.prin tln(s.substring(iBegin, iEnd));|Bic. Which of the following layout manager will present components with the same size .|java.awt.GridLayout. Object references can be converted in both method calls and assignments, and the rules goverming these conversions are identical.|True. Which is four-step approach to help you organize your GUI thinking.|Identifi-Iso late-Sketch-Choose. Which statement is true about BorderLayout?.|...and the center of a container. A program can suggest that garbage collection be performed but not force it.|Tru e. An object's lock is a mechanism that is used by multilple threads to obtain sync hronized access to the object.|True. Which statements about JDBC are NOT true?.|database system - any kind of DBMS. Which of the following statements is true about two base protocols used for netw orking TCP(Transmission Control Protocol) and UDP(User Datagram Protocol)?|TCP i s a connection-based protocol and UDP is not connection-based protocol. Which of the following is not a keyword or a reserved word in Java?.|Then. MVC is short call of|Model-View-Controller. How can you ensure that multithreaded code does not deadlock?|There is no single technique that can guarantee non-deadlocking code. If you need a Set implementation that provides value-ordered iteration, which ca lss should you use?|TreeSet. When is a thread in suspended state?|When wait() method is called. Which of the following declarations is legal?|transient int i = 41; Unicode characters are all 16 bits.|True. Which of the following statements can be used to call a constructor of the super class from its sub-class?|super(); Which of the following protocols is a connection-based protocol that provides a reliable flow of data between two computers?|Transmission Control Protocol. Which of the following statements about monitor is true?|A monitor is an instanc e of any class that has synchronized code. Interfaces cannnot have constructors|True.
__Drivers that use a pure Java client and communicate with a middleware server u sing a database-independent protocol The middleware server then communicates the client's requests to the data source.|Type 3. The default type of the ResultSet object is __|TYPE_FORWARD_ONLY. Suppose the declared type of x is a class, and the declared type of y is an inte rface. When is the assignment x = y; legal?|When the type of x is Object. A method in an interface can access class level variables|Incorrect. double d = 1.2d;|legal. How do you prevent shared data from being corrupted in a multilthreaded environm ent?| Access the variables only via synchronized methods. The Swing's list component(JList) can display text only.|Correct. The Swing's label(JLabel) can present an image.|Correct. Which of the following operations might throw an ArithmeticException?.|%. Under no circumstances can a class be defined with the private modifier.|True. Adding more classes via import statements will cause a performance overhead, onl y import classes you actually use.|True. Suppose class X contains the following method:|Public void doSomething(int a, fl oat b){...}. A protected method may only be accessed by classes of the same package or by sub classes of the class in which it is declared.|Correct. Vector does not allow duplicate elements.|Incorrect. Which of the following is a valid argument to the DataInputStream constructor?|F ileInputStream. The___class is the primary class that has the driver information.|DriverManager. Consider the following code developed in NetBeans.What does the thread t do?|The program cause errors when it is compiled. What is 7%-4?|3. A signed data type has an equal number of non-zero positive and negative values available.|False. Both primitives and object references can be both converted and cast.|Correct. Which of the following statements is true about two base protocols used for netw orking :TCP(Transmission Control Protocol) and UDP(User Datagram Protocol)?|TCP is a connection-base protocol and UDP is not connection-based protocol. To check whether the file denoted by the abstract pathname is a driectory or not call the isDirectory() method of the File class.|True. Which of the following methods of the Collections class can be used to find the largest value in a Vector?.|We don't need any method because elements in Vector are automatically sorted. Therefore, the first element contains the maximum valu e. Select the correct statement which set the layout manager of a given frame to Fl owLayoutManager.|setLayout(new FlowLayout()); 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.sal aries); String x = "Hello"; int y = 9; x=x+y;|Legal. Whenever a method does not want to handle exceptions using the try block.the___i s used.|throws. You cannot call an enum's toString() method.|True. Which is the four steps are used in working with JDBC?|Connect-Create-Look-Close . Which of the following methods of the java.io.File can be used to create a new f ile?|createNewFile(). Give a string constructed by calling s = new String("xyzzy").which of the calls modifies the string?|None of the others. Which of the following statements is INCORRECT about a non-static synchronized m ethod?|It cannot call to a static synchronized method of the current class. How can you force garbage collection of an object?|Garbage collection cannot be forced. char c = \u1234;|Incorrect. In RMI implementations, all methods, declared in the remote interface, must thro
w the __exception.|java.rmi.RemoteException. What method of the java.io.File class can create a file on the hard drive?|creat eNewFile(). BorderLayout is the default layout manager for every JFrame.|True. 1.A_dialog prevents user input to other windows in the application until the dia log is closed|Model 2.how do you prevent shared data from being corrupted in a multithreaded environ ment?|Access the variable only via synchronized methods 3.When a user selects a menu item,_is generated.|Action event 4.When you compile a program written in the Java programming language,the compil er converts the human-readble soure file into platfom- independent code that a J ava Virtual Machine can understand|bytecode 5.Which of the following operators can perform promotion on their operands?(sele ct two)|+6.Which line contains only legal statements?|int x=6;x=~x 7.Which Man class properly represents the relationship "Man has the bestfriend w ho is a Dog"?|class Man{private BestFriend dog;} 8.A thread is in the ready state after is has been created and started|most corr ect 9.Which of the following statement(s) is(are) true?1) An abstract class can not have any fianl methods.2)A final class may not have any abstract methods.|Only s tatement2 10.Which is the return type of the instance of operator?|A boolean 11.Study the statements: 1) When a JDBC connection is created,it is auto-commit mode.2) Once auto-commit mode is disabled, no SQL statements will be committed u ntil you call the method commit explicity| Both 1 and 2 are not true 12.Which of the following is true about Wrapped classes?|Wrapper class are :Bool ean,Char,Byte,Short,Interger,long,Float and Double 13.The GridBagLayout manager is the default manager for JFrame|true 14.What is the range of values that can be assigned to a variable of type short? |-2^15 throught 2^15-1 15.When is it appropriate to pass a cause to an exception's constructor?|...in r esponse to catching of a different exception type 16. When you construct an instance of File,the file will not be created even if the corresponding file does not exist on the local file system|true 17.Which of the following may follow the static keyword?(select two)|Methods and Non-inner class definitions 18.Constructors are not inherited|true 19.A for statement can loop infinitely, for example:for(;;)|true 20.We use readoject() method of ObjectOutputStream class to deserialize|INCORREC T 21.A(n)_ object is used to obtain a Connection to a Database|DriverManager 22.What is the difference between a TextArea and a TextField?|A TextArea can han dle multiple lines of text 23.A pet has an owner, a registration date;and a vaccination-duw date.Given that the Pet class has already been defined|String markings and boolean neutered Which of the following are valid declarations? Assume java.util.* is imported.|V ector