sdp200

Descrição

Quiz sobre sdp200, criado por Hello World em 18-01-2017.
Hello World
Quiz por Hello World, atualizado more than 1 year ago
Hello World
Criado por Hello World quase 8 anos atrás
733
1

Resumo de Recurso

Questão 1

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

Questão 2

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

Questão 3

Questão
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>}
Responda
  • 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

Questão 4

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

Questão 5

Questão
5. An array holds:
Responda
  • 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

Questão 6

Questão
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);
Responda
  • 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

Questão 7

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

Questão 8

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

Questão 9

Questão
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?
Responda
  • o java.util.Map
  • o java.util.Set
  • o java.util.Tree
  • o java.util.List
  • o java.util.Collection

Questão 10

Questão
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?
Responda
  • o public
  • o private
  • o protected
  • o transient
  • o volatile

Questão 11

Questão
11. Let’s assume that you have class C and interface I ? Which of the following is correct statement?
Responda
  • 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

Questão 12

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

Questão 13

Questão
13. Which statement is true?
Responda
  • 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

Questão 14

Questão
14. What will be the output of the program?<br>
Responda
  • o one two three four
  • o one two three four one
  • o four three two one
  • o four one three two

Questão 15

Questão
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?
Responda
  • o final
  • o public
  • o private
  • o protected
  • o static
  • o volatile

Questão 16

Questão
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.
Responda
  • o 1,2,4
  • o 2,3,5
  • o 3,4,5
  • o 1,2,3
  • o 1,3,5

Questão 17

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

Questão 18

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

Questão 19

Questão
19. Which is a valid declaration within an interface?
Responda
  • 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;

Questão 20

Questão
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?
Responda
  • o java.util.HashSet
  • o java.util.LinkedList
  • o java.util.ArrayList
  • o java.util.List
  • o java.util.TreeSet

Questão 21

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

Questão 22

Questão
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
Responda
  • o 1 and 2
  • o 2 and 3
  • o 3 and 4
  • o 1 and 4
  • o 2 and 4

Questão 23

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

Questão 24

Questão
24. What will be the output of the program? <br>
Responda
  • 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

Questão 25

Questão
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
Responda
  • o 1 and 2
  • o 2 and 3
  • o 3 and 4
  • o 4 and 5
  • o 1 and 4
  • o 2 and 5

Questão 26

Questão
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?
Responda
  • 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(){}}

Questão 27

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

Questão 28

Questão
28. Which interface does the java.util.Hashtable implement?
Responda
  • o java.util.Map
  • o java.util.Set
  • o java.util.Collection
  • o java.util.List
  • o java.util.HashTable

Questão 29

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

Questão 30

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

Questão 31

Questão
31. Which of the following statements is correct?
Responda
  • 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

Questão 32

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

Questão 33

Questão
33. Which statement is true for the Class java.util.HashSet?
Responda
  • 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

Questão 34

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

Questão 35

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

Questão 36

Questão
36. Static methods cannot be accessed directly from the class level
Responda
  • True
  • False

Questão 37

Questão
37. The process by which one object can acquire the properties of another object
Responda
  • o Encapsulation
  • o Inheritance
  • o Polymorphism

Questão 38

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

Questão 39

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

Questão 40

Questão
40. Is a program required to catch all exceptions that might happen?
Responda
  • 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

Questão 41

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

Questão 42

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

Questão 43

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

Questão 44

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

Questão 45

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

Questão 46

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

Questão 47

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

Questão 48

Questão
48. What is a buffer?
Responda
  • 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

Questão 49

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

Questão 50

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

Questão 51

Questão
51. A null reference may be used to access a static variable or method
Responda
  • True
  • False

Questão 52

Questão
52. Set allows at most two null elements?
Responda
  • True
  • False

Questão 53

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

Questão 54

Questão
54. A class cannot define more than one constructor
Responda
  • True
  • False

Questão 55

Questão
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?
Responda
  • o Queue
  • o Stack
  • o ArrayList
  • o LinkedList

Questão 56

Questão
56. In java one class can derive from one class?
Responda
  • True
  • False

Questão 57

Questão
57. Which of the following is not true for abstract classes?
Responda
  • 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

Questão 58

Questão
58. Which of the following is not true for static keyword?
Responda
  • 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

Questão 59

Questão
59. List is a/an …?
Responda
  • o Class
  • o Interface
  • o Both
  • o Package

Questão 60

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

Questão 61

Questão
61. Which is the Java keyword used to denote a class method?
Responda
  • o class
  • o final
  • o private
  • o static

Questão 62

Questão
62. What is Recursion in Java?
Responda
  • 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

Questão 63

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

Questão 64

Questão
64. What will be an output? <br>
Responda
  • o true true
  • o true false
  • o false true
  • o false false
  • o Runtime error will occur

Questão 65

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

Questão 66

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

Questão 67

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

Questão 68

Questão
68. Deletion is faster in LinkedList than ArrayList
Responda
  • True
  • False

Questão 69

Questão
69. Can a top level class be private?
Responda
  • True
  • False

Questão 70

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

Questão 71

Questão
71. The term wrapper class refers to
Responda
  • 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

Questão 72

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

Questão 73

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

Questão 74

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

Questão 75

Questão
75. What will be the output of the program? <br>
Responda
  • 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

Questão 76

Questão
76. What will be the output of the program? <br>
Responda
  • 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

Questão 77

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

Questão 78

Questão
78. Which of the following is not true about interfaces in java?
Responda
  • 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

Questão 79

Questão
79. Which of the following is not true about inheritance in java?
Responda
  • 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

Questão 80

Questão
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
Responda
  • 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

Questão 81

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

Questão 82

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

Questão 83

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

Questão 84

Questão
84. What will be the output of the program? <br>
Responda
  • 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

Questão 85

Questão
85. What will be the output of the program? <br>
Responda
  • 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)

Questão 86

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

Questão 87

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

Questão 88

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

Questão 89

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

Questão 90

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

Questão 91

Questão
91. What restriction is there on using a super reference in a constructor?
Responda
  • 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

Questão 92

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

Questão 93

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

Questão 94

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

Questão 95

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

Questão 96

Questão
96. Which of the followings is a type of stream in java?
Responda
  • o Integer stream
  • o Byte stream
  • o Short stream
  • o Long stream

Questão 97

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

Questão 98

Questão
98. What will be the output of the following code? <br>
Responda
  • 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

Questão 99

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

Questão 100

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

Questão 101

Questão
101. What will be the output of the program? <br>
Responda
  • 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

Questão 102

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

Questão 103

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

Questão 104

Questão
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?
Responda
  • o java.util.Map
  • o java.util.List
  • o java.util.Set
  • o java.util.Collection

Questão 105

Questão
105. Which interface does java.util.Hashtable implement?
Responda
  • o java.util.Map
  • o java.util.List
  • o java.util.HashTable
  • o java.util.Set
  • o java.util.Collection

Questão 106

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

Questão 107

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

Questão 108

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

Questão 109

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

Questão 110

Questão
110. What is an inheritance?
Responda
  • 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.

Questão 111

Questão
111. When constructor is called?
Responda
  • 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

Questão 112

Questão
112. What is the difference between a try-catch block and a try-catch-finally block?
Responda
  • 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

Questão 113

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

Questão 114

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

Questão 115

Questão
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>
Responda
  • o r
  • o n
  • o s
  • o a
  • o e

Questão 116

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

Questão 117

Questão
What is the purpose of a class constructor?
Responda
  • 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

Questão 118

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

Questão 119

Questão
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?
Responda
  • 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

Questão 120

Questão
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?
Responda
  • 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

Questão 121

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

Questão 122

Questão
121. What will be the output? <br>
Responda
  • 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

Questão 123

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

Questão 124

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

Questão 125

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

Questão 126

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

Questão 127

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

Questão 128

Questão
127. What will be the result of the following code segment? <br>
Responda
  • 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

Questão 129

Questão
128. What is the output of the following code segment?
Responda
  • o A
  • o B
  • o C
  • o D or lower

Questão 130

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

Questão 131

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

Questão 132

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

Questão 133

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

Questão 134

Questão
133. What is the size of short variable?
Responda
  • o 8 bit
  • o 16 bit
  • o 32 bit
  • o 64 bit

Questão 135

Questão
134. Which of the following is true about public access modifier?
Responda
  • 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

Questão 136

Questão
135. Which of the following is not a keyword in Java?
Responda
  • o static
  • o void
  • o Boolean
  • o private

Questão 137

Questão
136. Which of the following stands true about default modifier of class members?
Responda
  • 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

Questão 138

Questão
137. Inheritance represents
Responda
  • o HAS-A relationship
  • o IS-A relationship

Questão 139

Questão
138. What is function overloading?
Responda
  • 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

Questão 140

Questão
139. What is a class in java?
Responda
  • 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

Questão 141

Questão
140. Can be constructor be made private?
Responda
  • True
  • False

Questão 142

Questão
141. What is JRE?
Responda
  • 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

Questão 143

Questão
142. What is essential in making sure that your loop is not infinite?
Responda
  • 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

Questão 144

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

Questão 145

Questão
144. Abstract method can be in
Responda
  • o abstract class
  • o normal class
  • o concrete class
  • o any class

Questão 146

Questão
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
Responda
  • o Method overriding
  • o Method overloading
  • o Inheritance
  • o Encapsulation

Questão 147

Questão
146. Static variables cannot be accessed directly from the class level
Responda
  • True
  • False

Questão 148

Questão
147. When a class is based on another class, it inherits:
Responda
  • 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

Questão 149

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

Questão 150

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

Questão 151

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

Questão 152

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

Questão 153

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

Questão 154

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

Questão 155

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

Questão 156

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

Questão 157

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

Questão 158

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

Questão 159

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

Questão 160

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

Questão 161

Questão
161. Which of the following is the closing brace for a block of statements in a method?
Responda
  • [
  • {
  • ]
  • }
  • ()

Questão 162

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

Questão 163

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

Questão 164

Questão
164. What will be the output of the program?<br>
Responda
  • 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

Questão 165

Questão
165. What will be the output of the program?<br>
Responda
  • XyZabc
  • XyZABC
  • xyzabc
  • abcXyZ
  • abcxyz

Questão 166

Questão
166. Which of the following will directly stop the execution of a Thread?
Responda
  • wait()
  • notifyAll()
  • notify()
  • exits synchronized code

Questão 167

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

Questão 168

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

Questão 169

Questão
169. Information hiding can also be termed as
Responda
  • Data hiding
  • Encapsulation
  • Inheritance
  • Data minding

Questão 170

Questão
170. Two or more functions with same name in the same class with different arguments is called as
Responda
  • Method overriding
  • Method overloading
  • Encapsulation

Questão 171

Questão
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
Responda
  • Method overriding
  • Method overloading
  • Operator overriding
  • Operator overloading

Questão 172

Questão
172. What does closing file do?
Responda
  • 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

Questão 173

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

Questão 174

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

Questão 175

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

Questão 176

Questão
176. If a class contains a constructor, that constructor will be invoked
Responda
  • 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

Questão 177

Questão
177. In Java, the default layout manager for a JFrame component is
Responda
  • a) GridLayout
  • b) FlowLayout
  • c) GridingLayout
  • d) BorderLayout

Questão 178

Questão
178. Linked list cannot be implemented by using arrays
Responda
  • True
  • False

Questão 179

Questão
179. Can stack be described as a pointer?
Responda
  • True
  • False

Questão 180

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

Questão 181

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

Questão 182

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

Questão 183

Questão
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 {}
Responda
  • 1
  • 2
  • 3
  • 4

Questão 184

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

Questão 185

Questão
185. You can create java project same as:
Responda
  • a) public class name
  • c) any name
  • b) Main.java
  • d) class name

Questão 186

Questão
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.
Responda
  • a) III
  • b) I, II, and III
  • c) I and III
  • d) I and II

Questão 187

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

Questão 188

Questão
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); } }
Responda
  • 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"

Questão 189

Questão
189. The name of a Java source file.
Responda
  • 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

Questão 190

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

Questão 191

Questão
191. If a class has an association with itself, then the class contains
Responda
  • 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

Questão 192

Questão
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); } }
Responda
  • a) 100
  • c) 100.1
  • b) compilation error
  • d) true

Questão 193

Questão
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?
Responda
  • a) void windowClosing (WindowEvent we)
  • b) void windowClosed (WindowEvent we)
  • c) void windowDeactivated (WindowEvent we)
  • d) void windowAdapter (WindowEvent we)

Questão 194

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

Questão 195

Questão
195. An empty list is the one which has no
Responda
  • a) data
  • b) nodes
  • c) a and b
  • d)address

Questão 196

Questão
196. JVM stands for
Responda
  • a) Java Verify Machine
  • b) Java Visual Machine
  • d) Java Virtual Machine
  • c) Java Visual Member

Questão 197

Questão
197. Which of the following is not the method of object class?
Responda
  • a) toString
  • c) finalize
  • b) clone
  • d) system

Questão 198

Questão
198. Which of the following is True about final keyword
Responda
  • 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.

Questão 199

Questão
199. Which of the following is false about collections in Java ?
Responda
  • 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

Questão 200

Questão
200. Which of the following is not true for hashtable and hasmaps ?
Responda
  • 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.

Semelhante

Artigo Científico p/ TCC
Candido Gabriel
Estatuto
renathanjo2
LITERATURA: ROMANTISMO (INTRODUÇÃO)
jhonathannicolas
Vestibular - Regência Verbal
GoConqr suporte .
TEORIA SEXUAL FREUD
eleuterapara
Morfologia
Raíza Da Cunha
Tipos textuais
brunolorenzatto
Liderança
Liliane Tubino
Escala de Coma de Glasgow
Vanessa Palauro
Hipertensão Arterial Sistêmica - HAS
Katye dos Passos Rodrigues
Contextualização da Aula 2 - Tecnologia na Formação Profissional - SAÚDE
Fabrícia Assunção