SlideShare a Scribd company logo
1 of 9
Download to read offline
Question 1 To declare a class named A with a generic type, use a. public class A { ... } b. public
class A { ... } c. public class A(E) { ... } d. public class A(E, F) { ... } Select one: a. b. c. d.
Question 2 Answer saved Marked out of 1.00 Flag question Question text What does the
following code do? Action openAction = new AbstractAction( "Open..." ) { public void
actionPerformed( ActionEvent e ) { doOpen(); } }; JButton openButton = new JButton(
openAction ); JMenuItem openCommand = new JMenuItem( openAction ); Select one or more:
a. This code creates an Action that represents the opening of a file in the doOpen() instance
method. b. This code creates a button from the Action. c. This code creates a menu item from the
Action. d. This code reads a text file.
Question 3 Answer saved Marked out of 1.00 Flag question Question text Given the following
code: static void showOutput(int mark) { if (mark == 0) { System.out.print("*"); } else {
System.out.print("["); showOutput(mark - 1); System.out.print(","); showOutput(mark - 1);
System.out.println("]"); } } Can you determine what is produced by the following subroutine
calls: showOutput(0), showOutput(1), showOutput(2), and showOutput(3)? a. showOutput(0)
outputs: * showOutput(1) outputs: [*,*] showOutput(2) outputs: [[*,*],[*,*]] showOutput(3)
outputs: [[[*,*],[*,*]],[[*,*],[*,*]]] b. showOutput(0) outputs: [ showOutput(1) outputs: *,*
showOutput(2) outputs: [[],[]] showOutput(3) outputs: [[[*,*],[*,*]],[[*,*],[*,*]]] Select one: a.
b.
Question 4 Answer saved Marked out of 1.00 Flag question Question text A switch statement,
most often has the form: switch (expression) { case constant-1: statements-1 break; … } The
value of the expression can be: i. int ii. short iii. byte iv. Primitive char v. Enum vi. String vii.
Real number Select one: a. iii , iv and v b. i , ii, iii and iv c. All, except vi and vii d. vi and vii e.
All of the types listed
Question 5 Answer saved Marked out of 1.00 Flag question Question text Which of the
following statements are true? Select one or more: a. Recursive methods usually takes more
memory space than non-recursive methods. b. A recursive method can always be replaced by a
non-recursive method. c. In some cases, however, using recursion enables you to give a natural,
straightforward, simple solution to a program that would otherwise be difficult to solve. d.
Recursive methods run faster than non-recursive methods.
Question 6 Answer saved Marked out of 1.00 Flag question Question text Which of the
following are true? Select one or more: a. A stack can be viewed as a special type of list, where
the elements are accessed, inserted, and deleted only from the end, called the top, of the stack. b.
A queue represents a waiting list. A queue can be viewed as a special type of list, where the
elements are inserted into the end (tail) of the queue, and are accessed and deleted from the
beginning (head) of the queue. c. Since the insertion and deletion operations on a stack are made
only at the end of the stack, using an array list to implement a stack is more efficient than a
linked list. d. Since deletions are made at the beginning of the list, it is more efficient to
implement a queue using a linked list than an array list.
Question 7 Answer saved Marked out of 1.00 Flag question Question text Suppose the rule at the
office is that the workers who arrive later will leave earlier. Which data structure is appropriate
to store the workers? Select one: a. Stack b. Queue c. Array List d. Linked List
Question 8 Answer saved Marked out of 1.00 Flag question Question text To declare an interface
named A with two generic types, use a. public interface A { ... } b. public interface A { ... } c.
public interface A(E) { ... } d. public interface A(E, F) { ... } Select one: a. b. c. d.
Question 9 Not yet answered Marked out of 1.00 Flag question Question text To create a list to
store integers, use a. ArrayListlist = new ArrayList(); b. ArrayList list = new ArrayList(); c.
ArrayList list = new ArrayList(); d. ArrayList list = new ArrayList(); Select one: a. b. c. d.
Question 10 Answer saved Marked out of 1.00 Flag question Question text What is the printout
of the following code? List list = new ArrayList(); list.add("A"); list.add("B"); list.add("C");
list.add("D"); for (int i = 0; i < list.size(); i++) System.out.print(list.remove(i)); Select one: a.
ABCD b. AB c. AC d. AD e. ABC True or False: If 'currentCell' is in the middle of the list this
moveRight() method will perform its duties correctly. Select one: True False
Question 11 Answer saved Marked out of 1.00 Flag question Question text The server listens for
a connection request from a client using the following statement: Select one: a. Socket s = new
Socket(ServerName, port); b. Socket s = serverSocket.getSocket() c. Socket s = new
Socket(ServerName); d. Socket s = serverSocket.accept()
Question 12 Answer saved Marked out of 1.00 Flag question Question text Which of the
following code is correct to obtain hour from a Calendar object cal? Select one: a.
cal.get(Calendar.HOUR); b. cal.getHour(); c. cal.hour(); d. cal.get(Hour); Information Flag
question Information text The next two questions refer to this method: public void
switchMethod(String input){ switch(input){ case "apple": System.out.println("sauce"); break;
case "orange": System.out.println("julius"); case "banana": System.out.println("split");
break; case "pear": System.out.println("juice"); default: System.out.println(input); }
Question 13 Answer saved Marked out of 1.00 Flag question Question text What is the output to
System out after the following method call: switchMethod("orange"); Select one: a. sauce b.
julius c. split d. juice e. None of the Above
Question 14 Answer saved Marked out of 1.00 Flag question Question text What is the output to
System out after the following method call: switchMethod("strawberry"); Select one: a. sauce
b. julius c. juice d. strawberry e. None of the Above Information Flag question Information text
The next two questions refer to the following: 1 public int factorial(int number){ 2
if(number==1) { 3 return 1; 4 } else { 5 return number*(factorial(number-1)); 6 } 7 }
Question 15 Answer saved Marked out of 1.00 Flag question Question text On which line is the
base case for this recursive function? Select one: a. 1 b. 2 c. 4 d. 5 e. None of the Above
Question 16 Answer saved Marked out of 1.00 Flag question
Question text On which line is the recursive call for this recursive function? Select one: a. 1 b. 2
c. 4 d. 5 e. None of the Above Information Flag question Information text The next two
questions refer to the following: Cell class reference: public class Cell { public Cell(){ } public
char content; // The character in this cell. public Cell next; // Pointer to the cell to the right of this
one. public Cell prev; // Pointer to the cell to the left of this one. } The following method is
supposed to move one node to the right in a doubly linked list of Cells but it contains a flaw. The
global variable 'currentCell' is a pointer to a Cell in the list. 1 public void moveRight() { 2 if
(currentCell.next == null) { 3 Cell newCell = new Cell(); 4 newCell.content = ' '; 5
newCell.next = null; 6 newCell.prev = currentCell; 7 currentCell.next = newCell; 8 currentCell =
currentCell.next; 9 } 10 }
Question 17 Answer saved Marked out of 1.00 Flag question Question text True or False: If
'currentCell' is at the head of the list this moveRight() method will perform its duties correctly.
Select one: True False
Question 18 Answer saved Marked out of 1.00 Flag question Question text True or False: If
'currentCell' is in the middle of the list this moveRight() method will perform its duties
correctly. Select one: True False
Question 19 Not yet answered Marked out of 1.00 Flag question Question text Sample class
reference: public class Sample { private int number; private String color; public Sample(int
number) { this.number = number; this.color = "blue"; } @Override public boolean
equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return
false; } final Sample other = (Sample) obj; if ((this.color == null) ? (other.color != null) :
!this.color.equals(other.color)) { return false; } return true; } } Given the above code for the
Sample class what is the output of the following program: public static void main(String args[]){
List list = new ArrayList(); Sample sample1 = new Sample(1); Sample sample2 = new
Sample(2); list.add(sample1); Boolean contains; contains = list.contains(sample2);
System.out.println("Contains: " + contains); } Select one: a. Contains: true b. Contains: false c.
Contains: null
Question 20 Answer saved Marked out of 1.00 Flag question Question text True or False: A Set
is used to store objects in a particular order. Select one: True False
Question 21 Answer saved Marked out of 1.00 Flag question Question text True or False: The
following two statements will always yield the same value when a and b are Strings: 1)
a.equals(b); 2) a==b; Select one: True False
Question 22 Answer saved Marked out of 1.00 Flag question Question text Overloaded methods
must be differentiated by: Select one: a. method name b. data type of arguments c. method
signature d. None of the above
Question 23 Answer saved Marked out of 1.00 Flag question Question text True or False: An
Interface contains method declarations as well as implementations. Select one: True False
Question 24 Answer saved Marked out of 1.00 Flag question Question text True or False: A
class that implements an interface may only implement a few of that interface's method
declarations. Select one: True False
Question 25 Answer saved Marked out of 1.00 Flag question Question text For the following list:
int[] list = { 4, 8, 10, 6, 2, 8, 5 }; What would the list look like after one pass of the outer loop of
the bubble sort algorithm? Select one: a. { 2, 4, 5, 6, 8, 8, 10 } b. { 4, 8, 8, 6, 2, 10, 5 } c. { 4, 8,
6, 2, 8, 5, 10 } d. None of the above Question
26 Answer saved Marked out of 1.00 Flag question Question text True or False: Every 'try'
block must end with a 'finally' block. Select one: True False Question
27 Answer saved Marked out of 1.00 Flag question Question text If A and B are logical
expressions: !(A && B) is equivalent to: Select one: a. (A || B) b. (!A || !B) c. (!A && !B) d.
None of the above
Solution
Please follow the data and description :
1)
A generic class is defined as, class name { /* ... */ }
The type parameter section, delimited by angle brackets (<>), follows the class name. It
specifies the type parameters (also called type variables) T1, T2, ..., and Tn.
So the answer is OPTION C ( public class A(E) { ... } ).
2)
The class that we are writing has an instance method doOpen() (with no parameters) that is
meant to be used to open a file selected by the user. This creates an Action that represents the
action of opening a file.
So the answer is OPTION C (This code creates a menu item from the Action. ).
3)
The output for the code given is
showOutput(0) outputs: *
showOutput(1) outputs: [*,*]
showOutput(2) outputs: [[*,*],[*,*]]
showOutput(3) outputs: [[[*,*],[*,*]],[[*,*],[*,*]]]
So the answer is OPTION A (showOutput(0) outputs: * showOutput(1) outputs: [*,*]
showOutput(2) outputs: [[*,*],[*,*]] showOutput(3) outputs: [[[*,*],[*,*]],[[*,*],[*,*]]] ).
4)
The expression used in a switch statement must have an integral or enumerated type, or be of a
class type in which the class has a single conversion function to an integral or enumerated type.
So the answer is OPTION E (All of the types listed).
5)
a. Recursive methods usually takes more memory space than non-recursive methods.
b. A recursive method can always be replaced by a non-recursive method.
c. In some cases, however, using recursion enables you to give a natural, straightforward, simple
solution to a program that would otherwise be difficult to solve.
d. Recursive methods run faster than non-recursive methods.
All the answers are true in case of a recursion.
6)
a. A stack can be viewed as a special type of list, where the elements are accessed, inserted, and
deleted only from the end, called the top, of the stack.
b. A queue represents a waiting list. A queue can be viewed as a special type of list, where the
elements are inserted into the end (tail) of the queue, and are accessed and deleted from the
beginning (head) of the queue.
c. Since the insertion and deletion operations on a stack are made only at the end of the stack,
using an array list to implement a stack is more efficient than a linked list.
d. Since deletions are made at the beginning of the list, it is more efficient to implement a queue
using a linked list than an array list.
All the answers are true in case of a queue and a stack.
7)
Stack : a stack is a collection of objects in which objects are accessed in LIFO (Last In First Out)
fashion.
So the answer is OPTION A (Stack).
8)
public interface A(E, F) { ... } is an interface with a two generic types.
So the answer is OPTION D (public interface A(E, F) { ... } ).
9)
To declare a list of integer type we can write the line as ArrayList list = new ArrayList();
So the answer is OPTION C (ArrayList list = new ArrayList();).
10)
CODE :
public static void main(String[] args) {
List list = new ArrayList();
list.add("A");
list.add("B");
list.add("C");
list.add("D");
for (int i = 0; i < list.size(); i++) {
System.out.print(list.remove(i));
}
}
OUTPUT :
AC
So the answer is OPTION C (AC).
If 'currentCell' is in the middle of the list this moveRight() method will perform its duties
correctly it is true.
11)
The server listens for a connection request from a client using the following statement
Socket s = serverSocket.accept();
So the answer is OPTION D (Socket s = serverSocket.accept());
12)
The following code is correct to obtain hour from a Calendar object cal :
cal.get(Calendar.HOUR);
So the answer is OPTION A (cal.get(Calendar.HOUR););
13)
For the given the code the output for the call switchMethod("orange"); is given by julius.
So the answer is OPTION B (julius).
14)
For the given the code the output for the call switchMethod("strawberry"); is given by
strawberry.
So the answer is OPTION D (strawberry).
15)
1 public int factorial(int number){
2 if(number==1) {
3 return 1;
4 } else {
5 return number*(factorial(number-1));
6 }
7 }
The base case for the recursive function for the given code is in the line 5. So the answer is
OPTION D (5);
16)
The call for the recursive function for the given code is in the line 5. So the answer is OPTION D
(5);
17)
If 'currentCell' is at the head of the list this moveRight() method will perform its duties
correctly. It is True. So the answer is OPTION A (True).
18)
If 'currentCell' is in the middle of the list this moveRight() method will perform its duties
correctly. It is True. So the answer is OPTION A (True).
19)
CODE :
public class Sample {
private int number;
private String color;
public Sample(int number) {
this.number = number;
this.color = "blue";
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Sample other = (Sample) obj;
if ((this.color == null) ? (other.color != null) : !this.color.equals(other.color)) {
return false;
}
return true;
}
public static void main(String args[]) {
List list = new ArrayList();
Sample sample1 = new Sample(1);
Sample sample2 = new Sample(2);
list.add(sample1);
Boolean contains;
contains = list.contains(sample2);
System.out.println("Contains: " + contains);
}
}
OUTPUT :
Contains: true
So the answer is OPTION A (Contains: true).
20)
A Set is used to store objects in a particular order.
It is True.
So the answer is OPTION A (True).
21)
The two statements will always yield the same value when a and b are Strings: 1) a.equals(b); 2)
a==b; It is True.
So the answer is OPTION A (True).
22)
If a class have multiple methods by same name but different parameters, it is known as Method
Overloading.
There are two ways to overload the method in java
By changing number of arguments
By changing the data type
So the answer is OPTION B (data type of arguments).
23)
Interfaces are declared using the interface keyword, and may only contain method signature and
constant declarations (variable declarations that are declared to be both static and final ). All
methods of an Interface do not contain implementation (method bodies).
So the answer is OPTION B (False).
24)
A class that implements an interface may only implement a few of that interface's method
declarations. No this is False.
So the answer is OPTION B (False).
25)
The output for the list = { 4, 8, 10, 6, 2, 8, 5 }; after the outer loop is {4, 8, 6, 10, 2, 5, 8}
So the answer is OPTION D (None of the Above).
26)
Every 'try' block must end with a 'finally' block. Not necessarily in evry case but could be also
a catch block of statement. So the answer is OPTION B (False).
27)
!(A && B) is equivalent to (!A || !B)
So the answer is OPTION B ((!A || !B) ).
Hope this is helpful.

More Related Content

Similar to Java Class Questions Multiple Choice Quiz

Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Udayan Khattry
 
Question đúng cnu
Question đúng cnuQuestion đúng cnu
Question đúng cnuPhamHoc
 
Quiz1 tonghop
 Quiz1 tonghop Quiz1 tonghop
Quiz1 tonghopDaewoo Han
 
Computer programming mcqs
Computer programming mcqsComputer programming mcqs
Computer programming mcqssaadkhan672
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guidekrtioplal
 
1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer iiIsabella789
 
Conceitos Fundamentais de Orientação a Objetos
Conceitos Fundamentais de Orientação a ObjetosConceitos Fundamentais de Orientação a Objetos
Conceitos Fundamentais de Orientação a Objetosguest22a621
 
Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docxrosemarybdodson23141
 
Indus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersIndus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersSushant Choudhary
 
Redo midterm
Redo midtermRedo midterm
Redo midtermIIUM
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomeshpraveensomesh
 
Examf cs-cs141-2-17
Examf cs-cs141-2-17Examf cs-cs141-2-17
Examf cs-cs141-2-17Fahadaio
 
ExamName___________________________________MULTIPLE CH.docx
ExamName___________________________________MULTIPLE CH.docxExamName___________________________________MULTIPLE CH.docx
ExamName___________________________________MULTIPLE CH.docxgitagrimston
 

Similar to Java Class Questions Multiple Choice Quiz (20)

Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...
 
1z0 808[1]
1z0 808[1]1z0 808[1]
1z0 808[1]
 
Question đúng cnu
Question đúng cnuQuestion đúng cnu
Question đúng cnu
 
Quiz1 tonghop
 Quiz1 tonghop Quiz1 tonghop
Quiz1 tonghop
 
Computer programming mcqs
Computer programming mcqsComputer programming mcqs
Computer programming mcqs
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Comp 328 final guide
Comp 328 final guideComp 328 final guide
Comp 328 final guide
 
1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii1z0 804 exam-java se 7 programmer ii
1z0 804 exam-java se 7 programmer ii
 
Questões de Certificação SCJP
Questões de Certificação SCJPQuestões de Certificação SCJP
Questões de Certificação SCJP
 
Conceitos Fundamentais de Orientação a Objetos
Conceitos Fundamentais de Orientação a ObjetosConceitos Fundamentais de Orientação a Objetos
Conceitos Fundamentais de Orientação a Objetos
 
Java concurrency questions and answers
Java concurrency questions and answers Java concurrency questions and answers
Java concurrency questions and answers
 
Name _______________________________ Class time __________.docx
Name _______________________________    Class time __________.docxName _______________________________    Class time __________.docx
Name _______________________________ Class time __________.docx
 
Indus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answersIndus Valley Partner aptitude questions and answers
Indus Valley Partner aptitude questions and answers
 
Redo midterm
Redo midtermRedo midterm
Redo midterm
 
important C questions and_answers praveensomesh
important C questions and_answers praveensomeshimportant C questions and_answers praveensomesh
important C questions and_answers praveensomesh
 
Examf cs-cs141-2-17
Examf cs-cs141-2-17Examf cs-cs141-2-17
Examf cs-cs141-2-17
 
T1
T1T1
T1
 
Part - 2 Cpp programming Solved MCQ
Part - 2  Cpp programming Solved MCQ Part - 2  Cpp programming Solved MCQ
Part - 2 Cpp programming Solved MCQ
 
C++ questions
C++ questionsC++ questions
C++ questions
 
ExamName___________________________________MULTIPLE CH.docx
ExamName___________________________________MULTIPLE CH.docxExamName___________________________________MULTIPLE CH.docx
ExamName___________________________________MULTIPLE CH.docx
 

More from dbrienmhompsonkath75

Give examples of system which can achieve some security requirement.pdf
Give examples of system which can achieve some security requirement.pdfGive examples of system which can achieve some security requirement.pdf
Give examples of system which can achieve some security requirement.pdfdbrienmhompsonkath75
 
Help me with these questions please.1. Name four characteristics t.pdf
Help me with these questions please.1. Name four characteristics t.pdfHelp me with these questions please.1. Name four characteristics t.pdf
Help me with these questions please.1. Name four characteristics t.pdfdbrienmhompsonkath75
 
Describe current and emerging roles of the patient record in HIT toda.pdf
Describe current and emerging roles of the patient record in HIT toda.pdfDescribe current and emerging roles of the patient record in HIT toda.pdf
Describe current and emerging roles of the patient record in HIT toda.pdfdbrienmhompsonkath75
 
Dont change the templates, and just fill out the TODO parts on .pdf
Dont change the templates, and just fill out the  TODO parts on .pdfDont change the templates, and just fill out the  TODO parts on .pdf
Dont change the templates, and just fill out the TODO parts on .pdfdbrienmhompsonkath75
 
Directions Problem 1. A female with Muppetrus bristle mates with a .pdf
Directions Problem 1. A female with Muppetrus bristle mates with a .pdfDirections Problem 1. A female with Muppetrus bristle mates with a .pdf
Directions Problem 1. A female with Muppetrus bristle mates with a .pdfdbrienmhompsonkath75
 
Describe the roll of each of the following in membrane transport a.pdf
Describe the roll of each of the following in membrane transport a.pdfDescribe the roll of each of the following in membrane transport a.pdf
Describe the roll of each of the following in membrane transport a.pdfdbrienmhompsonkath75
 
Compare and contrast transactional and transformational leadership.pdf
Compare and contrast transactional and transformational leadership.pdfCompare and contrast transactional and transformational leadership.pdf
Compare and contrast transactional and transformational leadership.pdfdbrienmhompsonkath75
 
Calculator Which of the following is not an asset Oa, owners equi.pdf
Calculator Which of the following is not an asset Oa, owners equi.pdfCalculator Which of the following is not an asset Oa, owners equi.pdf
Calculator Which of the following is not an asset Oa, owners equi.pdfdbrienmhompsonkath75
 
You are installing a KVM switch for a small business customer so tha.pdf
You are installing a KVM switch for a small business customer so tha.pdfYou are installing a KVM switch for a small business customer so tha.pdf
You are installing a KVM switch for a small business customer so tha.pdfdbrienmhompsonkath75
 
Why is metabolism important for physiological processesSolution.pdf
Why is metabolism important for physiological processesSolution.pdfWhy is metabolism important for physiological processesSolution.pdf
Why is metabolism important for physiological processesSolution.pdfdbrienmhompsonkath75
 
Which macromolecule is primarily responsible for producing the pheno.pdf
Which macromolecule is primarily responsible for producing the pheno.pdfWhich macromolecule is primarily responsible for producing the pheno.pdf
Which macromolecule is primarily responsible for producing the pheno.pdfdbrienmhompsonkath75
 
which invertebrate phylum is considered the most evolutionarily succe.pdf
which invertebrate phylum is considered the most evolutionarily succe.pdfwhich invertebrate phylum is considered the most evolutionarily succe.pdf
which invertebrate phylum is considered the most evolutionarily succe.pdfdbrienmhompsonkath75
 
What suggestions would you offer to parents and teachers who want to.pdf
What suggestions would you offer to parents and teachers who want to.pdfWhat suggestions would you offer to parents and teachers who want to.pdf
What suggestions would you offer to parents and teachers who want to.pdfdbrienmhompsonkath75
 
What is the F2 generation when the F1 generation of +++y cv f is cr.pdf
What is the F2 generation when the F1 generation of +++y cv f is cr.pdfWhat is the F2 generation when the F1 generation of +++y cv f is cr.pdf
What is the F2 generation when the F1 generation of +++y cv f is cr.pdfdbrienmhompsonkath75
 
What features on the plasmid allows it to replicate independent o.pdf
What features on the plasmid allows it to replicate independent o.pdfWhat features on the plasmid allows it to replicate independent o.pdf
What features on the plasmid allows it to replicate independent o.pdfdbrienmhompsonkath75
 
What are the use of Fibonacci numbers or the Golden Ratio in nature,.pdf
What are the use of Fibonacci numbers or the Golden Ratio in nature,.pdfWhat are the use of Fibonacci numbers or the Golden Ratio in nature,.pdf
What are the use of Fibonacci numbers or the Golden Ratio in nature,.pdfdbrienmhompsonkath75
 
Based on the following schematic with 3 D flip-flops, Write complete .pdf
Based on the following schematic with 3 D flip-flops, Write complete .pdfBased on the following schematic with 3 D flip-flops, Write complete .pdf
Based on the following schematic with 3 D flip-flops, Write complete .pdfdbrienmhompsonkath75
 
Although O_2 does not participate directly in the reactions of the TC.pdf
Although O_2 does not participate directly in the reactions of the TC.pdfAlthough O_2 does not participate directly in the reactions of the TC.pdf
Although O_2 does not participate directly in the reactions of the TC.pdfdbrienmhompsonkath75
 
8. Which of the following is NOT a transcriptionally repressed genom.pdf
8. Which of the following is NOT a transcriptionally repressed genom.pdf8. Which of the following is NOT a transcriptionally repressed genom.pdf
8. Which of the following is NOT a transcriptionally repressed genom.pdfdbrienmhompsonkath75
 
49. Autonomic nervous system function is influenced by A) cerebral co.pdf
49. Autonomic nervous system function is influenced by A) cerebral co.pdf49. Autonomic nervous system function is influenced by A) cerebral co.pdf
49. Autonomic nervous system function is influenced by A) cerebral co.pdfdbrienmhompsonkath75
 

More from dbrienmhompsonkath75 (20)

Give examples of system which can achieve some security requirement.pdf
Give examples of system which can achieve some security requirement.pdfGive examples of system which can achieve some security requirement.pdf
Give examples of system which can achieve some security requirement.pdf
 
Help me with these questions please.1. Name four characteristics t.pdf
Help me with these questions please.1. Name four characteristics t.pdfHelp me with these questions please.1. Name four characteristics t.pdf
Help me with these questions please.1. Name four characteristics t.pdf
 
Describe current and emerging roles of the patient record in HIT toda.pdf
Describe current and emerging roles of the patient record in HIT toda.pdfDescribe current and emerging roles of the patient record in HIT toda.pdf
Describe current and emerging roles of the patient record in HIT toda.pdf
 
Dont change the templates, and just fill out the TODO parts on .pdf
Dont change the templates, and just fill out the  TODO parts on .pdfDont change the templates, and just fill out the  TODO parts on .pdf
Dont change the templates, and just fill out the TODO parts on .pdf
 
Directions Problem 1. A female with Muppetrus bristle mates with a .pdf
Directions Problem 1. A female with Muppetrus bristle mates with a .pdfDirections Problem 1. A female with Muppetrus bristle mates with a .pdf
Directions Problem 1. A female with Muppetrus bristle mates with a .pdf
 
Describe the roll of each of the following in membrane transport a.pdf
Describe the roll of each of the following in membrane transport a.pdfDescribe the roll of each of the following in membrane transport a.pdf
Describe the roll of each of the following in membrane transport a.pdf
 
Compare and contrast transactional and transformational leadership.pdf
Compare and contrast transactional and transformational leadership.pdfCompare and contrast transactional and transformational leadership.pdf
Compare and contrast transactional and transformational leadership.pdf
 
Calculator Which of the following is not an asset Oa, owners equi.pdf
Calculator Which of the following is not an asset Oa, owners equi.pdfCalculator Which of the following is not an asset Oa, owners equi.pdf
Calculator Which of the following is not an asset Oa, owners equi.pdf
 
You are installing a KVM switch for a small business customer so tha.pdf
You are installing a KVM switch for a small business customer so tha.pdfYou are installing a KVM switch for a small business customer so tha.pdf
You are installing a KVM switch for a small business customer so tha.pdf
 
Why is metabolism important for physiological processesSolution.pdf
Why is metabolism important for physiological processesSolution.pdfWhy is metabolism important for physiological processesSolution.pdf
Why is metabolism important for physiological processesSolution.pdf
 
Which macromolecule is primarily responsible for producing the pheno.pdf
Which macromolecule is primarily responsible for producing the pheno.pdfWhich macromolecule is primarily responsible for producing the pheno.pdf
Which macromolecule is primarily responsible for producing the pheno.pdf
 
which invertebrate phylum is considered the most evolutionarily succe.pdf
which invertebrate phylum is considered the most evolutionarily succe.pdfwhich invertebrate phylum is considered the most evolutionarily succe.pdf
which invertebrate phylum is considered the most evolutionarily succe.pdf
 
What suggestions would you offer to parents and teachers who want to.pdf
What suggestions would you offer to parents and teachers who want to.pdfWhat suggestions would you offer to parents and teachers who want to.pdf
What suggestions would you offer to parents and teachers who want to.pdf
 
What is the F2 generation when the F1 generation of +++y cv f is cr.pdf
What is the F2 generation when the F1 generation of +++y cv f is cr.pdfWhat is the F2 generation when the F1 generation of +++y cv f is cr.pdf
What is the F2 generation when the F1 generation of +++y cv f is cr.pdf
 
What features on the plasmid allows it to replicate independent o.pdf
What features on the plasmid allows it to replicate independent o.pdfWhat features on the plasmid allows it to replicate independent o.pdf
What features on the plasmid allows it to replicate independent o.pdf
 
What are the use of Fibonacci numbers or the Golden Ratio in nature,.pdf
What are the use of Fibonacci numbers or the Golden Ratio in nature,.pdfWhat are the use of Fibonacci numbers or the Golden Ratio in nature,.pdf
What are the use of Fibonacci numbers or the Golden Ratio in nature,.pdf
 
Based on the following schematic with 3 D flip-flops, Write complete .pdf
Based on the following schematic with 3 D flip-flops, Write complete .pdfBased on the following schematic with 3 D flip-flops, Write complete .pdf
Based on the following schematic with 3 D flip-flops, Write complete .pdf
 
Although O_2 does not participate directly in the reactions of the TC.pdf
Although O_2 does not participate directly in the reactions of the TC.pdfAlthough O_2 does not participate directly in the reactions of the TC.pdf
Although O_2 does not participate directly in the reactions of the TC.pdf
 
8. Which of the following is NOT a transcriptionally repressed genom.pdf
8. Which of the following is NOT a transcriptionally repressed genom.pdf8. Which of the following is NOT a transcriptionally repressed genom.pdf
8. Which of the following is NOT a transcriptionally repressed genom.pdf
 
49. Autonomic nervous system function is influenced by A) cerebral co.pdf
49. Autonomic nervous system function is influenced by A) cerebral co.pdf49. Autonomic nervous system function is influenced by A) cerebral co.pdf
49. Autonomic nervous system function is influenced by A) cerebral co.pdf
 

Recently uploaded

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 

Recently uploaded (20)

How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 

Java Class Questions Multiple Choice Quiz

  • 1. Question 1 To declare a class named A with a generic type, use a. public class A { ... } b. public class A { ... } c. public class A(E) { ... } d. public class A(E, F) { ... } Select one: a. b. c. d. Question 2 Answer saved Marked out of 1.00 Flag question Question text What does the following code do? Action openAction = new AbstractAction( "Open..." ) { public void actionPerformed( ActionEvent e ) { doOpen(); } }; JButton openButton = new JButton( openAction ); JMenuItem openCommand = new JMenuItem( openAction ); Select one or more: a. This code creates an Action that represents the opening of a file in the doOpen() instance method. b. This code creates a button from the Action. c. This code creates a menu item from the Action. d. This code reads a text file. Question 3 Answer saved Marked out of 1.00 Flag question Question text Given the following code: static void showOutput(int mark) { if (mark == 0) { System.out.print("*"); } else { System.out.print("["); showOutput(mark - 1); System.out.print(","); showOutput(mark - 1); System.out.println("]"); } } Can you determine what is produced by the following subroutine calls: showOutput(0), showOutput(1), showOutput(2), and showOutput(3)? a. showOutput(0) outputs: * showOutput(1) outputs: [*,*] showOutput(2) outputs: [[*,*],[*,*]] showOutput(3) outputs: [[[*,*],[*,*]],[[*,*],[*,*]]] b. showOutput(0) outputs: [ showOutput(1) outputs: *,* showOutput(2) outputs: [[],[]] showOutput(3) outputs: [[[*,*],[*,*]],[[*,*],[*,*]]] Select one: a. b. Question 4 Answer saved Marked out of 1.00 Flag question Question text A switch statement, most often has the form: switch (expression) { case constant-1: statements-1 break; … } The value of the expression can be: i. int ii. short iii. byte iv. Primitive char v. Enum vi. String vii. Real number Select one: a. iii , iv and v b. i , ii, iii and iv c. All, except vi and vii d. vi and vii e. All of the types listed Question 5 Answer saved Marked out of 1.00 Flag question Question text Which of the following statements are true? Select one or more: a. Recursive methods usually takes more memory space than non-recursive methods. b. A recursive method can always be replaced by a non-recursive method. c. In some cases, however, using recursion enables you to give a natural, straightforward, simple solution to a program that would otherwise be difficult to solve. d. Recursive methods run faster than non-recursive methods. Question 6 Answer saved Marked out of 1.00 Flag question Question text Which of the following are true? Select one or more: a. A stack can be viewed as a special type of list, where the elements are accessed, inserted, and deleted only from the end, called the top, of the stack. b. A queue represents a waiting list. A queue can be viewed as a special type of list, where the elements are inserted into the end (tail) of the queue, and are accessed and deleted from the beginning (head) of the queue. c. Since the insertion and deletion operations on a stack are made
  • 2. only at the end of the stack, using an array list to implement a stack is more efficient than a linked list. d. Since deletions are made at the beginning of the list, it is more efficient to implement a queue using a linked list than an array list. Question 7 Answer saved Marked out of 1.00 Flag question Question text Suppose the rule at the office is that the workers who arrive later will leave earlier. Which data structure is appropriate to store the workers? Select one: a. Stack b. Queue c. Array List d. Linked List Question 8 Answer saved Marked out of 1.00 Flag question Question text To declare an interface named A with two generic types, use a. public interface A { ... } b. public interface A { ... } c. public interface A(E) { ... } d. public interface A(E, F) { ... } Select one: a. b. c. d. Question 9 Not yet answered Marked out of 1.00 Flag question Question text To create a list to store integers, use a. ArrayListlist = new ArrayList(); b. ArrayList list = new ArrayList(); c. ArrayList list = new ArrayList(); d. ArrayList list = new ArrayList(); Select one: a. b. c. d. Question 10 Answer saved Marked out of 1.00 Flag question Question text What is the printout of the following code? List list = new ArrayList(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); for (int i = 0; i < list.size(); i++) System.out.print(list.remove(i)); Select one: a. ABCD b. AB c. AC d. AD e. ABC True or False: If 'currentCell' is in the middle of the list this moveRight() method will perform its duties correctly. Select one: True False Question 11 Answer saved Marked out of 1.00 Flag question Question text The server listens for a connection request from a client using the following statement: Select one: a. Socket s = new Socket(ServerName, port); b. Socket s = serverSocket.getSocket() c. Socket s = new Socket(ServerName); d. Socket s = serverSocket.accept() Question 12 Answer saved Marked out of 1.00 Flag question Question text Which of the following code is correct to obtain hour from a Calendar object cal? Select one: a. cal.get(Calendar.HOUR); b. cal.getHour(); c. cal.hour(); d. cal.get(Hour); Information Flag question Information text The next two questions refer to this method: public void switchMethod(String input){ switch(input){ case "apple": System.out.println("sauce"); break; case "orange": System.out.println("julius"); case "banana": System.out.println("split"); break; case "pear": System.out.println("juice"); default: System.out.println(input); } Question 13 Answer saved Marked out of 1.00 Flag question Question text What is the output to System out after the following method call: switchMethod("orange"); Select one: a. sauce b. julius c. split d. juice e. None of the Above Question 14 Answer saved Marked out of 1.00 Flag question Question text What is the output to System out after the following method call: switchMethod("strawberry"); Select one: a. sauce b. julius c. juice d. strawberry e. None of the Above Information Flag question Information text The next two questions refer to the following: 1 public int factorial(int number){ 2 if(number==1) { 3 return 1; 4 } else { 5 return number*(factorial(number-1)); 6 } 7 }
  • 3. Question 15 Answer saved Marked out of 1.00 Flag question Question text On which line is the base case for this recursive function? Select one: a. 1 b. 2 c. 4 d. 5 e. None of the Above Question 16 Answer saved Marked out of 1.00 Flag question Question text On which line is the recursive call for this recursive function? Select one: a. 1 b. 2 c. 4 d. 5 e. None of the Above Information Flag question Information text The next two questions refer to the following: Cell class reference: public class Cell { public Cell(){ } public char content; // The character in this cell. public Cell next; // Pointer to the cell to the right of this one. public Cell prev; // Pointer to the cell to the left of this one. } The following method is supposed to move one node to the right in a doubly linked list of Cells but it contains a flaw. The global variable 'currentCell' is a pointer to a Cell in the list. 1 public void moveRight() { 2 if (currentCell.next == null) { 3 Cell newCell = new Cell(); 4 newCell.content = ' '; 5 newCell.next = null; 6 newCell.prev = currentCell; 7 currentCell.next = newCell; 8 currentCell = currentCell.next; 9 } 10 } Question 17 Answer saved Marked out of 1.00 Flag question Question text True or False: If 'currentCell' is at the head of the list this moveRight() method will perform its duties correctly. Select one: True False Question 18 Answer saved Marked out of 1.00 Flag question Question text True or False: If 'currentCell' is in the middle of the list this moveRight() method will perform its duties correctly. Select one: True False Question 19 Not yet answered Marked out of 1.00 Flag question Question text Sample class reference: public class Sample { private int number; private String color; public Sample(int number) { this.number = number; this.color = "blue"; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Sample other = (Sample) obj; if ((this.color == null) ? (other.color != null) : !this.color.equals(other.color)) { return false; } return true; } } Given the above code for the Sample class what is the output of the following program: public static void main(String args[]){ List list = new ArrayList(); Sample sample1 = new Sample(1); Sample sample2 = new Sample(2); list.add(sample1); Boolean contains; contains = list.contains(sample2); System.out.println("Contains: " + contains); } Select one: a. Contains: true b. Contains: false c. Contains: null Question 20 Answer saved Marked out of 1.00 Flag question Question text True or False: A Set is used to store objects in a particular order. Select one: True False Question 21 Answer saved Marked out of 1.00 Flag question Question text True or False: The following two statements will always yield the same value when a and b are Strings: 1) a.equals(b); 2) a==b; Select one: True False Question 22 Answer saved Marked out of 1.00 Flag question Question text Overloaded methods
  • 4. must be differentiated by: Select one: a. method name b. data type of arguments c. method signature d. None of the above Question 23 Answer saved Marked out of 1.00 Flag question Question text True or False: An Interface contains method declarations as well as implementations. Select one: True False Question 24 Answer saved Marked out of 1.00 Flag question Question text True or False: A class that implements an interface may only implement a few of that interface's method declarations. Select one: True False Question 25 Answer saved Marked out of 1.00 Flag question Question text For the following list: int[] list = { 4, 8, 10, 6, 2, 8, 5 }; What would the list look like after one pass of the outer loop of the bubble sort algorithm? Select one: a. { 2, 4, 5, 6, 8, 8, 10 } b. { 4, 8, 8, 6, 2, 10, 5 } c. { 4, 8, 6, 2, 8, 5, 10 } d. None of the above Question 26 Answer saved Marked out of 1.00 Flag question Question text True or False: Every 'try' block must end with a 'finally' block. Select one: True False Question 27 Answer saved Marked out of 1.00 Flag question Question text If A and B are logical expressions: !(A && B) is equivalent to: Select one: a. (A || B) b. (!A || !B) c. (!A && !B) d. None of the above Solution Please follow the data and description : 1) A generic class is defined as, class name { /* ... */ } The type parameter section, delimited by angle brackets (<>), follows the class name. It specifies the type parameters (also called type variables) T1, T2, ..., and Tn. So the answer is OPTION C ( public class A(E) { ... } ). 2) The class that we are writing has an instance method doOpen() (with no parameters) that is meant to be used to open a file selected by the user. This creates an Action that represents the action of opening a file. So the answer is OPTION C (This code creates a menu item from the Action. ). 3) The output for the code given is showOutput(0) outputs: * showOutput(1) outputs: [*,*] showOutput(2) outputs: [[*,*],[*,*]] showOutput(3) outputs: [[[*,*],[*,*]],[[*,*],[*,*]]]
  • 5. So the answer is OPTION A (showOutput(0) outputs: * showOutput(1) outputs: [*,*] showOutput(2) outputs: [[*,*],[*,*]] showOutput(3) outputs: [[[*,*],[*,*]],[[*,*],[*,*]]] ). 4) The expression used in a switch statement must have an integral or enumerated type, or be of a class type in which the class has a single conversion function to an integral or enumerated type. So the answer is OPTION E (All of the types listed). 5) a. Recursive methods usually takes more memory space than non-recursive methods. b. A recursive method can always be replaced by a non-recursive method. c. In some cases, however, using recursion enables you to give a natural, straightforward, simple solution to a program that would otherwise be difficult to solve. d. Recursive methods run faster than non-recursive methods. All the answers are true in case of a recursion. 6) a. A stack can be viewed as a special type of list, where the elements are accessed, inserted, and deleted only from the end, called the top, of the stack. b. A queue represents a waiting list. A queue can be viewed as a special type of list, where the elements are inserted into the end (tail) of the queue, and are accessed and deleted from the beginning (head) of the queue. c. Since the insertion and deletion operations on a stack are made only at the end of the stack, using an array list to implement a stack is more efficient than a linked list. d. Since deletions are made at the beginning of the list, it is more efficient to implement a queue using a linked list than an array list. All the answers are true in case of a queue and a stack. 7) Stack : a stack is a collection of objects in which objects are accessed in LIFO (Last In First Out) fashion. So the answer is OPTION A (Stack). 8) public interface A(E, F) { ... } is an interface with a two generic types. So the answer is OPTION D (public interface A(E, F) { ... } ). 9) To declare a list of integer type we can write the line as ArrayList list = new ArrayList(); So the answer is OPTION C (ArrayList list = new ArrayList();).
  • 6. 10) CODE : public static void main(String[] args) { List list = new ArrayList(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); for (int i = 0; i < list.size(); i++) { System.out.print(list.remove(i)); } } OUTPUT : AC So the answer is OPTION C (AC). If 'currentCell' is in the middle of the list this moveRight() method will perform its duties correctly it is true. 11) The server listens for a connection request from a client using the following statement Socket s = serverSocket.accept(); So the answer is OPTION D (Socket s = serverSocket.accept()); 12) The following code is correct to obtain hour from a Calendar object cal : cal.get(Calendar.HOUR); So the answer is OPTION A (cal.get(Calendar.HOUR);); 13) For the given the code the output for the call switchMethod("orange"); is given by julius. So the answer is OPTION B (julius). 14) For the given the code the output for the call switchMethod("strawberry"); is given by strawberry. So the answer is OPTION D (strawberry).
  • 7. 15) 1 public int factorial(int number){ 2 if(number==1) { 3 return 1; 4 } else { 5 return number*(factorial(number-1)); 6 } 7 } The base case for the recursive function for the given code is in the line 5. So the answer is OPTION D (5); 16) The call for the recursive function for the given code is in the line 5. So the answer is OPTION D (5); 17) If 'currentCell' is at the head of the list this moveRight() method will perform its duties correctly. It is True. So the answer is OPTION A (True). 18) If 'currentCell' is in the middle of the list this moveRight() method will perform its duties correctly. It is True. So the answer is OPTION A (True). 19) CODE : public class Sample { private int number; private String color; public Sample(int number) { this.number = number; this.color = "blue"; } @Override public boolean equals(Object obj) { if (obj == null) { return false; }
  • 8. if (getClass() != obj.getClass()) { return false; } final Sample other = (Sample) obj; if ((this.color == null) ? (other.color != null) : !this.color.equals(other.color)) { return false; } return true; } public static void main(String args[]) { List list = new ArrayList(); Sample sample1 = new Sample(1); Sample sample2 = new Sample(2); list.add(sample1); Boolean contains; contains = list.contains(sample2); System.out.println("Contains: " + contains); } } OUTPUT : Contains: true So the answer is OPTION A (Contains: true). 20) A Set is used to store objects in a particular order. It is True. So the answer is OPTION A (True). 21) The two statements will always yield the same value when a and b are Strings: 1) a.equals(b); 2) a==b; It is True. So the answer is OPTION A (True). 22) If a class have multiple methods by same name but different parameters, it is known as Method Overloading.
  • 9. There are two ways to overload the method in java By changing number of arguments By changing the data type So the answer is OPTION B (data type of arguments). 23) Interfaces are declared using the interface keyword, and may only contain method signature and constant declarations (variable declarations that are declared to be both static and final ). All methods of an Interface do not contain implementation (method bodies). So the answer is OPTION B (False). 24) A class that implements an interface may only implement a few of that interface's method declarations. No this is False. So the answer is OPTION B (False). 25) The output for the list = { 4, 8, 10, 6, 2, 8, 5 }; after the outer loop is {4, 8, 6, 10, 2, 5, 8} So the answer is OPTION D (None of the Above). 26) Every 'try' block must end with a 'finally' block. Not necessarily in evry case but could be also a catch block of statement. So the answer is OPTION B (False). 27) !(A && B) is equivalent to (!A || !B) So the answer is OPTION B ((!A || !B) ). Hope this is helpful.