Pregunta 1
Pregunta
1. What will be the output of the program?<br>
Respuesta
-
o Pine
-
o Oak
-
o Tree
-
o Forest
-
o Oops
Pregunta 2
Pregunta
2. Select how you would run your program to cause it to print: Arg is 2 <br>
Respuesta
-
o java Myfile 2 2 2
-
o java Myfile 1 2 2 3 4
-
o java Myfile 1 3 2 2
-
o java MyFile 1 2 2 2
-
o java Myfile 0 1 2 3
Pregunta 3
Pregunta
3. [html]What does the following code do? <br>void blur(char[] z, String st) {<br> if(z.length < st.length()) retrun; <br> for(int i = 0; i < st.length(); i++) <br> z[i] = st.charAt(i); <br>}
Respuesta
-
o It determines if the array contains the same characters as the String
-
o It copies characters from the array to the String
-
o It copies characters from the String to the array;
-
o It creates a new array that contains the same characters as the String
Pregunta 4
Pregunta
4. Given the declaration of an array : int[] a = {1,2,3,4,5}; What is the value of a[4]?
Pregunta 5
Pregunta
5. An array holds:
Respuesta
-
o Similar values of same data type
-
o Different values of same data type
-
o Same values of different data types
-
o Different values of different data types
Pregunta 6
Pregunta
6. [html]Java uses call by value. What is the value that is being passed into the routine by the method call in the following? <br> double rats[] = {1.2 , 2.3, 3.4}; <br> routine(rats);
Respuesta
-
o A copy of the array rats
-
o The value of the elements of rats
-
o A reference of the array
-
o 1.2
-
o 2.3
Pregunta 7
Pregunta
7. What is the prototype of the default constructor?<br>
Respuesta
-
o Test()
-
o Test
-
o public Test()
-
o public Test(void)
-
o Test(void)
Pregunta 8
Pregunta
8. What is the widest valid returnType for methodA in line 3?<br>
Respuesta
-
o int
-
o long
-
o byte
-
o double
-
o void
Pregunta 9
Pregunta
9. You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?
Respuesta
-
o java.util.Map
-
o java.util.Set
-
o java.util.Tree
-
o java.util.List
-
o java.util.Collection
Pregunta 10
Pregunta
10. You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?
Respuesta
-
o public
-
o private
-
o protected
-
o transient
-
o volatile
Pregunta 11
Pregunta
11. Let’s assume that you have class C and interface I ? Which of the following is correct statement?
Pregunta 12
Pregunta
12. Which is valid in a class that extends class A?<br>
Respuesta
-
o public int method1(int a, int b) {return 0; }
-
o private int method1(int a, int b) {return 0; }
-
o protected static int method1(int a, int b) {return 0; }
-
o public long method1(int a, int b) {return 0; }
-
o public static int method1(int a, int b) {return 0; }
Pregunta 13
Pregunta
13. Which statement is true?
Respuesta
-
o catch(X x) can catch subclasses of X where X is a subclass of Exception.
-
o The Error class is a RuntimeException.
-
o Any statement that can throw an Error must be enclosed in a try block
-
o Any statement that can throw an Exception must be enclosed in a try block
Pregunta 14
Pregunta
14. What will be the output of the program?<br>
Respuesta
-
o one two three four
-
o one two three four one
-
o four three two one
-
o four one three two
Pregunta 15
Pregunta
15. Given a method in a class, what access modifier do you use to restrict access to that method to only the other members of the same class?
Respuesta
-
o final
-
o public
-
o private
-
o protected
-
o static
-
o volatile
Pregunta 16
Pregunta
16. [html] Which three statements are true? <br> 1. The default constructor initialises method variables.<br> 2. The default constructor has the same access as its class.<br> 3. The default constructor invokes the no-arg constructor of the superclass.<br> 4. If a class lacks a no-arg constructor, the compiler always creates a default constructor. <br> 5. The compiler creates a default constructor only when there are no other constructors for the class.
Respuesta
-
o 1,2,4
-
o 2,3,5
-
o 3,4,5
-
o 1,2,3
-
o 1,3,5
Pregunta 17
Pregunta
17. What will be the output of the program?<br>
Respuesta
-
o AC
-
o ACD
-
o BD
-
o ABCD
-
o ABD
Pregunta 18
Pregunta
18. What will be the output of the program after the running program in such way :/> java Test red green blue?<br>
Respuesta
-
o baz =
-
o baz = blue
-
o baz = null
-
o Runtime Exception
-
o Compilation Error
Pregunta 19
Pregunta
19. Which is a valid declaration within an interface?
Respuesta
-
o public static final short stop = 23;
-
o protected short stop = 23;
-
o transient short stop = 23;
-
o final void madness(short stop);
-
o void madness(short stop) = 0;
Pregunta 20
Pregunta
20. Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
Respuesta
-
o java.util.HashSet
-
o java.util.LinkedList
-
o java.util.ArrayList
-
o java.util.List
-
o java.util.TreeSet
Pregunta 21
Pregunta
21. Which interface provides the capability to store objects using a key-value pair?
Respuesta
-
o java.util.Map
-
o java.util.Set
-
o java.util.List
-
o java.util.Collection
-
o java.util.ArrayList
Pregunta 22
Pregunta
22. [html]Which of the following statements about the hashcode() method are incorrect? <br> 1.The value returned by hashcode() is used in some collection classes to help locate objects <br> 2. The hashcode() method is required to return a positive int value <br> 3. The hashcode() method in the String class is the one inherited from Object <br> 4. Two new empty String objects will produce identical hashcodes
Respuesta
-
o 1 and 2
-
o 2 and 3
-
o 3 and 4
-
o 1 and 4
-
o 2 and 4
Pregunta 23
Pregunta
23. Which class or interface defines the wait(), notify(),and notifyAll() methods?
Respuesta
-
o Object
-
o Thread
-
o Runnable
-
o Class
Pregunta 24
Pregunta
24. What will be the output of the program? <br>
Respuesta
-
o It will print the numbers from 0 to 19 sequentially
-
o It will print the numbers from 1 to 20 sequentially
-
o It will print the numbers from 0 to 19 but the order is not determined
-
o It will print the numbers from 1 to 20 but the order is not determined
-
o It will print the numbers from 0 to 9 two times, but the order is not determined
Pregunta 25
Pregunta
25. [html]Which two can be used to create a new Thread? <br> 1. Extend java.lang.Thread and override the run() method <br> 2. Extend java.lang.Runnable and override the start() method <br> 3. Implement java.lang.Thread and implement the run() method <br> 4. Implement java.lang.Runnable and implement the run() method <br> 5. Implement java.lang.Thread and implement the start() method
Respuesta
-
o 1 and 2
-
o 2 and 3
-
o 3 and 4
-
o 4 and 5
-
o 1 and 4
-
o 2 and 5
Pregunta 26
Pregunta
26. The following block of code creates a Thread using a Runnable target: <br>
br> Which of the following classes can be used to create the target, so that the preceding code compiles correctly?
Respuesta
-
o public class MyRunnable extends Runnable{public void run(){}}
-
o public class MyRunnable extends Object{public void run(){}}
-
o public class MyRunnable implements Runnable{public void run(){}}
-
o public class MyRunnable implements Runnable{void run(){}}
-
o public class MyRunnable implements Thread{void run(){}}
Pregunta 27
Pregunta
27. What will be the output of the program?<br>
Respuesta
-
o AB
-
o BC
-
o BCD
-
o ABC
-
o ACD
Pregunta 28
Pregunta
28. Which interface does the java.util.Hashtable implement?
Respuesta
-
o java.util.Map
-
o java.util.Set
-
o java.util.Collection
-
o java.util.List
-
o java.util.HashTable
Pregunta 29
Pregunta
29. Which of these will create and start this thread? <br>
Respuesta
-
o new Runnable(MyRunnable).start();
-
o new Thread(MyRunnable).run();
-
o new Thread(new MyRunnable()).start();
-
o new MyRunnable().start();
-
o new Runnable(MyRunnable).run();
Pregunta 30
Pregunta
30. The number of characters in an object of a class String is given by
Respuesta
-
o The member variable called size
-
o The member variable called length
-
o The method size() returns the number of characters
-
o The method length() returns the number of characters
Pregunta 31
Pregunta
31. Which of the following statements is correct?
Respuesta
-
o An import statement, if defined, must be the non-comment statement of the file
-
o Private members are accessible to all classes in the same package
-
o An abstract class can be declared as final
-
o Local variables cannot be declared as static
Pregunta 32
Pregunta
32. Which code determines the int value data closer to, but not greater than, a double value b?
Respuesta
-
o int data = (int)Math.ceil(b)
-
o int data = (int)Math.floor(b)
-
o int data = (int)Math.abs(b)
-
o int data = (int)Math.min(b)
Pregunta 33
Pregunta
33. Which statement is true for the Class java.util.HashSet?
Respuesta
-
o The elements in the collection are unique
-
o The elements in the collection are ordered
-
o The elements in the collection are synchronized
-
o The collection is guaranteed to be immutable
Pregunta 34
Pregunta
34. [html]What will be the output of the program? <i><br>class Exc0 extends Exception{} <br> class Exc1 extends Exc0 {} // Line 2 <br> public class Test { <br> public static void main(String args[]) { <br> try { <br> throw new Exc1(); //Line 9 <br> } catch (Exc0 e0) { <br> System.out.println(“Ex0 caught”); <br>} catch(Exception e) { <br> System.out.println(“Exception caught”);<br>}<br>}<br>}
Pregunta 35
Pregunta
35. Which of the following is not a part of OOP?
Respuesta
-
o Type checking
-
o Multitasking
-
o Polymorphism
-
o Information hiding
Pregunta 36
Pregunta
36. Static methods cannot be accessed directly from the class level
Pregunta 37
Pregunta
37. The process by which one object can acquire the properties of another object
Respuesta
-
o Encapsulation
-
o Inheritance
-
o Polymorphism
Pregunta 38
Pregunta
38. Constructors are used to
Pregunta 39
Pregunta
39. What happens in a method if an exception is thrown in a try{} block and there is NO MATCHING catch{} block?
Respuesta
-
o This is not legal, so the program will not compile
-
o The method throws the exception to its caller, exactly if there were no try{} block
-
o The program halts immediately
-
o The program ignores the exception
Pregunta 40
Pregunta
40. Is a program required to catch all exceptions that might happen?
Respuesta
-
o No. You can write a program to catch just the exceptions you want
-
o No. But if a program catches one type of exception it must catch all other types as well
-
o Yes. If a program is not written to catch all exceptions it will not compile
-
o Yes. A program can not do I/O unless it catches all exceptions
Pregunta 41
Pregunta
41. What method of an Exception object returns a message string?
Respuesta
-
o getError()
-
o getMessage()
-
o printMessage()
-
o traceMessage()
Pregunta 42
Pregunta
42. What happens during execution if a negative value is used for an array index?
Respuesta
-
o An IndexOutOfBoundsException is thrown
-
o A NumberFormatException is thrown
-
o The first slot of the array is used
-
o This is an Error, so the program immediately terminates no matter what
Pregunta 43
Pregunta
43. What method of an Exception object prints a list of methods that were called before the exception was throw?
Respuesta
-
o printErrors()
-
o getMessage()
-
o traceStack()
-
o printStackTrace()
Pregunta 44
Pregunta
44. A single sequence of code executing within a program is known as:
Respuesta
-
o A method
-
o A process
-
o A thread
Pregunta 45
Pregunta
45. To start the execution of a thread after you create it, you must:
Respuesta
-
o Call the method run()
-
o Call the method start()
-
o Do nothing, threads start automatically upon creation
-
o Call the method notify()
Pregunta 46
Pregunta
46. You designate a method as being synchronized by:
Respuesta
-
o Using the keyword synchronized
-
o Naming the method synchronize
-
o Placing a synchronized section of code within it
Pregunta 47
Pregunta
47. What method is declared in the Runnable interface and serves as the path of execution for all threads?
Pregunta 48
Pregunta
48. What is a buffer?
Respuesta
-
o A section of memory used as a staging area for input or output data
-
o The cable that connects a data source to the bus
-
o Any stream that deals with character IO
-
o A file that contains binary data
Pregunta 49
Pregunta
49. What happens if a FileWriter constructor is given an illegal file name?
Respuesta
-
o The program bombs immediately
-
o The users disk is corrupted
-
o The constructor returns a null value
-
o An IOExcpetion is thrown
Pregunta 50
Pregunta
50. When a file is opened for appending where does the write() put new text?
Respuesta
-
o At the beginning of the file
-
o At the end of the file
-
o Where ever the user specifies
-
o Files cannot be appended to
Pregunta 51
Pregunta
51. A null reference may be used to access a static variable or method
Pregunta 52
Pregunta
52. Set allows at most two null elements?
Pregunta 53
Pregunta
53. Which collection class allows you to access its elements by associating sorted element and provides an order?
Respuesta
-
o java.util.TreeSet
-
o java.util.HashSet
-
o java.util.TreeMap
-
o java.util.Hashtable
Pregunta 54
Pregunta
54. A class cannot define more than one constructor
Pregunta 55
Pregunta
55. If you were to store objects into an implementation of List which happens only once in the entire lifecycle of the product,but reading these objects inside the List implementation is quite high, then which one would you use?
Respuesta
-
o Queue
-
o Stack
-
o ArrayList
-
o LinkedList
Pregunta 56
Pregunta
56. In java one class can derive from one class?
Pregunta 57
Pregunta
57. Which of the following is not true for abstract classes?
Respuesta
-
o Abstract class cannot to be instantiated
-
o Abstract class handlers can be used to handle derived class objects
-
o We can’t have an abstract class without abstract methods
-
o Abstract class has member elements
Pregunta 58
Pregunta
58. Which of the following is not true for static keyword?
Respuesta
-
o Static members are shared by all objects of the class
-
o We can override static methods
-
o Static methods operate only on static variables only
-
o Static elements are accessed using class name
Pregunta 59
Pregunta
59. List is a/an …?
Respuesta
-
o Class
-
o Interface
-
o Both
-
o Package
Pregunta 60
Pregunta
60. Which exception is thrown by the read () method of InputStream class?
Respuesta
-
o IOException
-
o FileNotFoundException
-
o ReadException
-
o AccessDeniedException
Pregunta 61
Pregunta
61. Which is the Java keyword used to denote a class method?
Respuesta
-
o class
-
o final
-
o private
-
o static
Pregunta 62
Pregunta
62. What is Recursion in Java?
Respuesta
-
o Recursion is a class
-
o Recursion is a process of defining a method that calls other methods repeatedly
-
o Recursion is a process of defining a method that calls itself repeatedly
-
o Recursion is a process of defining a method that calls other methods which in turn call again this method
Pregunta 63
Pregunta
63. Which of these data types is used by operating system to manage the Recursion in Java?
Respuesta
-
o Array
-
o Stack
-
o Queue
-
o Tree
-
o Map
Pregunta 64
Pregunta
64. What will be an output? <br>
Pregunta 65
Pregunta
65. What will be an output? <br>
Respuesta
-
o 24
-
o 30
-
o 120
-
o 720
-
o Compilation Error
-
o Runtime Error
Pregunta 66
Pregunta
66. What will be an output? <br>
Respuesta
-
o 1
-
o 0
-
o 5
-
o 15
-
o Compilation Error
-
o Runtime Error
Pregunta 67
Pregunta
67. What will be an output? <br>
Respuesta
-
o 1
-
o 0
-
o 12
-
o 78
-
o Compilation error
-
o Runtime error
Pregunta 68
Pregunta
68. Deletion is faster in LinkedList than ArrayList
Pregunta 69
Pregunta
69. Can a top level class be private?
Pregunta 70
Pregunta
70. Which of the following is not a primitive data type?
Respuesta
-
o Double
-
o int
-
o char
-
o boolean
-
o No right answer
Pregunta 71
Pregunta
71. The term wrapper class refers to
Respuesta
-
o A collection of java classes that used to make an object from primitive data types
-
o The java classes that contain at least two data fields
-
o The java classes that contain a reference to themselves
-
o A collection of java classes that contain other java classes
Pregunta 72
Pregunta
72. What will be the output of the program? <br>
Respuesta
-
o Got the exception 10
-
o Got the exception e
-
o Compilation error
-
o Runtime error
Pregunta 73
Pregunta
73. What will be the output of the program? <br>
Pregunta 74
Pregunta
74. What will be the output of the program? <br>
Pregunta 75
Pregunta
75. What will be the output of the program? <br>
Respuesta
-
o Caught base class exception
-
o Caught derived class exception
-
o Caught base class exception <br> Caught derived class exception
-
o Compilation error because derived is not throwable
-
o Compilation error because base class exception is caught before derived class
Pregunta 76
Pregunta
76. What will be the output of the program? <br>
Pregunta 77
Pregunta
77. What will be the output of the program?<br>
Pregunta 78
Pregunta
78. Which of the following is not true about interfaces in java?
Respuesta
-
o An interface is similar to a class, but can contain following type of members. <br> public, static, final fields(i.e., constants) <br> default and static methods with bodies
-
o An instance of interface can be created
-
o A class can implement multiple interfaces
-
o Many classes can implement the same interface
Pregunta 79
Pregunta
79. Which of the following is not true about inheritance in java?
Respuesta
-
o Private methods are final
-
o Protected members are accessible within a package and inherited classes outside the package
-
o Protected methods are final
-
o We cannot override private methods
Pregunta 80
Pregunta
80. Which of the following is true about inheritance in Java. <br>1) In Java all classes inherit from the Object class directly or indirectly. The Object class is root of all classes.<br> 2) Multiple inheritance is not allowed in Java.<br>3) Inheritance is a part of polymorphism
Respuesta
-
o 1,2 and 3
-
o 1 and 2
-
o 1 and 3
-
o 2 and 3
-
o Only 1
-
o Only 2
-
o Only 3
Pregunta 81
Pregunta
81. What will be the output of the program? <br>
Respuesta
-
o Derived::show() called
-
o Base::show() called
-
o Compilation error
-
o Runtime error
Pregunta 82
Pregunta
82. What will be the output of the program? <br>
Respuesta
-
o Derived::show() called
-
o Base::show() called
-
o Compilation error
-
o Runtime error
Pregunta 83
Pregunta
83. What will be the output of the program? <br>
Respuesta
-
o Base
-
o Derived
-
o Compilation error
-
o Runtime error
Pregunta 84
Pregunta
84. What will be the output of the program? <br>
Respuesta
-
o Compilation error in super.super.Print()
-
o Grandparent’s print <br> Child’s Print()
-
o Grandparent’s print <br> Parent’s Print <br> Child’s Print()
-
o Runtime error
Pregunta 85
Pregunta
85. What will be the output of the program? <br>
Pregunta 86
Pregunta
86. What will be the output of the program? <br>
Respuesta
-
o 20
-
o 0
-
o Compilation error
-
o Runtime error
Pregunta 87
Pregunta
87. What will be the output of the program? <br>
Respuesta
-
o s1 == s2 is: true
-
o s1 == s2 is: false
-
o true
-
o false
-
o compilation error
-
o runtime exception
Pregunta 88
Pregunta
88. Which of the following is used by byte streams for input?
Respuesta
-
o InputStream
-
o InputOutputStream
-
o BufferedReader
-
o Scanner
-
o System.in
Pregunta 89
Pregunta
89. Which of these classes are used by character streams output operations?
Respuesta
-
o InputStream
-
o ReadStream
-
o Writer
-
o OutputStream
Pregunta 90
Pregunta
90. Which of the following is not a wrapper class?
Respuesta
-
o Byte
-
o String
-
o Integer
-
o Character
-
o Double
-
o Long
Pregunta 91
Pregunta
91. What restriction is there on using a super reference in a constructor?
Respuesta
-
o Only one child class can use it
-
o It can only be used in parent class
-
o It must be used in the first statement of the constructor of subclass
-
o It must be used in the last statement of the constructor of subclass
-
o No right answer
Pregunta 92
Pregunta
92. A method that is used to assign values to the instance variables of the class is called a
Respuesta
-
o set method
-
o get method
-
o accessor
-
o constructor
-
o toString() method
Pregunta 93
Pregunta
93. Which of the following is not a keyword for an exception handling?
Respuesta
-
o try
-
o catch
-
o throw
-
o thrown
-
o finally
Pregunta 94
Pregunta
94. Which of the following keywords is used to handle the exception by try block?
Respuesta
-
o try
-
o finally
-
o catch
-
o throw
-
o throws
Pregunta 95
Pregunta
95. Which of these operator is used to generate an instance of an exception than can be thrown by using throw?
Respuesta
-
o new
-
o malloc
-
o alloc
-
o thrown
-
o return
Pregunta 96
Pregunta
96. Which of the followings is a type of stream in java?
Respuesta
-
o Integer stream
-
o Byte stream
-
o Short stream
-
o Long stream
Pregunta 97
Pregunta
97. What will be the output of the following program? <br>
Respuesta
-
o BD
-
o ABDE
-
o BCDE
-
o BCD
-
o BDE
-
o ABCE
-
o ABCD
-
o ABD
Pregunta 98
Pregunta
98. What will be the output of the following code? <br>
Pregunta 99
Pregunta
99. What will be the output of the program? <br>
Pregunta 100
Pregunta
100. What will be the output of the program? <br>
Respuesta
-
o ABCD
-
o ACD
-
o ABD
-
o BCD
-
o BC
-
o BD
-
o CD
Pregunta 101
Pregunta
101. What will be the output of the program? <br>
Respuesta
-
o Hello world
-
o Hello world Finally executing
-
o Finally executing
-
o Nothing. The program will not compile because no exceptions are specified
-
o Nothing. The program will not compile because no catch clauses are specified
Pregunta 102
Pregunta
102. What will be the output of the program? <br>
Respuesta
-
o Ex0 caught
-
o Exception caught
-
o Compilation fails on line 2
-
o Compilation fails on line 9
-
o Compilation fails on line 11
Pregunta 103
Pregunta
103. Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
Pregunta 104
Pregunta
104. You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?
Respuesta
-
o java.util.Map
-
o java.util.List
-
o java.util.Set
-
o java.util.Collection
Pregunta 105
Pregunta
105. Which interface does java.util.Hashtable implement?
Respuesta
-
o java.util.Map
-
o java.util.List
-
o java.util.HashTable
-
o java.util.Set
-
o java.util.Collection
Pregunta 106
Pregunta
106. Which interface provides the capability to store objects using a key-value pair?
Respuesta
-
o java.util.Map
-
o java.util.List
-
o java.util.HashTable
-
o java.util.Set
-
o java.util.Collection
Pregunta 107
Pregunta
107. What line of code should replace the missing statement to make this program compile? <br>
Pregunta 108
Pregunta
108. What is the numerical range of char?
Respuesta
-
o 0 .. 32767
-
o 0 .. 65535
-
o -256 .. 255
-
o 0 .. 255
-
o -32768 .. 32767
-
o 0 .. 511
Pregunta 109
Pregunta
109. In Java, defining more than one method having the same name within a particular class is called
Respuesta
-
o overloading
-
o sharing
-
o overriding
-
o superseding
Pregunta 110
Pregunta
110. What is an inheritance?
Respuesta
-
o It is the process where one object acquires the properties of another
-
o Inheritance is the ability of an object to take on many forms
-
o Inheritance is a technique to define different methods of same types
-
o None of the above.
Pregunta 111
Pregunta
111. When constructor is called?
Respuesta
-
o Constructor is called before creating the object
-
o Constructor is called after creating the object
-
o Constructor is called concurrently when object creation is going on
-
o Constructor cannot be called
Pregunta 112
Pregunta
112. What is the difference between a try-catch block and a try-catch-finally block?
Respuesta
-
o try-catch contains code to execute whether an occurs or not, try-catch-finally contains code to execute only if an error occurs
-
o try-catch contains code to execute if an error occurs or not, while try-catch-finally works the same way as try-catch block with the addition of a set of code that will execute whether an error occurs or not
-
o Same thing, different names
-
o try-catch contains code to execute only if an error occurs, try-catch-finally contains code to execute whether an occurs or not
Pregunta 113
Pregunta
113. Which keyword would you use if you wanted a class to use an interface?
Respuesta
-
o implements
-
o extends
-
o throws
-
o new
-
o main()
Pregunta 114
Pregunta
114. Which keyword would you use to break out of a loop?
Respuesta
-
o break
-
o continue
-
o while
-
o for
-
o do
Pregunta 115
Pregunta
115. What will be the output of this code? <br><html> <i>String a = “Crayons are great!”; <br> System.out.println(a.charAt(8));</i></html>
Pregunta 116
Pregunta
116. Which package is imported by default into Java programs?
Respuesta
-
o java.awt
-
o java.awt.font
-
o java.lang
-
o java.io
-
o java.util
Pregunta 117
Pregunta
What is the purpose of a class constructor?
Respuesta
-
o To make objects initially have certain values when they are instantiated
-
o To extend a class
-
o To pass values to methods for a class
-
o To instantiate an object
Pregunta 118
Pregunta
117. What will be the output of the program?<br>
Pregunta 119
Pregunta
118. Given : <br> <b>-A and E are classes <br>-B and D are interfaces<br>-C is an abstract class <br></b> Which is true?
Pregunta 120
Pregunta
119. Given <br> <br> <b> Note: The keyword "instanceof" is use to check whether an object is of a particular type</b><br>What is the result?
Respuesta
-
o Compilation fails due to error at line 3
-
o Will produce output as false
-
o Compilation fails due to error at line 4
-
o Length of this array is 3
-
o Will produce output a true
Pregunta 121
Pregunta
120. What will be the output? <br>
Pregunta 122
Pregunta
121. What will be the output? <br>
Respuesta
-
o Caught base class exception
-
o Caught derived class exception
-
o Compiler error because derived is not throwable
-
o Compiler error because base class exception is caught before derived class
Pregunta 123
Pregunta
122. A java array that contains N components will be indexed from ….. through …..
Respuesta
-
o 0, N – 1
-
o 1, N
-
o 0, N
-
o 1, N - 1
Pregunta 124
Pregunta
123. Which method must exist, to make your class executable?
Respuesta
-
o main
-
o begin
-
o init
-
o int
-
o paint
Pregunta 125
Pregunta
124. What will be output produced after the execution of the following code segment? <br>String name = “Elvis”; <br> System.out.println(name + “was here”);
Respuesta
-
o Elviswas here
-
o Elvis was here
-
o namewas here
-
o name was here
-
o name + was here
Pregunta 126
Pregunta
125. What will be output produced after the execution of the following code segment? <br>int x = 5; <br> int y = 2; <br> System.out.println(x + “1“ + y);
Pregunta 127
Pregunta
126. What will be output produced after the execution of the following code segment? <br>int x = 5; <br> int y = 2; <br> System.out.println(x + y + “1“);
Pregunta 128
Pregunta
127. What will be the result of the following code segment? <br>
Respuesta
-
o 2 4 6 8
-
o 2 4 6 8 10
-
o 2 4 6 8 10 1 3 5 7 9
-
o 1 3 5 7 9
-
o 9 7 5 3 1 10 8 6 4 2
Pregunta 129
Pregunta
128. What is the output of the following code segment?
Pregunta 130
Pregunta
129. If you want to execute body at least once, what type of loop would you use?
Respuesta
-
o for loop
-
o while loop
-
o none of the given
-
o do .. while loop
Pregunta 131
Pregunta
130. What are the values of I and product after this code is executed? <br>
Respuesta
-
o 9 and 366
-
o 9 and 336
-
o 8 and 42
-
o 8 and 336
Pregunta 132
Pregunta
131. What is the output of the following code fragment? <br>
Pregunta 133
Pregunta
132. What is the purpose of the semicolon mark (;) in a Java program?
Respuesta
-
o Designates a temporary separation when used in a package statement.
-
o It is used once and only once in a program
-
o Designates the end of a statement or unit of Java code.
-
o It is used only with JApplet class.
-
o It is an optional end-of-file marker
Pregunta 134
Pregunta
133. What is the size of short variable?
Respuesta
-
o 8 bit
-
o 16 bit
-
o 32 bit
-
o 64 bit
Pregunta 135
Pregunta
134. Which of the following is true about public access modifier?
Respuesta
-
o Variables, methods and constructors which are declared public can be accessed by any class.
-
o Variables, methods and constructors which are declared public can be accessed by any class lying in same package
-
o Variables, methods and constructors which are declared public in the superclass can be accessed only by its child class
-
o No right answer
Pregunta 136
Pregunta
135. Which of the following is not a keyword in Java?
Respuesta
-
o static
-
o void
-
o Boolean
-
o private
Pregunta 137
Pregunta
136. Which of the following stands true about default modifier of class members?
Respuesta
-
o By default, variables, methods and constructors can be accessed by subclass only.
-
o By default, variables, methods and constructors can be accessed by any class lying in any package.
-
o By default, variables, methods and constructors can be accessed by any class lying in the same package.
-
o No right answer
Pregunta 138
Pregunta
137. Inheritance represents
Respuesta
-
o HAS-A relationship
-
o IS-A relationship
Pregunta 139
Pregunta
138. What is function overloading?
Respuesta
-
o Methods with same name but different parameters.
-
o Methods with same name but different return types
-
o Methods with same name, same parameter types but different parameter names.
-
o No right answer
Pregunta 140
Pregunta
139. What is a class in java?
Respuesta
-
o A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object
-
o class is a special data type
-
o class is used to allocate memory to a data type.
-
o No right answer
Pregunta 141
Pregunta
140. Can be constructor be made private?
Pregunta 142
Pregunta
141. What is JRE?
Respuesta
-
o JRE is a java based GUI application.
-
o JRE is an application development framework
-
o JRE is an implementation of the Java Virtual Machine which executes Java programs
-
o No right answer
Pregunta 143
Pregunta
142. What is essential in making sure that your loop is not infinite?
Respuesta
-
o That your Boolean statement at some point will be false
-
o That your Boolean statement at some point will be true
-
o That there is a Boolean statement somewhere in your code
-
o All answers are right
Pregunta 144
Pregunta
143. In a “for” loop, what section is not included in parentheses after “for”?
Respuesta
-
o Initialization
-
o Loop body
-
o Test statement
-
o Update
Pregunta 145
Pregunta
144. Abstract method can be in
Respuesta
-
o abstract class
-
o normal class
-
o concrete class
-
o any class
Pregunta 146
Pregunta
145. One or more function that has different number of arguments or different type of arguments but all have the same return type is called as
Respuesta
-
o Method overriding
-
o Method overloading
-
o Inheritance
-
o Encapsulation
Pregunta 147
Pregunta
146. Static variables cannot be accessed directly from the class level
Pregunta 148
Pregunta
147. When a class is based on another class, it inherits:
Respuesta
-
o The data and methods for the class
-
o The methods and messages for the class
-
o Only the data for the class
-
o Static block of that class
Pregunta 149
Pregunta
148. When sub class declares a method that has the same type arguments as a method in the parent class, it is termed as
Respuesta
-
o Method overriding
-
o Method overloading
-
o Operator overloading
-
o Operator overriding
Pregunta 150
Pregunta
149. Constructors are used to
Pregunta 151
Pregunta
150. What is a template, or specification, that determines a type of object in java?
Respuesta
-
o A class
-
o A template
-
o A struct
-
o A prototype
-
o A framework
Pregunta 152
Pregunta
151. The process by which one object can acquire the properties of another object?
Respuesta
-
o Encapsulation
-
o Inheritance
-
o Polymorphism
-
o Aggregation
Pregunta 153
Pregunta
152. What is the highest index value is associated with the array that follows? <br> <i> byte[] values = new byte[x]; </i>
Pregunta 154
Pregunta
153. which of the following statements gets the number of integers in the array that follows? <br> <i> int[] customers = new int[55];</i>
Respuesta
-
o int size = customers.length();
-
o int size = customers.size();
-
o int size = costomers.length;
-
o int size = Arrays.size(customers);
-
o int size = Arrays.length(customers);
Pregunta 155
Pregunta
154. What will be the output of the following code? <i> <br> int[] arr = new int[9]; <br> System.out.println(arr[9]);</i>
Pregunta 156
Pregunta
155. When an object no longer has any reference variables referring to it, what happens to the object?
Respuesta
-
o It sits around in main memory forever
-
o It is swapped out the disk
-
o It is sent to the Dumpster
-
o The garbage collector makes the memory it occupies available for new objects
Pregunta 157
Pregunta
156. What value is assigned to a reference value to show that there is no object?
Respuesta
-
o 0
-
o null
-
o void
-
o 0x00000
-
o “”
Pregunta 158
Pregunta
158. Which one of the below shows the correct use of public to modify a method?
Respuesta
-
Public Void init()
-
public class MyProgram()
-
void public init()
-
public int myMethod()
-
init() public void
Pregunta 159
Pregunta
159.Which statement is accurate for the use of void with a method?
Respuesta
-
The void keyword means that the method will not return a value.
-
The void keyword denotes a particular instance of the void class.
-
The void method returns a void data type.
-
The void keyword means that the statements in the method are not executed.
-
This keyword voids the effects of a method.
Pregunta 160
Pregunta
160. Which of the below shows the correct form of a method? public int void goodBye() { code here }
Respuesta
-
public void MyProgram() { code here}
-
public voided hello() { code here } public
-
intGoodBye();
-
private int goodBye() {code here }
Pregunta 161
Pregunta
161. Which of the following is the closing brace for a block of statements in a method?
Pregunta 162
Pregunta
162. If a class has one method in it, which of the following would be the last two symbols in the program?
Pregunta 163
Pregunta
163. Given the line, public class MyTextArea extends JTextArea {, which of the following statements is correct?
Respuesta
-
JTextArea is a subclass of MyTextArea.
-
MyTextArea is a superclass of the extends class.
-
MyTextArea is a subclass of the JText class.
-
JTextArea is a superclass of MyTextArea.
-
JTextArea is a class of MyTextArea.
Pregunta 164
Pregunta
164. What will be the output of the program?<br>
Respuesta
-
0 1 2
-
0 1 2 1 2 2
-
2 1 0 1 0 0
-
2 1 2 0 1 2
-
2 1 2 1 0 2
Pregunta 165
Pregunta
165. What will be the output of the program?<br>
Respuesta
-
XyZabc
-
XyZABC
-
xyzabc
-
abcXyZ
-
abcxyz
Pregunta 166
Pregunta
166. Which of the following will directly stop the execution of a Thread?
Respuesta
-
wait()
-
notifyAll()
-
notify()
-
exits synchronized code
Pregunta 167
Pregunta
167. What will be the output of the program? <br>
Respuesta
-
It compiles and runs printing nothing It
-
compiles but fails at runtime
-
Compile error
-
It compiles and runs printing “complete”
Pregunta 168
Pregunta
168. What allows the programmer to destroy an object x? x.delete();
Pregunta 169
Pregunta
169. Information hiding can also be termed as
Respuesta
-
Data hiding
-
Encapsulation
-
Inheritance
-
Data minding
Pregunta 170
Pregunta
170. Two or more functions with same name in the same class with different arguments is called as
Respuesta
-
Method overriding
-
Method overloading
-
Encapsulation
Pregunta 171
Pregunta
171. When sub class declares a method that has the same type arguments as a method declared by one of its superclass it is termed as
Respuesta
-
Method overriding
-
Method overloading
-
Operator overriding
-
Operator overloading
Pregunta 172
Pregunta
172. What does closing file do?
Respuesta
-
Flushes pending output and finishes processing the file
-
Finishes processing the file, only
-
Flushes pending output, but the file may still be written to
-
Makes the file read-only
Pregunta 173
Pregunta
173. What method ensures that data from previous calls to write() is sent to disk and leaves the file open?
Pregunta 174
Pregunta
174. If a file opened for reading does not exist, which of the following events will occur in Java?
Respuesta
-
A run-time error will occur
-
A NullPointerException will be rised
-
A FileNotFoundException will be rised
-
A new file will be created
Pregunta 175
Pregunta
175. If a file opened for writing does not exist, which of the following events will occur in Java?
Respuesta
-
A NullPointerException will be rised
-
A run-time error will occur
-
A FileNotFoundException will be rised
-
A new file will be created
Pregunta 176
Pregunta
176. If a class contains a constructor, that constructor will be invoked
Respuesta
-
Each time an object of that class is instantiated
-
Each time an object of that class goes out of scope
-
Once at the beginning of any program that uses that class
-
Each time a method of an object of that class is invoked
Pregunta 177
Pregunta
177. In Java, the default layout manager for a JFrame component is
Respuesta
-
a) GridLayout
-
b) FlowLayout
-
c) GridingLayout
-
d) BorderLayout
Pregunta 178
Pregunta
178. Linked list cannot be implemented by using arrays
Pregunta 179
Pregunta
179. Can stack be described as a pointer?
Pregunta 180
Pregunta
180. What is the signature of the method specified in the Java ActionListener interface?
Respuesta
-
a) void actionPerformed (ActionListener al)
-
c) void actionListener (ActionEvent ae)
-
b) void actionEvent (ActionPerformed ap)
-
d) void actionPerformed (ActionEvent ae)
Pregunta 181
Pregunta
181. How many String objects have been created?
String x = new String("xyz");
String y = "abc";
x = x + y;
Pregunta 182
Pregunta
182. Which of the following is a Java event that is generated when a JButton component is pressed?
Respuesta
-
a) ButtonEvent
-
b) WindowEvent
-
c) ClickEvent
-
d) ActionEvent
Pregunta 183
Pregunta
183. Which one is true declaration?
1 final abstract class Test {}
2 public static interface Test {}
3 final public class Test {}
4 protected abstract class Test {}
Pregunta 184
Pregunta
184. What is the keyword in java used to create an instance?
Respuesta
-
a) this
-
b) object
-
d) none of the above
-
c) new
Pregunta 185
Pregunta
185. You can create java project same as:
Respuesta
-
a) public class name
-
c) any name
-
b) Main.java
-
d) class name
Pregunta 186
Pregunta
186. Consider following coding:
public class Object1 {
protected String d(){
return "Hi"; }}
public class Object2 extends Object1 {
protected String d(){
return super.d(); }}
Which of the following statements are true regarding the definitions?
Class Object2 inherits from class Object1.
Class Object2 overrides method d.
Method d do not returns equivalent results when executed from either class.
Respuesta
-
a) III
-
b) I, II, and III
-
c) I and III
-
d) I and II
Pregunta 187
Pregunta
187. What will be the output the following method Java code
import java.io.IOException
class Animal {
public void eat() throws IOException {
}
}
class Dog extends Animal {
public void eat() throws IOException {
}
}
Respuesta
-
a) Compilation error at Line 8
-
b) Compilation error at Line 7
-
c) Compilation error at Line 6
-
d) successful compilation
Pregunta 188
Pregunta
188. What will be the output the following method Java code
import java.io.*;
public class Test {
public Test( ) {
System.out.println("default");
}
public Test( int i ) {
System.out.println("non-default");
}
public static void main(String[] args) {
Test t = new Test(2);
}
}
Respuesta
-
a) The line of text "non-default" followed by the line of text "default"
-
b) The line of text "default"
-
c) The line of text "default" followed by the line of text "non-default"
-
d) The line of text "non-default"
Pregunta 189
Pregunta
189. The name of a Java source file.
Respuesta
-
a) has no restrictions
-
b) must be the same as the class it defines, respecting case
-
c) must be the same as the class it defines, ignoring case
-
d) must use the extension .class
Pregunta 190
Pregunta
190. The ActionEvent class and ActionListener interface are available in the _____ package of Java.
Respuesta
-
a) javax.swing.event
-
b) java.awt.event
-
c) javax.event
-
d) java.event
Pregunta 191
Pregunta
191. If a class has an association with itself, then the class contains
Respuesta
-
a) its own superclass
-
b) an attribute that references an object of the same class
-
c) a method that calls itself
-
d) a method that calls another method within the same class
Pregunta 192
Pregunta
192. What will be the output?
class Equals
{
public static void main(String [] args)
{
int x = 100;
double y = 100.1;
boolean b = (x = y);
System.out.println(b);
}
}
Respuesta
-
a) 100
-
c) 100.1
-
b) compilation error
-
d) true
Pregunta 193
Pregunta
193. In Java, what is the signature of the method in the WindowListener interface where code is to be added to end a program when the close button is pressed?
Respuesta
-
a) void windowClosing (WindowEvent we)
-
b) void windowClosed (WindowEvent we)
-
c) void windowDeactivated (WindowEvent we)
-
d) void windowAdapter (WindowEvent we)
Pregunta 194
Pregunta
194. Which of the following implementation will you use if you were to insert elements at any position in the collection ??
Respuesta
-
a) Vector
-
b) List
-
c) LinkedList
-
d) ArrayList
Pregunta 195
Pregunta
195. An empty list is the one which has no
Respuesta
-
a) data
-
b) nodes
-
c) a and b
-
d)address
Pregunta 196
Pregunta
196. JVM stands for
Respuesta
-
a) Java Verify Machine
-
b) Java Visual Machine
-
d) Java Virtual Machine
-
c) Java Visual Member
Pregunta 197
Pregunta
197. Which of the following is not the method of object class?
Respuesta
-
a) toString
-
c) finalize
-
b) clone
-
d) system
Pregunta 198
Pregunta
198. Which of the following is True about final keyword
Respuesta
-
a) We can declare abstract class as final.
-
b) We can modify final variables.
-
c) We can't declare a class abstract as well as final.
-
d) We can override final methods.
Pregunta 199
Pregunta
199. Which of the following is false about collections in Java ?
Respuesta
-
b) java.util is the default package for collection classes.
-
a) List , Map and Set are interfaces.
-
c) Collection interface is the base interface.
-
d) List , Map and Set are abstract classes
Pregunta 200
Pregunta
200. Which of the following is not true for hashtable and hasmaps ?
Respuesta
-
a) Hashtable are synchronized whereas hashmaps are not.
-
b) Hashtable doesn't allow null values whereas HashMaps allows null values.
-
c) Hashtable came before Hashmap
-
d) HashMaps are synchronized whereas hashtables are not.