sdp200

Beschreibung

Quiz am sdp200, erstellt von Hello World am 18/01/2017.
Hello World
Quiz von Hello World, aktualisiert more than 1 year ago
Hello World
Erstellt von Hello World vor fast 8 Jahre
733
1

Zusammenfassung der Ressource

Frage 1

Frage
1. What will be the output of the program?<br>
Antworten
  • o Pine
  • o Oak
  • o Tree
  • o Forest
  • o Oops

Frage 2

Frage
2. Select how you would run your program to cause it to print: Arg is 2 <br>
Antworten
  • 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

Frage 3

Frage
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>}
Antworten
  • 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

Frage 4

Frage
4. Given the declaration of an array : int[] a = {1,2,3,4,5}; What is the value of a[4]?
Antworten
  • o 2
  • o 3
  • o 4
  • o 5
  • o 1

Frage 5

Frage
5. An array holds:
Antworten
  • 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

Frage 6

Frage
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);
Antworten
  • 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

Frage 7

Frage
7. What is the prototype of the default constructor?<br>
Antworten
  • o Test()
  • o Test
  • o public Test()
  • o public Test(void)
  • o Test(void)

Frage 8

Frage
8. What is the widest valid returnType for methodA in line 3?<br>
Antworten
  • o int
  • o long
  • o byte
  • o double
  • o void

Frage 9

Frage
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?
Antworten
  • o java.util.Map
  • o java.util.Set
  • o java.util.Tree
  • o java.util.List
  • o java.util.Collection

Frage 10

Frage
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?
Antworten
  • o public
  • o private
  • o protected
  • o transient
  • o volatile

Frage 11

Frage
11. Let’s assume that you have class C and interface I ? Which of the following is correct statement?
Antworten
  • o class C implements I
  • o class C extends I
  • o interface I extends C
  • o interface I implements C
  • o class I implements C

Frage 12

Frage
12. Which is valid in a class that extends class A?<br>
Antworten
  • 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; }

Frage 13

Frage
13. Which statement is true?
Antworten
  • 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

Frage 14

Frage
14. What will be the output of the program?<br>
Antworten
  • o one two three four
  • o one two three four one
  • o four three two one
  • o four one three two

Frage 15

Frage
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?
Antworten
  • o final
  • o public
  • o private
  • o protected
  • o static
  • o volatile

Frage 16

Frage
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.
Antworten
  • o 1,2,4
  • o 2,3,5
  • o 3,4,5
  • o 1,2,3
  • o 1,3,5

Frage 17

Frage
17. What will be the output of the program?<br>
Antworten
  • o AC
  • o ACD
  • o BD
  • o ABCD
  • o ABD

Frage 18

Frage
18. What will be the output of the program after the running program in such way :/> java Test red green blue?<br>
Antworten
  • o baz =
  • o baz = blue
  • o baz = null
  • o Runtime Exception
  • o Compilation Error

Frage 19

Frage
19. Which is a valid declaration within an interface?
Antworten
  • 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;

Frage 20

Frage
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?
Antworten
  • o java.util.HashSet
  • o java.util.LinkedList
  • o java.util.ArrayList
  • o java.util.List
  • o java.util.TreeSet

Frage 21

Frage
21. Which interface provides the capability to store objects using a key-value pair?
Antworten
  • o java.util.Map
  • o java.util.Set
  • o java.util.List
  • o java.util.Collection
  • o java.util.ArrayList

Frage 22

Frage
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
Antworten
  • o 1 and 2
  • o 2 and 3
  • o 3 and 4
  • o 1 and 4
  • o 2 and 4

Frage 23

Frage
23. Which class or interface defines the wait(), notify(),and notifyAll() methods?
Antworten
  • o Object
  • o Thread
  • o Runnable
  • o Class

Frage 24

Frage
24. What will be the output of the program? <br>
Antworten
  • 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

Frage 25

Frage
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
Antworten
  • o 1 and 2
  • o 2 and 3
  • o 3 and 4
  • o 4 and 5
  • o 1 and 4
  • o 2 and 5

Frage 26

Frage
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?
Antworten
  • 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(){}}

Frage 27

Frage
27. What will be the output of the program?<br>
Antworten
  • o AB
  • o BC
  • o BCD
  • o ABC
  • o ACD

Frage 28

Frage
28. Which interface does the java.util.Hashtable implement?
Antworten
  • o java.util.Map
  • o java.util.Set
  • o java.util.Collection
  • o java.util.List
  • o java.util.HashTable

Frage 29

Frage
29. Which of these will create and start this thread? <br>
Antworten
  • 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();

Frage 30

Frage
30. The number of characters in an object of a class String is given by
Antworten
  • 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

Frage 31

Frage
31. Which of the following statements is correct?
Antworten
  • 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

Frage 32

Frage
32. Which code determines the int value data closer to, but not greater than, a double value b?
Antworten
  • 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)

Frage 33

Frage
33. Which statement is true for the Class java.util.HashSet?
Antworten
  • 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

Frage 34

Frage
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>}
Antworten
  • o Ex0 caught
  • o Exception caught
  • o Compilation fails because of an error at line 2
  • o Ex0 caught Exception caught

Frage 35

Frage
35. Which of the following is not a part of OOP?
Antworten
  • o Type checking
  • o Multitasking
  • o Polymorphism
  • o Information hiding

Frage 36

Frage
36. Static methods cannot be accessed directly from the class level
Antworten
  • True
  • False

Frage 37

Frage
37. The process by which one object can acquire the properties of another object
Antworten
  • o Encapsulation
  • o Inheritance
  • o Polymorphism

Frage 38

Frage
38. Constructors are used to
Antworten
  • o Build a user interface
  • o Free memory
  • o Initialize a newly created object
  • o To create a sub class

Frage 39

Frage
39. What happens in a method if an exception is thrown in a try{} block and there is NO MATCHING catch{} block?
Antworten
  • 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

Frage 40

Frage
40. Is a program required to catch all exceptions that might happen?
Antworten
  • 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

Frage 41

Frage
41. What method of an Exception object returns a message string?
Antworten
  • o getError()
  • o getMessage()
  • o printMessage()
  • o traceMessage()

Frage 42

Frage
42. What happens during execution if a negative value is used for an array index?
Antworten
  • 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

Frage 43

Frage
43. What method of an Exception object prints a list of methods that were called before the exception was throw?
Antworten
  • o printErrors()
  • o getMessage()
  • o traceStack()
  • o printStackTrace()

Frage 44

Frage
44. A single sequence of code executing within a program is known as:
Antworten
  • o A method
  • o A process
  • o A thread

Frage 45

Frage
45. To start the execution of a thread after you create it, you must:
Antworten
  • o Call the method run()
  • o Call the method start()
  • o Do nothing, threads start automatically upon creation
  • o Call the method notify()

Frage 46

Frage
46. You designate a method as being synchronized by:
Antworten
  • o Using the keyword synchronized
  • o Naming the method synchronize
  • o Placing a synchronized section of code within it

Frage 47

Frage
47. What method is declared in the Runnable interface and serves as the path of execution for all threads?
Antworten
  • o run()
  • o start()
  • o go()

Frage 48

Frage
48. What is a buffer?
Antworten
  • 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

Frage 49

Frage
49. What happens if a FileWriter constructor is given an illegal file name?
Antworten
  • o The program bombs immediately
  • o The users disk is corrupted
  • o The constructor returns a null value
  • o An IOExcpetion is thrown

Frage 50

Frage
50. When a file is opened for appending where does the write() put new text?
Antworten
  • 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

Frage 51

Frage
51. A null reference may be used to access a static variable or method
Antworten
  • True
  • False

Frage 52

Frage
52. Set allows at most two null elements?
Antworten
  • True
  • False

Frage 53

Frage
53. Which collection class allows you to access its elements by associating sorted element and provides an order?
Antworten
  • o java.util.TreeSet
  • o java.util.HashSet
  • o java.util.TreeMap
  • o java.util.Hashtable

Frage 54

Frage
54. A class cannot define more than one constructor
Antworten
  • True
  • False

Frage 55

Frage
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?
Antworten
  • o Queue
  • o Stack
  • o ArrayList
  • o LinkedList

Frage 56

Frage
56. In java one class can derive from one class?
Antworten
  • True
  • False

Frage 57

Frage
57. Which of the following is not true for abstract classes?
Antworten
  • 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

Frage 58

Frage
58. Which of the following is not true for static keyword?
Antworten
  • 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

Frage 59

Frage
59. List is a/an …?
Antworten
  • o Class
  • o Interface
  • o Both
  • o Package

Frage 60

Frage
60. Which exception is thrown by the read () method of InputStream class?
Antworten
  • o IOException
  • o FileNotFoundException
  • o ReadException
  • o AccessDeniedException

Frage 61

Frage
61. Which is the Java keyword used to denote a class method?
Antworten
  • o class
  • o final
  • o private
  • o static

Frage 62

Frage
62. What is Recursion in Java?
Antworten
  • 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

Frage 63

Frage
63. Which of these data types is used by operating system to manage the Recursion in Java?
Antworten
  • o Array
  • o Stack
  • o Queue
  • o Tree
  • o Map

Frage 64

Frage
64. What will be an output? <br>
Antworten
  • o true true
  • o true false
  • o false true
  • o false false
  • o Runtime error will occur

Frage 65

Frage
65. What will be an output? <br>
Antworten
  • o 24
  • o 30
  • o 120
  • o 720
  • o Compilation Error
  • o Runtime Error

Frage 66

Frage
66. What will be an output? <br>
Antworten
  • o 1
  • o 0
  • o 5
  • o 15
  • o Compilation Error
  • o Runtime Error

Frage 67

Frage
67. What will be an output? <br>
Antworten
  • o 1
  • o 0
  • o 12
  • o 78
  • o Compilation error
  • o Runtime error

Frage 68

Frage
68. Deletion is faster in LinkedList than ArrayList
Antworten
  • True
  • False

Frage 69

Frage
69. Can a top level class be private?
Antworten
  • True
  • False

Frage 70

Frage
70. Which of the following is not a primitive data type?
Antworten
  • o Double
  • o int
  • o char
  • o boolean
  • o No right answer

Frage 71

Frage
71. The term wrapper class refers to
Antworten
  • 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

Frage 72

Frage
72. What will be the output of the program? <br>
Antworten
  • o Got the exception 10
  • o Got the exception e
  • o Compilation error
  • o Runtime error

Frage 73

Frage
73. What will be the output of the program? <br>
Antworten
  • o Got the Test Exception
  • o Inside finally block
  • o Got the Test Exception <br> Inside finally block
  • o Compilation error

Frage 74

Frage
74. What will be the output of the program? <br>
Antworten
  • o Compilation error
  • o Compiles and runs fine
  • o Compiles fine but throws ArithmeticException at runtime

Frage 75

Frage
75. What will be the output of the program? <br>
Antworten
  • 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

Frage 76

Frage
76. What will be the output of the program? <br>
Antworten
  • o Compilation error
  • o Divide by zero error
  • o inside the finally block
  • o a = 0
  • o a=0 <br> Divide by zero block <br> inside the finally block

Frage 77

Frage
77. What will be the output of the program?<br>
Antworten
  • o Compilation error
  • o Runtime error
  • o ArrayIndexOutOfBoundsException
  • o ErrorCode is printed
  • o Array is printed

Frage 78

Frage
78. Which of the following is not true about interfaces in java?
Antworten
  • 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

Frage 79

Frage
79. Which of the following is not true about inheritance in java?
Antworten
  • 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

Frage 80

Frage
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
Antworten
  • 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

Frage 81

Frage
81. What will be the output of the program? <br>
Antworten
  • o Derived::show() called
  • o Base::show() called
  • o Compilation error
  • o Runtime error

Frage 82

Frage
82. What will be the output of the program? <br>
Antworten
  • o Derived::show() called
  • o Base::show() called
  • o Compilation error
  • o Runtime error

Frage 83

Frage
83. What will be the output of the program? <br>
Antworten
  • o Base
  • o Derived
  • o Compilation error
  • o Runtime error

Frage 84

Frage
84. What will be the output of the program? <br>
Antworten
  • 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

Frage 85

Frage
85. What will be the output of the program? <br>
Antworten
  • o Complex number is (10.0 + 15.0i)
  • o Compilation error
  • o Runtime error
  • o Complex number is Complex@8e2fb5 (where 8e2fb5 is hash code of c)

Frage 86

Frage
86. What will be the output of the program? <br>
Antworten
  • o 20
  • o 0
  • o Compilation error
  • o Runtime error

Frage 87

Frage
87. What will be the output of the program? <br>
Antworten
  • o s1 == s2 is: true
  • o s1 == s2 is: false
  • o true
  • o false
  • o compilation error
  • o runtime exception

Frage 88

Frage
88. Which of the following is used by byte streams for input?
Antworten
  • o InputStream
  • o InputOutputStream
  • o BufferedReader
  • o Scanner
  • o System.in

Frage 89

Frage
89. Which of these classes are used by character streams output operations?
Antworten
  • o InputStream
  • o ReadStream
  • o Writer
  • o OutputStream

Frage 90

Frage
90. Which of the following is not a wrapper class?
Antworten
  • o Byte
  • o String
  • o Integer
  • o Character
  • o Double
  • o Long

Frage 91

Frage
91. What restriction is there on using a super reference in a constructor?
Antworten
  • 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

Frage 92

Frage
92. A method that is used to assign values to the instance variables of the class is called a
Antworten
  • o set method
  • o get method
  • o accessor
  • o constructor
  • o toString() method

Frage 93

Frage
93. Which of the following is not a keyword for an exception handling?
Antworten
  • o try
  • o catch
  • o throw
  • o thrown
  • o finally

Frage 94

Frage
94. Which of the following keywords is used to handle the exception by try block?
Antworten
  • o try
  • o finally
  • o catch
  • o throw
  • o throws

Frage 95

Frage
95. Which of these operator is used to generate an instance of an exception than can be thrown by using throw?
Antworten
  • o new
  • o malloc
  • o alloc
  • o thrown
  • o return

Frage 96

Frage
96. Which of the followings is a type of stream in java?
Antworten
  • o Integer stream
  • o Byte stream
  • o Short stream
  • o Long stream

Frage 97

Frage
97. What will be the output of the following program? <br>
Antworten
  • o BD
  • o ABDE
  • o BCDE
  • o BCD
  • o BDE
  • o ABCE
  • o ABCD
  • o ABD

Frage 98

Frage
98. What will be the output of the following code? <br>
Antworten
  • o hello caught finally after
  • o hello throwit finally
  • o hello throwit caught finally after
  • o hello caught after
  • o compilation fails
  • o caught finally after

Frage 99

Frage
99. What will be the output of the program? <br>
Antworten
  • o finally
  • o Compilation fails
  • o exception finished
  • o finally finished
  • o finally exception finished
  • o finally exception

Frage 100

Frage
100. What will be the output of the program? <br>
Antworten
  • o ABCD
  • o ACD
  • o ABD
  • o BCD
  • o BC
  • o BD
  • o CD

Frage 101

Frage
101. What will be the output of the program? <br>
Antworten
  • 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

Frage 102

Frage
102. What will be the output of the program? <br>
Antworten
  • o Ex0 caught
  • o Exception caught
  • o Compilation fails on line 2
  • o Compilation fails on line 9
  • o Compilation fails on line 11

Frage 103

Frage
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?
Antworten
  • o java.util.HashSet
  • o java.util.List
  • o java.util.LinkedHashSet
  • o java.util.ArrayList
  • o java.util.HashMap
  • o java.util.Map

Frage 104

Frage
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?
Antworten
  • o java.util.Map
  • o java.util.List
  • o java.util.Set
  • o java.util.Collection

Frage 105

Frage
105. Which interface does java.util.Hashtable implement?
Antworten
  • o java.util.Map
  • o java.util.List
  • o java.util.HashTable
  • o java.util.Set
  • o java.util.Collection

Frage 106

Frage
106. Which interface provides the capability to store objects using a key-value pair?
Antworten
  • o java.util.Map
  • o java.util.List
  • o java.util.HashTable
  • o java.util.Set
  • o java.util.Collection

Frage 107

Frage
107. What line of code should replace the missing statement to make this program compile? <br>
Antworten
  • o import java.io.*;
  • o import java.io.PrintWriter
  • o include java.io.*;
  • o no statement required

Frage 108

Frage
108. What is the numerical range of char?
Antworten
  • o 0 .. 32767
  • o 0 .. 65535
  • o -256 .. 255
  • o 0 .. 255
  • o -32768 .. 32767
  • o 0 .. 511

Frage 109

Frage
109. In Java, defining more than one method having the same name within a particular class is called
Antworten
  • o overloading
  • o sharing
  • o overriding
  • o superseding

Frage 110

Frage
110. What is an inheritance?
Antworten
  • 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.

Frage 111

Frage
111. When constructor is called?
Antworten
  • 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

Frage 112

Frage
112. What is the difference between a try-catch block and a try-catch-finally block?
Antworten
  • 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

Frage 113

Frage
113. Which keyword would you use if you wanted a class to use an interface?
Antworten
  • o implements
  • o extends
  • o throws
  • o new
  • o main()

Frage 114

Frage
114. Which keyword would you use to break out of a loop?
Antworten
  • o break
  • o continue
  • o while
  • o for
  • o do

Frage 115

Frage
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>
Antworten
  • o r
  • o n
  • o s
  • o a
  • o e

Frage 116

Frage
116. Which package is imported by default into Java programs?
Antworten
  • o java.awt
  • o java.awt.font
  • o java.lang
  • o java.io
  • o java.util

Frage 117

Frage
What is the purpose of a class constructor?
Antworten
  • 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

Frage 118

Frage
117. What will be the output of the program?<br>
Antworten
  • o 0
  • o error
  • o Compilation fails
  • o An uncaught exception is thrown at runtime
  • o No output
  • o / by 0

Frage 119

Frage
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?
Antworten
  • o class F implements B,C
  • o class F implements C
  • o class F extends A,C
  • o class F implements E
  • o class F extends C implements B
  • o class F extends B

Frage 120

Frage
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?
Antworten
  • 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

Frage 121

Frage
120. What will be the output? <br>
Antworten
  • o Got the Test Exception<br> Inside finally block
  • o Inside finally block
  • o Got the Test Exception
  • o Compilation fails

Frage 122

Frage
121. What will be the output? <br>
Antworten
  • 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

Frage 123

Frage
122. A java array that contains N components will be indexed from ….. through …..
Antworten
  • o 0, N – 1
  • o 1, N
  • o 0, N
  • o 1, N - 1

Frage 124

Frage
123. Which method must exist, to make your class executable?
Antworten
  • o main
  • o begin
  • o init
  • o int
  • o paint

Frage 125

Frage
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”);
Antworten
  • o Elviswas here
  • o Elvis was here
  • o namewas here
  • o name was here
  • o name + was here

Frage 126

Frage
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);
Antworten
  • o 512
  • o 5 1 2
  • o 8
  • o The code will cause a compilation error

Frage 127

Frage
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“);
Antworten
  • o 71
  • o 521
  • o 5 2 1
  • o 7 1
  • o The code will cause a compilation error
  • o All are valid

Frage 128

Frage
127. What will be the result of the following code segment? <br>
Antworten
  • 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

Frage 129

Frage
128. What is the output of the following code segment?
Antworten
  • o A
  • o B
  • o C
  • o D or lower

Frage 130

Frage
129. If you want to execute body at least once, what type of loop would you use?
Antworten
  • o for loop
  • o while loop
  • o none of the given
  • o do .. while loop

Frage 131

Frage
130. What are the values of I and product after this code is executed? <br>
Antworten
  • o 9 and 366
  • o 9 and 336
  • o 8 and 42
  • o 8 and 336

Frage 132

Frage
131. What is the output of the following code fragment? <br>
Antworten
  • o Error
  • o 2 times Hello
  • o 3 times Hello
  • o No output will be produced

Frage 133

Frage
132. What is the purpose of the semicolon mark (;) in a Java program?
Antworten
  • 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

Frage 134

Frage
133. What is the size of short variable?
Antworten
  • o 8 bit
  • o 16 bit
  • o 32 bit
  • o 64 bit

Frage 135

Frage
134. Which of the following is true about public access modifier?
Antworten
  • 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

Frage 136

Frage
135. Which of the following is not a keyword in Java?
Antworten
  • o static
  • o void
  • o Boolean
  • o private

Frage 137

Frage
136. Which of the following stands true about default modifier of class members?
Antworten
  • 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

Frage 138

Frage
137. Inheritance represents
Antworten
  • o HAS-A relationship
  • o IS-A relationship

Frage 139

Frage
138. What is function overloading?
Antworten
  • 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

Frage 140

Frage
139. What is a class in java?
Antworten
  • 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

Frage 141

Frage
140. Can be constructor be made private?
Antworten
  • True
  • False

Frage 142

Frage
141. What is JRE?
Antworten
  • 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

Frage 143

Frage
142. What is essential in making sure that your loop is not infinite?
Antworten
  • 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

Frage 144

Frage
143. In a “for” loop, what section is not included in parentheses after “for”?
Antworten
  • o Initialization
  • o Loop body
  • o Test statement
  • o Update

Frage 145

Frage
144. Abstract method can be in
Antworten
  • o abstract class
  • o normal class
  • o concrete class
  • o any class

Frage 146

Frage
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
Antworten
  • o Method overriding
  • o Method overloading
  • o Inheritance
  • o Encapsulation

Frage 147

Frage
146. Static variables cannot be accessed directly from the class level
Antworten
  • True
  • False

Frage 148

Frage
147. When a class is based on another class, it inherits:
Antworten
  • 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

Frage 149

Frage
148. When sub class declares a method that has the same type arguments as a method in the parent class, it is termed as
Antworten
  • o Method overriding
  • o Method overloading
  • o Operator overloading
  • o Operator overriding

Frage 150

Frage
149. Constructors are used to
Antworten
  • o Build a user interface
  • o Free memory
  • o Initialize a newly created object
  • o To create a sub class

Frage 151

Frage
150. What is a template, or specification, that determines a type of object in java?
Antworten
  • o A class
  • o A template
  • o A struct
  • o A prototype
  • o A framework

Frage 152

Frage
151. The process by which one object can acquire the properties of another object?
Antworten
  • o Encapsulation
  • o Inheritance
  • o Polymorphism
  • o Aggregation

Frage 153

Frage
152. What is the highest index value is associated with the array that follows? <br> <i> byte[] values = new byte[x]; </i>
Antworten
  • o 0
  • o x
  • o x+1
  • o x-1

Frage 154

Frage
153. which of the following statements gets the number of integers in the array that follows? <br> <i> int[] customers = new int[55];</i>
Antworten
  • 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);

Frage 155

Frage
154. What will be the output of the following code? <i> <br> int[] arr = new int[9]; <br> System.out.println(arr[9]);</i>
Antworten
  • o 0
  • o Some junk value
  • o Error because array is not initialized
  • o Error because index out of range

Frage 156

Frage
155. When an object no longer has any reference variables referring to it, what happens to the object?
Antworten
  • 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

Frage 157

Frage
156. What value is assigned to a reference value to show that there is no object?
Antworten
  • o 0
  • o null
  • o void
  • o 0x00000
  • o “”

Frage 158

Frage
158. Which one of the below shows the correct use of public to modify a method?
Antworten
  • Public Void init()
  • public class MyProgram()
  • void public init()
  • public int myMethod()
  • init() public void

Frage 159

Frage
159.Which statement is accurate for the use of void with a method?
Antworten
  • 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.

Frage 160

Frage
160. Which of the below shows the correct form of a method? public int void goodBye() { code here }
Antworten
  • public void MyProgram() { code here}
  • public voided hello() { code here } public
  • intGoodBye();
  • private int goodBye() {code here }

Frage 161

Frage
161. Which of the following is the closing brace for a block of statements in a method?
Antworten
  • [
  • {
  • ]
  • }
  • ()

Frage 162

Frage
162. If a class has one method in it, which of the following would be the last two symbols in the program?
Antworten
  • {}
  • ))
  • }}
  • )}
  • }{

Frage 163

Frage
163. Given the line, public class MyTextArea extends JTextArea {, which of the following statements is correct?
Antworten
  • 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.

Frage 164

Frage
164. What will be the output of the program?<br>
Antworten
  • 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

Frage 165

Frage
165. What will be the output of the program?<br>
Antworten
  • XyZabc
  • XyZABC
  • xyzabc
  • abcXyZ
  • abcxyz

Frage 166

Frage
166. Which of the following will directly stop the execution of a Thread?
Antworten
  • wait()
  • notifyAll()
  • notify()
  • exits synchronized code

Frage 167

Frage
167. What will be the output of the program? <br>
Antworten
  • It compiles and runs printing nothing It
  • compiles but fails at runtime
  • Compile error
  • It compiles and runs printing “complete”

Frage 168

Frage
168. What allows the programmer to destroy an object x? x.delete();
Antworten
  • x.destroy();
  • x.clean();
  • Runtime.getRuntime.gc(x);
  • Only the garbage collection system can destroy the object

Frage 169

Frage
169. Information hiding can also be termed as
Antworten
  • Data hiding
  • Encapsulation
  • Inheritance
  • Data minding

Frage 170

Frage
170. Two or more functions with same name in the same class with different arguments is called as
Antworten
  • Method overriding
  • Method overloading
  • Encapsulation

Frage 171

Frage
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
Antworten
  • Method overriding
  • Method overloading
  • Operator overriding
  • Operator overloading

Frage 172

Frage
172. What does closing file do?
Antworten
  • 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

Frage 173

Frage
173. What method ensures that data from previous calls to write() is sent to disk and leaves the file open?
Antworten
  • flush()
  • close()
  • each write() does this for the previous one.
  • print()

Frage 174

Frage
174. If a file opened for reading does not exist, which of the following events will occur in Java?
Antworten
  • A run-time error will occur
  • A NullPointerException will be rised
  • A FileNotFoundException will be rised
  • A new file will be created

Frage 175

Frage
175. If a file opened for writing does not exist, which of the following events will occur in Java?
Antworten
  • A NullPointerException will be rised
  • A run-time error will occur
  • A FileNotFoundException will be rised
  • A new file will be created

Frage 176

Frage
176. If a class contains a constructor, that constructor will be invoked
Antworten
  • 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

Frage 177

Frage
177. In Java, the default layout manager for a JFrame component is
Antworten
  • a) GridLayout
  • b) FlowLayout
  • c) GridingLayout
  • d) BorderLayout

Frage 178

Frage
178. Linked list cannot be implemented by using arrays
Antworten
  • True
  • False

Frage 179

Frage
179. Can stack be described as a pointer?
Antworten
  • True
  • False

Frage 180

Frage
180. What is the signature of the method specified in the Java ActionListener interface?
Antworten
  • a) void actionPerformed (ActionListener al)
  • c) void actionListener (ActionEvent ae)
  • b) void actionEvent (ActionPerformed ap)
  • d) void actionPerformed (ActionEvent ae)

Frage 181

Frage
181. How many String objects have been created? String x = new String("xyz"); String y = "abc"; x = x + y;
Antworten
  • a) 1
  • b) 2
  • c) 3
  • d) 4

Frage 182

Frage
182. Which of the following is a Java event that is generated when a JButton component is pressed?
Antworten
  • a) ButtonEvent
  • b) WindowEvent
  • c) ClickEvent
  • d) ActionEvent

Frage 183

Frage
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 {}
Antworten
  • 1
  • 2
  • 3
  • 4

Frage 184

Frage
184. What is the keyword in java used to create an instance?
Antworten
  • a) this
  • b) object
  • d) none of the above
  • c) new

Frage 185

Frage
185. You can create java project same as:
Antworten
  • a) public class name
  • c) any name
  • b) Main.java
  • d) class name

Frage 186

Frage
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.
Antworten
  • a) III
  • b) I, II, and III
  • c) I and III
  • d) I and II

Frage 187

Frage
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 { } }
Antworten
  • a) Compilation error at Line 8
  • b) Compilation error at Line 7
  • c) Compilation error at Line 6
  • d) successful compilation

Frage 188

Frage
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); } }
Antworten
  • 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"

Frage 189

Frage
189. The name of a Java source file.
Antworten
  • 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

Frage 190

Frage
190. The ActionEvent class and ActionListener interface are available in the _____ package of Java.
Antworten
  • a) javax.swing.event
  • b) java.awt.event
  • c) javax.event
  • d) java.event

Frage 191

Frage
191. If a class has an association with itself, then the class contains
Antworten
  • 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

Frage 192

Frage
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); } }
Antworten
  • a) 100
  • c) 100.1
  • b) compilation error
  • d) true

Frage 193

Frage
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?
Antworten
  • a) void windowClosing (WindowEvent we)
  • b) void windowClosed (WindowEvent we)
  • c) void windowDeactivated (WindowEvent we)
  • d) void windowAdapter (WindowEvent we)

Frage 194

Frage
194. Which of the following implementation will you use if you were to insert elements at any position in the collection ??
Antworten
  • a) Vector
  • b) List
  • c) LinkedList
  • d) ArrayList

Frage 195

Frage
195. An empty list is the one which has no
Antworten
  • a) data
  • b) nodes
  • c) a and b
  • d)address

Frage 196

Frage
196. JVM stands for
Antworten
  • a) Java Verify Machine
  • b) Java Visual Machine
  • d) Java Virtual Machine
  • c) Java Visual Member

Frage 197

Frage
197. Which of the following is not the method of object class?
Antworten
  • a) toString
  • c) finalize
  • b) clone
  • d) system

Frage 198

Frage
198. Which of the following is True about final keyword
Antworten
  • 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.

Frage 199

Frage
199. Which of the following is false about collections in Java ?
Antworten
  • 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

Frage 200

Frage
200. Which of the following is not true for hashtable and hasmaps ?
Antworten
  • 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.
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

10 Mind Mapping Strategien für Lehrer
AntonS
Vokabeln für Gesundheits- und Krankenpflege
julian.haeuserer
Vererbung
Greta Warnke
PR VO part2
Anda Muresan
Differenzialrechnung (Analysis) Zusammenfassung
Antonia C
Ökologie
vere2400
Methoden der Stratigraphie
Weltraumkatze Fanroth
PAED
Anna Huber
PR 2017/18
Carmen Mai
AVO & Klinische Pharmakologie 2013
Birte Schulz
Vetie Tierseuchen 2019
Tropsi B