Quiz
sDP3 THEORY
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (163)
13. [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>}
- Ao It determines if the array contains the same characters as the String
- Bo It copies characters from the array to the String
- C• It copies characters from the String to the array;
- Do It creates a new array that contains the same characters as the String
24. Given the declaration of an array : int[] a = {1,2,3,4,5}; What is the value of a[4]?
- Ao 2
- B3
- C4
- D5
- E1
35. An array holds:
- ASimilar values of same data type
- BDifferent values of same data type
- CSame values of different data types
- DDifferent values of different data types
46. [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);
- AA copy of the array rats
- BThe value of the elements of rats
- CA reference of the array
- D1.2
- E2.3
59. 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?
- Ajava.util.Map
- Bjava.util.Set
- Cjava.util.Tree
- Djava.util.List
- Ejava.util.Collection
610. You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?
- Apublic
- Bprivate
- Cprotected
- Dtransient
- Evolatile
711. Let’s assume that you have class C and interface I ? Which of the following is correct statement?
- Aclass C implements I
- Bclass C extends I
- Cinterface I extends C
- Dinterface I implements C
- Eclass I implements C
815. 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?
- Afinal
- Bpublic
- Cprivate
- Dprotected
- Estatic
- Fvolatile
916. [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.
- A1,2,4
- B2,3,5
- C3,4,5
- D1,2,3
- E1,3,5
1019. Which is a valid declaration within an interface?
- Apublic static final short stop = 23;
- Bprotected short stop = 23;
- Ctransient short stop = 23;
- Dfinal void madness(short stop);
- Evoid madness(short stop) = 0;
1120. Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
- Ajava.util.HashSet
- Bjava.util.LinkedList
- Cjava.util.ArrayList
- Djava.util.List
- Ejava.util.TreeSet
1221. Which interface provides the capability to store objects using a key-value pair?
- Ajava.util.Map
- Bjava.util.Set
- Cjava.util.List
- Djava.util.Collection
- Ejava.util.ArrayList
1322. [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
- A1 and 2
- B2 and 3
- C3 and 4
- D1 and 4
- E2 and 4
1423. Which class or interface defines the wait(), notify(),and notifyAll() methods?
- AObject
- BThread
- CRunnable
- DClass
1525. [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
- A1 and 2
- B2 and 3
- C3 and 4
- D4 and 5
- E1 and 4
- F2 and 5
1628. Which interface does the java.util.Hashtable implement?
- Ajava.util.Map
- Bjava.util.Set
- Cjava.util.Collection
- Djava.util.List
- Ejava.util.HashTable
1730. The number of characters in an object of a class String is given by
- AThe member variable called size
- BThe member variable called length
- CThe method size() returns the number of characters
- DThe method length() returns the number of characters
1831. Which of the following statements is correct?
- AAn import statement, if defined, must be the non-comment statement of the file
- BPrivate members are accessible to all classes in the same package
- CAn abstract class can be declared as final
- DLocal variables cannot be declared as static
1932. Which code determines the int value data closer to, but not greater than, a double value b?
- Aint data = (int)Math.ceil(b)
- Bint data = (int)Math.floor(b)
- Cint data = (int)Math.abs(b)
- Dint data = (int)Math.min(b)
2033. Which statement is true for the Class java.util.HashSet?
- AThe elements in the collection are unique
- BThe elements in the collection are ordered
- CThe elements in the collection are synchronized
- DThe collection is guaranteed to be immutable
2134. [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>}
- AEx0 caught
- BException caught
- CCompilation fails because of an error at line 2
- DCompilation fails because of an error at line 2д
- EEx0 caught Exception caught
2235. Which of the following is not a part of OOP?
- AType checking
- BMultitasking
- CPolymorphism
- DInformation hiding
2336. Static methods cannot be accessed directly from the class level
- ATrue
- Bfalse
2437. The process by which one object can acquire the properties of another object
- AEncapsulation
- BInheritance
- CPolymorphism
2538. Constructors are used to
- ABuild a user interface
- BFree memory
- CInitialize a newly created object
- DTo create a sub class
2639. What happens in a method if an exception is thrown in a try{} block and there is NO MATCHING catch{} block?
- AThis is not legal, so the program will not compile
- BThe method throws the exception to its caller, exactly if there were no try{} block
- CThe program halts immediately
- DThe program ignores the exception
27What happens in a method if an exception is thrown in a try{} block and there is NO MATCHING catch{} block?
- AThis is not legal, so the program will not compile
- BThe method throws the exception to its caller, exactly if there were no try{} block
- CThe program halts immediately
- DThe program ignores the exception
2840. Is a program required to catch all exceptions that might happen?
- ANo. You can write a program to catch just the exceptions you want
- BNo. But if a program catches one type of exception it must catch all other types as well
- CYes. If a program is not written to catch all exceptions it will not compile
- DYes. A program can not do I/O unless it catches all exceptions
2941. What method of an Exception object returns a message string?
- AgetError()
- BgetMessage()
- CprintMessage()
- DtraceMessage()
3042. What happens during execution if a negative value is used for an array index?
- AAn IndexOutOfBoundsException is thrown
- BA NumberFormatException is thrown
- CThe first slot of the array is used
- DThis is an Error, so the program immediately terminates no matter what
3143. What method of an Exception object prints a list of methods that were called before the exception was throw?
- AprintErrors()
- BgetMessage()
- CprintStackTrace()
- DtraceStack()
3244. A single sequence of code executing within a program is known as:
- AA method
- BA process
- CA Thread
3345. To start the execution of a thread after you create it, you must:
- ACall the method run()
- BCall the method start()
- CDo nothing, threads start automatically upon creation
- DCall the method notify()
3446. You designate a method as being synchronized by:
- AUsing the keyword synchronized
- BNaming the method synchronize
- CPlacing a synchronized section of code within it
3547. What method is declared in the Runnable interface and serves as the path of execution for all threads?
- Astart()
- Brun()
- Cgo()
3648. What is a buffer?
- AA section of memory used as a staging area for input or output data
- BThe cable that connects a data source to the bus
- CAny stream that deals with character IO
- DA file that contains binary data
3749. What happens if a FileWriter constructor is given an illegal file name?
- AThe program bombs immediately
- BThe users disk is corrupted
- CThe constructor returns a null value
- DAn IOExcpetion is thrown
3850. When a file is opened for appending where does the write() put new text?
- AAt the beginning of the file
- BAt the end of the file
- CWhere ever the user specifies
- DFiles cannot be appended to
3951. A null reference may be used to access a static variable or method
- ATrue
- BFalse
4052. Set allows at most two null elements?
- Atrue
- Bfalse
4153. Which collection class allows you to access its elements by associating sorted element and provides an order?
- Ajava.util.TreeSet
- Bjava.util.HashSet
- Cjava.util.TreeMap
- Djava.util.Hashtable
4254. A class cannot define more than one constructor
- Atrue
- Bfalse
4355. 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?
- AQueue
- BStack
- CArrayList
- DLinkedList
4456. In java one class can derive from one class?
- Atrue
- Bfalse
4557. Which of the following is not true for abstract classes?
- AAbstract class cannot to be instantiated
- BAbstract class handlers can be used to handle derived class objects
- CWe can’t have an abstract class without abstract methods
- DAbstract class has member elements
4658. Which of the following is not true for static keyword?
- AStatic members are shared by all objects of the class
- BWe can override static methods
- CStatic methods operate only on static variables only
- DStatic elements are accessed using class name
4759. List is a/an …?
- AClass
- BInterface
- CBoth
- DPackage
4860. Which exception is thrown by the read () method of InputStream class?
- AIOException
- BFileNotFoundException
- CReadException
- DAccessDeniedException
4961. Which is the Java keyword used to denote a class method?
- Aclass
- Bfinal
- Cprivate
- Dstatic
5062. What is Recursion in Java?
- ARecursion is a class
- BRecursion is a process of defining a method that calls other methods repeatedly
- CRecursion is a process of defining a method that calls itself repeatedly
- DRecursion is a process of defining a method that calls other methods which in turn call again this method
5163. Which of these data types is used by operating system to manage the Recursion in Java?
- AArray
- BStack
- CQueue
- DTree
- EMap
5269. Can a top level class be private?
- Atrue
- Bfalse
5370. Which of the following is not a primitive data type?
- ADouble
- Bint
- Cchar
- Dboolean
- Eno right answear
5471. The term wrapper class refers to
- AA collection of java classes that used to make an object from primitive data types
- BThe java classes that contain at least two data fields
- CThe java classes that contain a reference to themselves
- DA collection of java classes that contain other java classes
5578. Which of the following is not true about interfaces in java?
- AAn 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
- BAn instance of interface can be created
- CA class can implement multiple interfaces
- DMany classes can implement the same interface
5679. Which of the following is not true about inheritance in java?
- APrivate methods are final
- BProtected members are accessible within a package and inherited classes outside the package
- CProtected methods are final
- DWe cannot override private methods
5780. 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
- A1,2 and 3
- B1 and 2
- C1 and 3
- D2 and 3
- EOnly 1
- FOnly 2
- GOnly 3
5888. Which of the following is used by byte streams for input?
- AInputStream
- BInputOutputStream
- CBufferedReader
- DScanner
- ESystem.in
5989. Which of these classes are used by character streams output operations?
- AInputStream
- BReadStream
- CWriter
- DOutputStream
6090. Which of the following is not a wrapper class?
- AByte
- BString
- CInteger
- DCharacter
- EDouble
- FLong
6191. What restriction is there on using a super reference in a constructor?
- AOnly one child class can use it
- BIt can only be used in parent class
- CIt must be used in the first statement of the constructor of subclass
- DIt must be used in the last statement of the constructor of subclass
- ENo right answer
6292. A method that is used to assign values to the instance variables of the class is called a
- Aset method
- Bget method
- Caccessor
- Dconstructor
- EtoString() method
6393. Which of the following is not a keyword for an exception handling?
- Atry
- Bcatch
- Cthrow
- Dthrown
- Efinally
6494. Which of the following keywords is used to handle the exception by try block?
- Atry
- Bfinally
- Ccatch
- Dthrow
- Ethrows
6595. Which of these operator is used to generate an instance of an exception than can be thrown by using throw?
- Anew
- Bmalloc
- Calloc
- Dthrown
- Ereturn
6696. Which of the followings is a type of stream in java?
- AInteger stream
- BByte stream
- CShort stream
- DLong stream
67103. Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
- Ajava.util.HashSet
- Bjava.util.List
- Cjava.util.LinkedHashSet
- Djava.util.ArrayList
- Ejava.util.HashMap
- Fjava.util.Map
68104. 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
- Ao java.util.Map
- Bo java.util.List
- Co java.util.Set
- Do java.util.Collection
69105. Which interface does java.util.Hashtable implement?
- Ajava.util.Map
- Bjava.util.List
- Cjava.util.HashTable
- Djava.util.Set
- Ejava.util.Collection
70106. Which interface provides the capability to store objects using a key-value pair?
- Ajava.util.Map
- Bjava.util.List
- Cjava.util.HashTable
- Djava.util.Set
- Ejava.util.Collection
71108. What is the numerical range of char?
- A0 .. 32767
- B0 .. 65535
- C-256 .. 255
- D-32768 .. 32767
- E0 .. 255
- F0 .. 511
72109. In Java, defining more than one method having the same name within a particular class is called
- Aoverloading
- Bsharing
- Coverriding
- Dsuperseding
73110. What is an inheritance?
- AIt is the process where one object acquires the properties of another
- BInheritance is the ability of an object to take on many forms
- CInheritance is a technique to define different methods of same types
- DNone of the above.
74111. When constructor is called?
- AConstructor is called before creating the object
- BConstructor is called after creating the object
- CConstructor is called concurrently when object creation is going on
- DConstructor cannot be called
75112. What is the difference between a try-catch block and a try-catch-finally block?
- Atry-catch contains code to execute whether an occurs or not, try-catch-finally contains code to execute only if an error occurs
- Btry-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
- CSame thing, different names
- Dtry-catch contains code to execute only if an error occurs, try-catch-finally contains code to execute whether an occurs or not
76113. Which keyword would you use if you wanted a class to use an interface?
- Aimplements
- Bextends
- Cthrows
- Dnew
- Emain()
77114. Which keyword would you use to break out of a loop?
- Abreak
- Bcontinue
- Cwhile
- Dfor
- Edo
78115. 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>
- Ar
- Bn
- Ca
- Ds
- Ee
79116. Which package is imported by default into Java programs?
- Ajava.awt
- Bjava.awt.font
- Cjava.lang
- Djava.io
- Ejava.util
80117. What is the purpose of a class constructor?
- ATo make objects initially have certain values when they are instantiated
- BTo extend a class
- CTo pass values to methods for a class
- DTo instantiate an object
81119. 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?
- Aclass F implements B,C
- Bclass F implements C
- Cclass F extends A,C
- Dclass F implements E
- Eclass F extends C implements B
- Fclass F extends B
82123. A java array that contains N components will be indexed from ….. o 0, N
- A0, N – 1
- B1, N
- C0, N
- D1, N - 1
83Which method must exist, to make your class executable?
- Amain
- Bbegin
- Cinit
- Dint
- Epaint
84125. What will be output produced after the execution of the following code segment? <br>String name = “Elvis”; <br> System.out.println(name + “was here”);
- AElviswas here
- BElvis was here
- Cnamewas here
- Dname was here
- Ename + was here
85126. 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);
- A512
- B5 1 2
- C8
- DThe code will cause a compilation error
86127. 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“);
- A71
- B521
- C5 2 1
- D7 1
- EThe code will cause a compilation error
- FAll are valid
87130. If you want to execute body at least once, what type of loop would you use?
- Afor loop
- Bwhile loop
- Cdo .. while loop
- Dnone of the given
88133. What is the purpose of the semicolon mark (;) in a Java program?
- ADesignates a temporary separation when used in a package statement.
- BIt is used once and only once in a program
- CDesignates the end of a statement or unit of Java code.
- DIt is used only with JApplet class.
- EIt is an optional end-of-file marker
89134. What is the size of short variable?
- A8 bit
- B16 bit
- C32 bit
- D64 bit
90135. Which of the following is true about public access modifier?
- AVariables, methods and constructors which are declared public can be accessed by any class.
- BVariables, methods and constructors which are declared public can be accessed by any class lying in same package
- CVariables, methods and constructors which are declared public in the superclass can be accessed only by its child class
- DNo right answer
91136. Which of the following is not a keyword in Java?
- Astatic
- Bvoid
- CBoolean
- Dprivate
92137. Which of the following stands true about default modifier of class members?
- ABy default, variables, methods and constructors can be accessed by subclass only.
- BBy default, variables, methods and constructors can be accessed by any class lying in any package.
- CBy default, variables, methods and constructors can be accessed by any class lying in the same package.
- DNo right answer
93138. Inheritance represents
- AHAS-A relationship
- BIS-A relationship
94139. What is function overloading?
- AMethods with same name but different parameters.
- BMethods with same name but different return types
- CMethods with same name, same parameter types but different parameter names.
- DNo right answer
95140. What is a class in java?
- AA 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
- Bclass is a special data type
- Cclass is used to allocate memory to a data type.
- DNo right answer
96141. Can be constructor be made private?
- Atrue
- Bfalse
97142. What is JRE?
- AJRE is a java based GUI application.
- BJRE is an application development framework
- CJRE is an implementation of the Java Virtual Machine which executes Java programs
- DNo right answer
98143. What is essential in making sure that your loop is not infinite?
- AThat your Boolean statement at some point will be false
- BThat your Boolean statement at some point will be true
- CThat there is a Boolean statement somewhere in your code
- DAll answers are right
99144. In a “for” loop, what section is not included in parentheses after “for”?
- AInitialization
- BLoop body
- CTest statement
- DUpdate
100145. Abstract method can be in
- Aabstract class
- Bnormal class
- Cconcrete class
- Dany class
101146. 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
- AMethod overriding
- BMethod overloading
- CInheritance
- DEncapsulation
102147. Static variables cannot be accessed directly from the class level
- Atrue
- Bfalse
103148. When a class is based on another class, it inherits:
- AThe data and methods for the class
- BThe methods and messages for the class
- COnly the data for the class
- DStatic block of that class
104149. When sub class declares a method that has the same type arguments as a method in the parent class, it is termed as
- AMethod overriding
- BMethod overloading
- COperator overriding
- DOperator overloading
105150. Constructors are used to
- ABuild a user interface
- BFree memory
- CInitialize a newly created object
- DTo create a sub class
106151. What is a template, or specification, that determines a type of object in java?
- AA class
- BA template
- CA struct
- DA prototype
- EA framework
107152. The process by which one object can acquire the properties of another object?
- AEncapsulation
- BInheritance
- CPolymorphism
- DAggregation
108153. What is the highest index value is associated with the array that follows? <br> <i> byte[] values = new byte[x]; </i>
- A0
- Bx
- Cx-1
- Dx+1
109154. which of the following statements gets the number of integers in the array that follows? <br> <i> int[] customers = new int[55];</i>
- Aint size = customers.length();
- Bint size = customers.size();
- Cint size = costomers.length;
- Dint size = Arrays.size(customers);
- Eint size = Arrays.length(customers);
110155. What will be the output of the following code? <i> <br> int[] arr = new int[9]; <br> System.out.println(arr[9]);</i>
- A0
- BSome junk value
- CError because array is not initialized
- DError because index out of range
111156. When an object no longer has any reference variables referring to it, what happens to the object?
- AIt sits around in main memory forever
- BIt is swapped out the disk
- CIt is sent to the Dumpster
- DThe garbage collector makes the memory it occupies available for new objects
112157. What value is assigned to a reference value to show that there is no object?
- A0
- Bnull
- Cvoid
- D“”
- E0x00000
113158. Which one of the below shows the correct use of public to modify a method?
- APublic Void init()
- Bpublic class
- CMyProgram() void
- Dpublic init()
- Epublic int myMethod()
- Finit() public void
114Which statement is accurate for the use of void with a method?
- AThe void keyword means that the method will not return a value.
- BThe void keyword denotes a particular instance of the void class.
- C. The void method returns a void data type.
- DThe void keyword means that the statements in the method are not executed.
- EThis keyword voids the effects of a method.
115Which of the below shows the correct form of a method?
- Apublic int void goodBye() { code here }
- Bpublic void MyProgram() { code here}
- Cpublic voided hello() { code here }
- DintGoodBye();
- Eprivate int goodBye() {code here }
116. Which of the following is the closing brace for a block of statements in a method?
- A[
- B{
- C]
- D}
- E()
117If a class has one method in it, which of the following would be the last two symbols in the program?
- A{}
- B))
- C}}
- D)}
- E}{
118 Given the line, public class MyTextArea extends JTextArea {, which of the following statements is correct?
- AJTextArea is a subclass of MyTextArea.
- BMyTextArea is a superclass of the extends class
- CMyTextArea is a subclass of the JText class.
- DJTextArea is a superclass of MyTextArea.
- EJTextArea is a class of MyTextArea.
119164. What will be the output of the program?<br>

- A0 1 2
- B0 1 2 1 2 2
- C2 1 0 1 0 0
- D2 1 2 0 1 2
- E2 1 2 1 0 2
120165. What will be the output of the program?<br>
- AXyZabc
- BXyZABC
- Cxyzabc
- DabcXyZ
- Eabcxyz
121Which of the following will directly stop the execution of a Thread?
- Await()
- Bnotify()
- CnotifyAll()
- Dexits synchronized code
122. What allows the programmer to destroy an object x?
- Ax.delete();
- Bx.destroy();
- Cx.clean();
- DRuntime.getRuntime.gc(x);
- EOnly the garbage collection system can destroy the object
123169. Information hiding can also be termed as
- AData hiding
- BEncapsulation
- CInheritance
- DData minding
124Two or more functions with same name in the same class with different arguments is called as
- AMethod overriding
- BMethod overloading
- CEncapsulation
125When sub class declares a method that has the same type arguments as a method declared by one of its superclass it is termed as
- AMethod overriding
- BMethod overloading
- COperator overriding
- DOperator overloading
126What does closing file do?
- AFlushes pending output and finishes processing the file.
- BFinishes processing the file, only.
- CFlushes pending output, but the file may still be written to.
- DMakes the file read-only.
127What method ensures that data from previous calls to write() is sent to disk and leaves the file open?
- Aflush()
- Bclose()
- Cprint()
- Deach write() does this for the previous one.
128If a file opened for reading does not exist, which of the following events will occur in Java?
- AA NullPointerException will be rised
- BA run-time error will occur
- CA FileNotFoundException will be rised
- DA new file will be created
129. If a file opened for writing does not exist, which of the following events will occur in Java?
- AA NullPointerException will be rised
- BA run-time error will occur
- CA FileNotFoundException will be rised
- DA new file will be created
130If a class contains a constructor, that constructor will be invoked
- AEach time an object of that class is instantiated
- BEach time an object of that class goes out of scope
- COnce at the beginning of any program that uses that class
- DEach time a method of an object of that class is invoked
131In Java, the default layout manager for a JFrame component is
- A) GridLayout
- Bb) FlowLayout
- Cc) GridingLayout
- Dd) BorderLayout
132. Linked list cannot be implemented by using arrays
- Aa) true
- Bb) false
133Can stack be described as a pointer?
- Aa) true
- Bb) false
134What is the signature of the method specified in the Java ActionListener interface?
- Aa) void actionPerformed (ActionListener al)
- Bb) void actionEvent (ActionPerformed ap)
- Cc) void actionListener (ActionEvent ae)
- Dd) void actionPerformed (ActionEvent ae)
135181. How many String objects have been created?
String x = new String("xyz");
String y = "abc";
x = x + y;- Aa) 1
- Bb) 2
- Cc) 3
- Dd) 4
136Which of the following is a Java event that is generated when a JButton component is pressed?
- Aa) ButtonEvent
- Bb) WindowEvent
- Cc) ClickEvent
- Dd) ActionEvent
137183. Which one is true declaration?
final abstract class Test {}
public static interface Test {}
final public class Test {}
protected abstract class Test {}- A1
- B2
- C3
- D4
138184. What is the keyword in java used to create an instance?
- Athis
- Bobject
- Cnew
- Dnone of them
139You can create java project same as:
- Apublic class name
- BMain.java
- Cany name
- Dclass name
140Consider 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.- Aa) III
- Bb) I, II, and III
- Cc) I and III
- Dd) I and II
141What 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 {
}
}- ACompilation error at Line 8
- BCompilation error at Line 7
- CCompilation error at Line 6
- Dsuccessful compilation
142. 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);
}
}- AThe line of text "non-default" followed by the line of text "default"
- BThe line of text "default"
- CThe line of text "default" followed by the line of text "non-default"
- DThe line of text "non-default"
143The name of a Java source file.
- Ahas no restrictions
- Bmust be the same as the class it defines, respecting case
- Cmust be the same as the class it defines, ignoring case
- Dmust use the extension .class
144The ActionEvent class and ActionListener interface are available in the _____ package of Java.
- Ajavax.swing.event
- Bjava.awt.event
- Cjavax.event
- Djava.event
145If a class has an association with itself, then the class contains
- Aa) its own superclass
- Bb) an attribute that references an object of the same class
- Cc) a method that calls itself
- Dd) a method that calls another method within the same class
146What 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);
}
}- Aa) 100
- Bb) compilation error
- Cc) 100.1
- Dd) true
147In 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?
- Avoid windowClosing (WindowEvent we)
- Bvoid windowClosed (WindowEvent we)
- Cvoid windowDeactivated (WindowEvent we)
- D) void windowAdapter (WindowEvent we)
148Which of the following implementation will you use if you were to insert elements at any position in the collection ??
- Aa) Vector
- Bb) List
- Cc) LinkedList
- Dd) ArrayList
149An empty list is the one which has no
- Aa) data
- Bb) nodes
- Cc) a and b
- Dd)address
150JVM stands for
- AJava Verify Machine
- BJava Visual Machine
- CJava Visual Member
- DJava Virtual Machine
151Which of the following is not the method of object class?
- AtoString
- Bclone
- Cfinalize
- Dsystem
152Which of the following is True about final keyword
- Aa) We can declare abstract class as final.
- Bb) We can modify final variables.
- Cc) We can't declare a class abstract as well as final.
- Dd) We can override final methods.
153199. Which of the following is false about collections in Java ?
- Aa) List , Map and Set are interfaces.
- Bb) java.util is the default package for collection classes.
- Cc) Collection interface is the base interface.
- Dd) List , Map and Set are abstract classes
154Which of the following is not true for hashtable and hasmaps ?
- AHashtable are synchronized whereas hashmaps are not.
- BHashtable doesn't allow null values whereas HashMaps allows null values.
- CHashtable came before Hashmap
- DHashMaps are synchronized whereas hashtables are not.
155 Which of the following has member elements?
- AClass
- BInterface
- CBoth
- DNone
156Which of the following can be used for implementing runtime polymorphism ?
- AClass
- BInterface
- CBoth
- DNone
157Parent of all collection classes is a/an ….?
- AClass
- BInterface
- CBoth
- DNone
158Which exception is thrown by the read() method of InputStream class?
- AIOException
- BFileNotFoundException
- CReadException
- DException
159Which of the following methods can be used to remove a java.awt.Component object from the display?
- Aremove()
- Bdisappear()
- Chide()
- Ddelete()
160Which of the following sets the frame to 300 pixels wide by 200 high?
- Afrm.setSize( 300, 200 );
- Bfrm.setSize( 200, 300 );
- Cfrm.paint( 300, 200 );
- Dfrm.setVisible( 300, 200 );
161What is a Graphics object?
- AThe Graphics object represents the part of the Frame that you can draw on.
- BThe Graphics object represents the whole Frame
- CThe Graphics object represents the entire monitor.
- DThe Graphics object represents the graphics board.
162In Java, the default layout manager for a JFrame component is
- ABorderLayout
- BGridBagLayout
- CFlowLayout
- DGridLayout
163The ListSelectionEvent class and ListSelectionListener interface are available in the _____ package of Java.
- Ajava.awt.event
- Bjavax.swing.event
- Cjavax.event
- Djava.event
Information
- Description
- - SDP Quiz on sDP3 THEORY, created by Khadis Bektemir on 18/01/2017.
- Author
- Khadis Bektemir
- Language
- English
- Views
- 65
- History
- Created on 18 Jan 2017 · updated on 6 Apr 2018
- Tags
- Rating
- No ratings yet Rate this quiz