Mock 5 - Web viewPlease select a true statement about delete() method of java.io.File. A. It can...

21

Click here to load reader

Transcript of Mock 5 - Web viewPlease select a true statement about delete() method of java.io.File. A. It can...

Page 1: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

Mock 5

1. Please select signed integralsA. char, byte, and shortB. byte, short, int, and longC. char, short, and long2. Java characters are ...A. ASCII codeB. Binary codeC. UnicodeD. ANSI code3. Please select the size of an int typeA. 32 bytesB. 16 bitsC. 32 bitsD. 16 bytes4. Select default value of boolean typeA. trueB. falseC. 0D. 15. Consider the following line of code:char x[]=new char[10];After execution, what is value of x[0]?A. 0B. '\u0000'C. null6. A package statement MUST exist in all classesA. TrueB. False7. Please choose invalid identifiersA. tempB. BIGintC. 25_lengthD. !length8. Please select floating point typesA. byteB. intC. doubleD. shortE. longF. float

c,f

8. All operands are evaluated left to right

Java Mock 5 Confidential Page 1 of 18http://www.integratedsolutions.co.in/

Page 2: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

A. trueB. false

true

9. Consider the following line of code:byte x=64;byte y=5;byte z= (byte)(x*y);After execution what is value of z?A. 320B. 0C. 645

D. 64

D. Comment: A byte value can represent a range of -128 to+127. Arithmeticallyanswer is 320, but when you store this result to a byte variable youwill get a value 64since result is out of the range (-128 to +127).

10. Consider the following line of code:int x=7;int y=4;int z=7/4;After execution what is value of z?A. 1.75B. 0C. 1

D. 2

C

11. Please select the true statement for ! operatorA. The ! operator inverts the value of a boolean expressionB. The ! operator inverts the bit pattern of an integral expression.

Java Mock 5 Confidential Page 2 of 18http://www.integratedsolutions.co.in/

Page 3: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

C. Both A and BD. None of the above

A

12. Please select arithmetic operations which can result in AirthmeticExceptionA. Multiplication: *B. Division: /C. Modulo: %D. Addition: +E. Subtraction: -

B and C

13. Please select operators which perform bit shifts of the binary representation ofthe integral typesA. <<B. >>C. >>>D. ~E. &F. ^G. |

A, B, and C

14. A protected method may be overridden by ...A. A private methodB. A protected methodC. A public method

D. All of the above

Java Mock 5 Confidential Page 3 of 18http://www.integratedsolutions.co.in/

Page 4: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

B and C

15. A public method may not be overridden by ...A. A private methodB. A protected methodC. A public method

D. All of the above

A and B

16. The private modifier can be applied to ...A. A variableB. A methodC. A top level class

D. All of the above

A and B

17. The abstract modifier can NOT be applied to ...A. A variableB. A methodC. A class

D. A constructor

A and D18. A class variable is declared using following modifiersA. protectedB. privateC. publicD. static

Java Mock 5 Confidential Page 4 of 18http://www.integratedsolutions.co.in/

Page 5: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

D

19. An unary operator operates on a single valueA. TrueB. False

A. Comment: + and - operator can take two values

20. The following types of loop are guaranteed to be executed at least onceA. The do loopB. The while loopC. The for loop

D. All of the above

A

21. The switch() construct is used to make a choice based upon ...A. A char valueB. An int valueC. A String value

D. None of the above

A and B

22. The circumstances that can prevent execution of the code in a finally block areA. The death of the threadB. The use of System.exit()

C. It is always guaranteed to be executed.

A and B

Java Mock 5 Confidential Page 5 of 18http://www.integratedsolutions.co.in/

Page 6: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

23. Select correct statement(s)A. The continue statement abandons the loop altogetherB. The break statement causes the current iteration of the loop to be abandoned.C. The break statement abandons the loop altogether

C

24. How can you declare a overloaded method?A. Reusing the method name with different arguments and same return typeB. Reusing the method name with different arguments and different return typeC. Reusing the name with identical arguments and return type

D. None of the above

A and B

25. How can you declare a overriding method?A. Using the same method name with identical arguments and return typeB. Using the same method name with identical arguments and different return typeC. Using the same method name with different arguments and same return type

D. All of the above

A

26. When a default constructor is provided by the compiler?A. If you define no constructor at all in a classB. When you define at least one constructorC. It is always provided whether you define a constructor or notD. It is never provided

A

27. A static inner class can access ...A. instance variables of the enclosing class

Java Mock 5 Confidential Page 6 of 18http://www.integratedsolutions.co.in/

Page 7: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

B. static variables of the enclosing classC. Both A and B

D. None of the above

B

28. An inner class created inside a method can accessA. Any local variables of a method that contain an inner class.B. Any instance variables of the enclosing classC. Any final variables of the enclosing class or a method that contain an inner class.

D. None of the above

C

29. Please select true statement(s) for an anonymous inner classA. An anonymous class can not extend to a superclassB. An anonymous class can not implement an interfaceC. An anonymous class can extend to a supperclass and implement an interface both.

D. An anonymous class can extend to a supperclass or implement an interface

D

30. Please select true statement(s) for a member inner classA. An inner class in class scope can have any accessibility of the top level class,including private.B. An Inner class defined local to a block may be staticC. An anonymous inner class can not declare a constructor.D. An inner class can not have same name as enclosing class.E. All of the above

A , C, and D

Java Mock 5 Confidential Page 7 of 18http://www.integratedsolutions.co.in/

Page 8: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

31. Please select invalid statement(s) for a threadA. You can restart a dead threadB. You can't call the methods of a dead threadC. Both of the above

D. None of the above

C

32. Select correct statements for a java.lang.StringA. Strings are sequences of 16 bit Unicode characters.B. Strings are immutable.C. Both of the above

D. None of the above

C

33. Select correct statements for == operator.A. It compare object reference of two objectsB. It compare the value of two objectsC. Both of the above

D. None of the above

A

34. Please select collection(s) that do not reject duplicatesA. java.util.ListB. java.util.SetC. java.util.Map

D. All of the above

A

35. Please select a default layout manager of the java.awt.PanelA. java.awt.FlowLayout with left justifiedB. java.awt.FlowLayout with center justified

Java Mock 5 Confidential Page 8 of 18http://www.integratedsolutions.co.in/

Page 9: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

C. java.awt.FlowLayout with right justifiedD. None of the above36. Please select a default layout manager for the java.awt.FrameA. java.awt.FlowLayoutB. java.awt.BorderLayoutC. java.awt.GridBagLayoutD. None of the above37. Please select true statement for prefix operator(++x/--x).A. The prefix operator(++x/--x) evaluates the value of the operand afterincrement/decrement operation.B. The prefix operator(++x/--x) evaluates the value of the operand beforeincrement/decrement operation.C. Both A and B

D. None of the above

A

38. Please select true statement(s) for shift operators.A. >>> operator always produces a positive number.B. >> always produces a positive number for a positive number.C. >> always produces a negative number for a negative number.

D. None of the above

B,C

39. Please select true statement(s) for shift operators.A. Shifting is not allowed in long integral typeB. Shifting is not allowed in float integral typeC. Shifting is not allowed in double integral type

D. Shifting is not allowed in int integral type.

B and C

40. Please identify correct assignment for boolean type.A. boolean javaExam=true;B. boolean javaExam=True;

Java Mock 5 Confidential Page 9 of 18http://www.integratedsolutions.co.in/

Page 10: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

C. boolean javaExam=1;D. All of the above

A

41. Bitwise operator can be applied to ...A. Integral typesB. Float typesC. Both of the above

D. None of the above

A

42. instanceof operator can be used with ...A. interfacesB. ArraysC. Classes

D. All of the above

D

43. Please select true statement(s)A. The equals method compares content of two objectsB. The == operator tests reference of two objectsC. The equals method compares reference of two objects.

D. The == operator compares content of two objects

A and B

44. Please identify invalid use of comparison operator for the following code:String s=new String("S");String t=new String("T");int x=83;int y=84;A. s == t

Java Mock 5 Confidential Page 10 of 18http://www.integratedsolutions.co.in/

Page 11: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

B. x!=yC. x==s

D. s!=t

C

45. Please select true statement(s) for instanceof operator:A. The instanceof operator can be applied to object referenceB. The instanceof operator can be applied to an array.C. Both of the above

D. None of the above

C

46. please select true statement(s) for static modifier.A. A static method can access non-static variables of the class.B. A static method can call non-static methods.C. A static method can be overridden by non-static method.

D. None of the above

D47. Please, select true statement(s) for thread.A. Invoking a constructor of a Thread registers the thread with thread scheduler.B. Calling a start() method of thread registers the thread with thread scheduler.C. Calling a run() method of thread registers the thread with thread scheduler.

D. All of the above.

B

48. Invoking yield() on a running thread cause following effect(s):A. A running thread will be placed in suspended state.B. A running thread will be placed in sleeping state.C. A running thread will be placed in ready state.

D. Neither of the above.

C

Java Mock 5 Confidential Page 11 of 18http://www.integratedsolutions.co.in/

Page 12: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

49. The default priority of the thread isA. 0B. 1C. 5

D. 10

C

50. Which of the following methods are NOT static of Thread class?A. start()B. sleep(long l)C. run()

D. yield()

A and C

51. Select true statement(s) about an inner class declared inside a method, alsoknown as local inner classA. The local inner class can access any local variables declared in the method and theparameters passed to the method.B. The local inner class can access only public variables declared in enclosing classC. The local inner class can access public, private, and protected variables declared inenclosing class.

D. The local inner class can access only final declared variables in the method.

C AND D

52. How can you prevent class JavaExam from being extended?A. declare class static JavaExamB. declare class synchronized JavaExamC. declare class final JavaExam

Java Mock 5 Confidential Page 12 of 18http://www.integratedsolutions.co.in/

Page 13: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

D. None of the above

C

54. Assume that following methods are declared in one class.1. public void addElement(Object javaExam)2. public void addElement( Object [] javaExam)

3. public Object addElement ( int index, Object javaExam)Please select true statement(s) for above methods.. All methods are example of overloading methodA. All methods are example of overriding methodB. Method # 1 and method # 2 are example of overloading method, whereasmethod # 3 is an example of overriding method.

C. None of the above

A55. When can't you override a method?A when method is declared abstractB. When method is declared finalC. when method is declared privateD. when method is declared static

B

56. Please select invalid declaration of the top level class. public abstract final class JavaExamA. public final class JavaExam implement RunnableB. protected static class JavaExam

C. public class JavaExam extend Thread

A, B, C, and D

57. Please select invalid types for a switch construct. floatA. longB. String

Java Mock 5 Confidential Page 13 of 18http://www.integratedsolutions.co.in/

Page 14: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

C. All of the above

D

58. Please select invalid java keywords. includeA. ifdefB. sizeof

C. goto

A, B, and C

59. Which of the following statements are NOT true about Java garbage collectionThread?. The garbage collection thread has a low priorityA. The garbage collection thread can be invoked at any timeB. A call to System.gc() is guaranteed to invoke garbage collection threadimmediatelyC. A call to Runtime.getRuntime().gc() is guaranteed to invoke garbage collectionthread immediately

B, C, and D

60. An inner class can not declare______ variables.. staticA. protectedB. final

C. transient

A

Java Mock 5 Confidential Page 14 of 18http://www.integratedsolutions.co.in/

Page 15: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

61. Which of the following types can be added to java.util.Vector?. referenceA. nullB. int

C. All of the above

A and B

62. Please select a true statement about delete() method of java.io.File.A. It can delete a fileB. It can delete an empty directoryC. Both of the above

D. Neither of the above

C

63. The continue statement causes the current iteration of the loop to be skippedand the next iteration starts.. TrueA. False

True

64. The return type of constructor is void.. TrueA. False

False

65. 'null' is valid java type.. TrueA. False

66. Invoking a constructor of java.io.File class creates a file on the file system.. TrueA. False

67. Select true statement(s) about native modifier.native modifier can be applied to a class

Java Mock 5 Confidential Page 15 of 18http://www.integratedsolutions.co.in/

Page 16: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

A. native modifier can be applied to a methodB. native modifier can be applied to an instance variable

C. native variable can be applied to a class variable

68. What method(s) needed to be declared by a class implementing Runnableinterface?public void start()A. public void run()B. public boolean start()

C. public boolean run()

69. The priority of a newly created thread is always Thread.NORM_PRIORITY.A. TrueB. False

B Comment: A newly created thread inherits the priority of theThread that creates it.

70. What methods are declared in java.lang.Thread class?public static void sleep(long millis, int nanos)A. public static native void sleep(long millis, int nanos)B. public static native void sleep(long millis)

C. public static void sleep(long millis)

71. A yield method of the Thread class suspends the operation of the currentthread.TrueA. False

72. What methods are NOT synchronized in java.util.Vector class?size()A. add(int index, Object element)B. capacity()

C. get(int index)

73. Please select unchecked exception(s)?java.lang.NullPointerExceptionA. java.lang.ClassNotFoundExceptionB. java.lang.ClassCastException

C. java.awt.AWTException

74. Which of the following declarations are valid to throw an exception?throw new java.lang.Exception();A. throws new java.lang.Exception();

Java Mock 5 Confidential Page 16 of 18http://www.integratedsolutions.co.in/

Page 17: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

B. Both of the aboveC. None of the above

75. Which of the following classes are immutable?java.lang.StringA. java.lang.StringBufferB. java.util.Vector

C. java.lang.Integer

76. Which of the following classes store and retrieve values based on a key?java.util.HashtableA. java.util.VectorB. java.util.LinkedList

C. java.util.HashMap

77. Which of the following classes can store null value for a key?java.util.HashtableA. java.util.HashMapB. java.util.Properties

C. All of the above

78. java.util.Vector uses synchronized methods to store and retrieve values.TrueA. False79. java.util.Hashtable uses synchronized methods to store and retrieve values.TrueA. False80. java.util.HashMap uses synchronized methods to store and retrieve values.TrueA. False81. Which of the following collections maintain object references in the order theywere added?java.util.VectorA. java.util.HashtableB. java.util.HashMapC. java.util.ArrayList82. java.util.hashtable implements which of the following interfaces?java.util.DictionaryA. java.util.MapB. java.util.HashMapC. java.util.Hashmap

Java Mock 5 Confidential Page 17 of 18http://www.integratedsolutions.co.in/

Page 18: Mock 5 -    Web viewPlease select a true statement about delete() method of java.io.File. A. It can delete a file. B. It can delete an empty directory. C. Both of the above

Java Mock 5 Confidential Page 18 of 18http://www.integratedsolutions.co.in/