SlideShare a Scribd company logo
Exam
Name___________________________________
MULTIPLE CHOICE. Choose the one alternative that best
completes the statement or answers the question.
1) Analyze the following program fragment:
int x;
double d = 1.5;
switch (d) {
case 1.0: x = 1;
case 1.5: x = 2;
case 2.0: x = 3;
}
1)
A) The switch control variable cannot be double.
B) The program has a compile error because the required break
statement is missing in the
switch statement.
C) The program has a compile error because the required default
case is missing in the switch
statement.
D) No errors.
2) Analyze the following code:
boolean even = false;
if (even = true) {
System.out.println("It is even!");
}
2)
A) The program runs fine, but displays nothing.
B) The program runs fine and displays It is even!.
C) The program has a runtime error.
D) The program has a compile error.
3) What is the printout of the following switch statement?
char ch = 'a';
switch (ch) {
case 'a':
case 'A':
System.out.print(ch); break;
case 'b':
case 'B':
System.out.print(ch); break;
case 'c':
case 'C':
System.out.print(ch); break;
case 'd':
case 'D':
System.out.print(ch);
}
3)
A) abc B) abcd C) ab D) aa E) a
1
4) The order of the precedence (from high to low) of the
operators +, *, &&, ||, & is: 4)
A) *, +, &, &&, ||
B) *, +, &&, ||, &
C) &&, ||, &, *, +
D) &, ||, &&, *, +
E) *, +, &, ||, &&
5) The statement System.out.printf("%10s", 123456) outputs
________. (Note: * represents a space) 5)
A) ****123456 B) 12345***** C) 123456**** D) 23456*****
6) The following code displays ________.
double temperature = 50;
if (temperature >= 100)
System.out.println("too hot");
else if (temperature <= 40)
System.out.println("too cold");
else
System.out.println("just right");
6)
A) too cold B) too hot
C) too hot too cold just right D) just right
7) Which of the following code displays the area of a circle if
the radius is positive? 7)
A) if (radius >= 0) System.out.println(radius * radius *
3.14159);
B) if (radius != 0) System.out.println(radius * radius *
3.14159);
C) if (radius > 0) System.out.println(radius * radius * 3.14159);
D) if (radius <= 0) System.out.println(radius * radius *
3.14159);
8) ________ is the code with natural language mixed with Java
code. 8)
A) A flowchart diagram B) Java program
C) Pseudocode D) A Java statement
9) Analyze the following code:
if (x < 100) && (x > 10)
System.out.println("x is between 10 and 100");
9)
A) The statement compiles fine.
B) The statement has compile errors because (x<100) & (x > 10)
must be enclosed inside
parentheses and the println(…) statement must be put inside a
block.
C) The statement compiles fine, but has a runtime error.
D) The statement has compile errors because (x<100) & (x >
10) must be enclosed inside
parentheses.
10) In Java, the word true is ________. 10)
A) same as value 1 B) same as value 0
C) a Boolean literal D) a Java keyword
2
11) How many times will the following code print "Welcome to
Java"?
int count = 0;
do {
System.out.println("Welcome to Java");
} while (count++ < 10);
11)
A) 11 B) 0 C) 8 D) 9 E) 10
12) What is sum after the following loop terminates?
int sum = 0;
int item = 0;
do {
item++;
sum += item;
if (sum > 4) break;
}
while (item < 5);
12)
A) 5 B) 7 C) 6 D) 8
13) What is i after the following for loop?
int y = 0;
for (int i = 0; i<10; ++i) {
y += i;
}
13)
A) 9 B) 11 C) 10 D) undefined
14) How many times will the following code print "Welcome to
Java"?
int count = 0;
while (count < 10) {
System.out.println("Welcome to Java");
count++;
}
14)
A) 11 B) 8 C) 0 D) 10 E) 9
15) How many times will the following code print "Welcome to
Java"?
int count = 0;
while (count++ < 10) {
System.out.println("Welcome to Java");
}
15)
A) 0 B) 10 C) 9 D) 11 E) 8
3
16) What is the number of iterations in the following loop:
for (int i = 1; i < n; i++) {
// iteration
}
16)
A) 2*n B) n C) n + 1 D) n - 1
17) Analyze the following fragment:
double sum = 0;
double d = 0;
while (d != 10.0) {
d += 0.1;
sum += sum + d;
}
17)
A) The program never stops because d is always 0.1 inside the
loop.
B) After the loop, sum is 0 + 0.1 + 0.2 + 0.3 + ... + 1.9
C) The program does not compile because sum and d are
declared double, but assigned with
integer value 0.
D) The program may not stop because of the phenomenon
referred to as numerical inaccuracy
for operating with floating-point numbers.
18) What is Math.rint(3.5)? 18)
A) 3.0 B) 5.0 C) 4.0 D) 3 E) 4
19) Which of the following should be declared as a void
method? 19)
A) Write a method that checks whether current second is an
integer from 1 to 100.
B) Write a method that prints integers from 1 to 100.
C) Write a method that converts an uppercase letter to
lowercase.
D) Write a method that returns a random integer from 1 to 100.
20) Given the following method
static void nPrint(String message, int n) {
while (n > 0) {
System.out.print(message);
n--;
}
}
What is k after invoking nPrint("A message", k)?
int k = 2;
nPrint("A message", k);
20)
A) 2 B) 0 C) 1 D) 3
21) What is Math.ceil(3.6)? 21)
A) 3 B) 3.0 C) 4.0 D) 5.0
4
22) ________ is to implement one method in the structure chart
at a time from the top to the bottom. 22)
A) Bottom-up and top-down approach B) Top-down approach
C) Stepwise refinement D) Bottom-up approach
23) What is the output of the following program?
import java.util.Date;
public class Test {
public static void main(String[ ] args) {
Date date = new Date(1234567);
m1(date);
System.out.print(date.getTime() + " ");
m2(date);
System.out.println(date.getTime());
}
public static void m1(Date date) {
date = new Date(7654321);
}
public static void m2(Date date) {
date.setTime(7654321);
}
}
23)
A) 7654321 1234567 B) 1234567 7654321
C) 1234567 1234567 D) 7654321 7654321
24) Which of the following statement is most accurate? (Choose
all that apply.) 24)
A) An object may contain other objects.
B) A reference variable refers to an object.
C) An object may contain the references of other objects.
D) A reference variable is an object.
25) How many JFrame objects can you create and how many can
you display? 25)
A) three B) one C) two D) unlimited
26) An object is an instance of a ________. 26)
A) data B) class C) method D) program
5
27) Analyze the following code fragments that assign a boolean
value to the variable even.
Code 1:
if (number % 2 == 0)
even = true;
else
even = false;
Code 2:
even = (number % 2 == 0) ? true: false;
Code 3:
even = number % 2 == 0;
27)
A) Code 3 has a compile error, because you attempt to assign
number to even.
B) All three are correct, but Code 2 is preferred.
C) All three are correct, but Code 1 is preferred.
D) Code 2 has a compile error, because you cannot have true
and false literals in the conditional
expression.
E) All three are correct, but Code 3 is preferred.
28) What is the printout of the following switch statement?
char ch = 'b';
switch (ch) {
case 'a':
System.out.print(ch);
case 'b':
System.out.print(ch);
case 'c':
System.out.print(ch);
case 'd':
System.out.print(ch);
}
28)
A) bcd B) bbb C) bb D) abcd E) b
29) Suppose x=10 and y=10. What is x after evaluating the
expression (y > 10) && (x-- > 10)? 29)
A) 11 B) 9 C) 10
30) To add 0.01 + 0.02 + ... + 1.00, what order should you use
to add the numbers to get better accuracy? 30)
A) add 1.00, 0.99, 0.98, ..., 0.02, 0.01 in this order to a sum
variable whose initial value is 0.
B) add 0.01, 0.02, ..., 1.00 in this order to a sum variable whose
initial value is 0.
31) How many times are the following loops executed?
for (int i = 0; i < 10; i++)
for (int j = 0; j < i; j++)
System.out.println(i * j)
31)
A) 100 B) 10 C) 20 D) 45
6
32) Analyze the following code.
public class Test {
public static void main(String[ ] args) {
System.out.println(m(2));
}
public static int m(int num) {
return num;
}
public static void m(int num) {
System.out.println(num);
}
}
32)
A) The program runs and prints 2 once.
B) The program runs and prints 2 twice.
C) The program has a compile error because the two methods m
have the same signature.
D) The program has a compile error because the second m
method is defined, but not invoked in
the main method.
33) Which of the following is the best for generating random
integer 0 or 1? 33)
A) (int)Math.random()
B) (int)(Math.random() + 0.2)
C) (int)(Math.random() + 0.8)
D) (int)Math.random() + 1
E) (int)(Math.random() + 0.5)
34) Variables that are shared by every instances of a class are
________. 34)
A) private variables B) class variables
C) instance variables D) public variables
35) Which of the following operators are right-associative? 35)
A) + B) % C) * D) = E) &&
36) What is the number of iterations in the following loop:
for (int i = 1; i <= n; i++) {
// iteration
}
36)
A) n B) n + 1 C) n - 1 D) 2*n
37) What is Math.rint(3.6)? 37)
A) 4.0 B) 3.0 C) 5.0 D) 3
7
38) What code may be filled in the blank without causing syntax
or runtime errors:
public class Test {
java.util.Date date;
public static void main(String[ ] args) {
Test test = new Test();
System.out.println(________);
}
}
38)
A) test.date B) date.toString()
C) test.date.toString() D) date
39) Suppose x=10 and y=10 what is x after evaluating the
expression (y >= 10) || (x-- > 10)? 39)
A) 11 B) 9 C) 10
40) What is the value in count after the following loop is
executed?
int count = 0;
do {
System.out.println("Welcome to Java");
} while (count++ < 9);
System.out.println(count);
40)
A) 8 B) 0 C) 9 D) 10 E) 11
8
ExamName___________________________________MULTIPLE CH.docx

More Related Content

Similar to ExamName___________________________________MULTIPLE CH.docx

C __paper.docx_final
C __paper.docx_finalC __paper.docx_final
C __paper.docx_final
Sumit Sar
 
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
CAPE Computer Science Unit 1 Paper 1 - Practice PaperCAPE Computer Science Unit 1 Paper 1 - Practice Paper
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
Alex Stewart
 
Model question paper_mc0061
Model question paper_mc0061Model question paper_mc0061
Model question paper_mc0061
gurbaxrawat
 
Question đúng cnu
Question đúng cnuQuestion đúng cnu
Question đúng cnu
PhamHoc
 
1. Which of the following statements would correctly print out t.pdf
1. Which of the following statements would correctly print out t.pdf1. Which of the following statements would correctly print out t.pdf
1. Which of the following statements would correctly print out t.pdf
ezzi97
 
Java language fundamentals
Java language fundamentalsJava language fundamentals
Java language fundamentals
Kapish Joshi
 
Oops Quiz
Oops QuizOops Quiz
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdf
choconyeuquy
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
Sujata Regoti
 
OXUS20 JAVA Programming Questions and Answers PART I
OXUS20 JAVA Programming Questions and Answers PART IOXUS20 JAVA Programming Questions and Answers PART I
OXUS20 JAVA Programming Questions and Answers PART I
Abdul Rahman Sherzad
 
Part - 2 Cpp programming Solved MCQ
Part - 2  Cpp programming Solved MCQ Part - 2  Cpp programming Solved MCQ
Part - 2 Cpp programming Solved MCQ
Knowledge Center Computer
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
Vedant Gavhane
 
Computer programming mcqs
Computer programming mcqsComputer programming mcqs
Computer programming mcqs
saadkhan672
 
this pdf very much useful for embedded c programming students
this pdf very much useful for embedded c programming studentsthis pdf very much useful for embedded c programming students
this pdf very much useful for embedded c programming students
pavan81088
 
C Programming
C ProgrammingC Programming
C Programming
amitymbaassignment
 
ALGO.ppt
ALGO.pptALGO.ppt
ALGO.ppt
PidoonEsm
 
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and AlgorithmsCP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
Sheba41
 
Part - 3 Cpp programming Solved MCQ
Part - 3 Cpp programming Solved MCQ  Part - 3 Cpp programming Solved MCQ
Part - 3 Cpp programming Solved MCQ
Knowledge Center Computer
 
200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)
Ankit Dubey
 
DAC CCAT GUESS PAPER Jun-Jul 2013
DAC CCAT GUESS PAPER Jun-Jul 2013 DAC CCAT GUESS PAPER Jun-Jul 2013
DAC CCAT GUESS PAPER Jun-Jul 2013
prabhatjon
 

Similar to ExamName___________________________________MULTIPLE CH.docx (20)

C __paper.docx_final
C __paper.docx_finalC __paper.docx_final
C __paper.docx_final
 
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
CAPE Computer Science Unit 1 Paper 1 - Practice PaperCAPE Computer Science Unit 1 Paper 1 - Practice Paper
CAPE Computer Science Unit 1 Paper 1 - Practice Paper
 
Model question paper_mc0061
Model question paper_mc0061Model question paper_mc0061
Model question paper_mc0061
 
Question đúng cnu
Question đúng cnuQuestion đúng cnu
Question đúng cnu
 
1. Which of the following statements would correctly print out t.pdf
1. Which of the following statements would correctly print out t.pdf1. Which of the following statements would correctly print out t.pdf
1. Which of the following statements would correctly print out t.pdf
 
Java language fundamentals
Java language fundamentalsJava language fundamentals
Java language fundamentals
 
Oops Quiz
Oops QuizOops Quiz
Oops Quiz
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdf
 
Technical aptitude test 2 CSE
Technical aptitude test 2 CSETechnical aptitude test 2 CSE
Technical aptitude test 2 CSE
 
OXUS20 JAVA Programming Questions and Answers PART I
OXUS20 JAVA Programming Questions and Answers PART IOXUS20 JAVA Programming Questions and Answers PART I
OXUS20 JAVA Programming Questions and Answers PART I
 
Part - 2 Cpp programming Solved MCQ
Part - 2  Cpp programming Solved MCQ Part - 2  Cpp programming Solved MCQ
Part - 2 Cpp programming Solved MCQ
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
 
Computer programming mcqs
Computer programming mcqsComputer programming mcqs
Computer programming mcqs
 
this pdf very much useful for embedded c programming students
this pdf very much useful for embedded c programming studentsthis pdf very much useful for embedded c programming students
this pdf very much useful for embedded c programming students
 
C Programming
C ProgrammingC Programming
C Programming
 
ALGO.ppt
ALGO.pptALGO.ppt
ALGO.ppt
 
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and AlgorithmsCP4151 ADSA unit1 Advanced Data Structures and Algorithms
CP4151 ADSA unit1 Advanced Data Structures and Algorithms
 
Part - 3 Cpp programming Solved MCQ
Part - 3 Cpp programming Solved MCQ  Part - 3 Cpp programming Solved MCQ
Part - 3 Cpp programming Solved MCQ
 
200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)200 mcq c++(Ankit dubey)
200 mcq c++(Ankit dubey)
 
DAC CCAT GUESS PAPER Jun-Jul 2013
DAC CCAT GUESS PAPER Jun-Jul 2013 DAC CCAT GUESS PAPER Jun-Jul 2013
DAC CCAT GUESS PAPER Jun-Jul 2013
 

More from gitagrimston

External Factor Analysis Summary (EFAS Table)External Factors.docx
External Factor Analysis Summary (EFAS Table)External Factors.docxExternal Factor Analysis Summary (EFAS Table)External Factors.docx
External Factor Analysis Summary (EFAS Table)External Factors.docx
gitagrimston
 
Exploring Online Consumer Behaviors.docx
Exploring Online Consumer Behaviors.docxExploring Online Consumer Behaviors.docx
Exploring Online Consumer Behaviors.docx
gitagrimston
 
External and Internal Analysis 8Extern.docx
External and Internal Analysis 8Extern.docxExternal and Internal Analysis 8Extern.docx
External and Internal Analysis 8Extern.docx
gitagrimston
 
Exploring Music Concert Paper Guidelines Instructions.docx
Exploring Music  Concert Paper Guidelines Instructions.docxExploring Music  Concert Paper Guidelines Instructions.docx
Exploring Music Concert Paper Guidelines Instructions.docx
gitagrimston
 
Expo 12 Discussion QuestionsThink about the cooperative learni.docx
Expo 12 Discussion QuestionsThink about the cooperative learni.docxExpo 12 Discussion QuestionsThink about the cooperative learni.docx
Expo 12 Discussion QuestionsThink about the cooperative learni.docx
gitagrimston
 
ExplanationMaster Honey is a franchise-style company that sel.docx
ExplanationMaster Honey is a franchise-style company that sel.docxExplanationMaster Honey is a franchise-style company that sel.docx
ExplanationMaster Honey is a franchise-style company that sel.docx
gitagrimston
 
Explain where industry profits are maximized in the figure below.docx
Explain where industry profits are maximized in the figure below.docxExplain where industry profits are maximized in the figure below.docx
Explain where industry profits are maximized in the figure below.docx
gitagrimston
 
Exploratory EssayResearch - 1The ability to Wallow in complex.docx
Exploratory EssayResearch - 1The ability to Wallow in complex.docxExploratory EssayResearch - 1The ability to Wallow in complex.docx
Exploratory EssayResearch - 1The ability to Wallow in complex.docx
gitagrimston
 
Exploring MusicExtra Credit #2 Due November 6 in classIn G.docx
Exploring MusicExtra Credit #2 Due November 6 in classIn G.docxExploring MusicExtra Credit #2 Due November 6 in classIn G.docx
Exploring MusicExtra Credit #2 Due November 6 in classIn G.docx
gitagrimston
 
Explain why Franz Boas did not accept Morgan’s view about evol.docx
Explain why Franz Boas did not accept Morgan’s view about evol.docxExplain why Franz Boas did not accept Morgan’s view about evol.docx
Explain why Franz Boas did not accept Morgan’s view about evol.docx
gitagrimston
 
Explanations 6.1 Qualities of Explanations Questions 0 of 3 com.docx
Explanations  6.1 Qualities of Explanations Questions 0 of 3 com.docxExplanations  6.1 Qualities of Explanations Questions 0 of 3 com.docx
Explanations 6.1 Qualities of Explanations Questions 0 of 3 com.docx
gitagrimston
 
Experts PresentationStudentPSY 496Instructor.docx
Experts PresentationStudentPSY 496Instructor.docxExperts PresentationStudentPSY 496Instructor.docx
Experts PresentationStudentPSY 496Instructor.docx
gitagrimston
 
Explain whether Okonkwo was remaining truthful to himself by killi.docx
Explain whether Okonkwo was remaining truthful to himself by killi.docxExplain whether Okonkwo was remaining truthful to himself by killi.docx
Explain whether Okonkwo was remaining truthful to himself by killi.docx
gitagrimston
 
Explain How these Aspects Work Together to Perform the Primary Fun.docx
Explain How these Aspects Work Together to Perform the Primary Fun.docxExplain How these Aspects Work Together to Perform the Primary Fun.docx
Explain How these Aspects Work Together to Perform the Primary Fun.docx
gitagrimston
 
Explain the 3 elements of every negotiation. Why is WinWin used m.docx
Explain the 3 elements of every negotiation. Why is WinWin used m.docxExplain the 3 elements of every negotiation. Why is WinWin used m.docx
Explain the 3 elements of every negotiation. Why is WinWin used m.docx
gitagrimston
 
Explain how the Kluckhohn–Strodtbeck and the Hofstede framework ca.docx
Explain how the Kluckhohn–Strodtbeck and the Hofstede framework ca.docxExplain how the Kluckhohn–Strodtbeck and the Hofstede framework ca.docx
Explain how the Kluckhohn–Strodtbeck and the Hofstede framework ca.docx
gitagrimston
 
Exploration 8 – Shifting and Stretching Rational Functions .docx
Exploration 8 – Shifting and Stretching Rational Functions .docxExploration 8 – Shifting and Stretching Rational Functions .docx
Exploration 8 – Shifting and Stretching Rational Functions .docx
gitagrimston
 
Exploring Innovation in Action Power to the People – Lifeline Ene.docx
Exploring Innovation in Action Power to the People – Lifeline Ene.docxExploring Innovation in Action Power to the People – Lifeline Ene.docx
Exploring Innovation in Action Power to the People – Lifeline Ene.docx
gitagrimston
 
Experiment 8 - Resistance and Ohm’s Law 8.1 Introduction .docx
Experiment 8 - Resistance and Ohm’s Law 8.1 Introduction .docxExperiment 8 - Resistance and Ohm’s Law 8.1 Introduction .docx
Experiment 8 - Resistance and Ohm’s Law 8.1 Introduction .docx
gitagrimston
 
Experimental Essay The DialecticThe purpose of this paper is to.docx
Experimental Essay The DialecticThe purpose of this paper is to.docxExperimental Essay The DialecticThe purpose of this paper is to.docx
Experimental Essay The DialecticThe purpose of this paper is to.docx
gitagrimston
 

More from gitagrimston (20)

External Factor Analysis Summary (EFAS Table)External Factors.docx
External Factor Analysis Summary (EFAS Table)External Factors.docxExternal Factor Analysis Summary (EFAS Table)External Factors.docx
External Factor Analysis Summary (EFAS Table)External Factors.docx
 
Exploring Online Consumer Behaviors.docx
Exploring Online Consumer Behaviors.docxExploring Online Consumer Behaviors.docx
Exploring Online Consumer Behaviors.docx
 
External and Internal Analysis 8Extern.docx
External and Internal Analysis 8Extern.docxExternal and Internal Analysis 8Extern.docx
External and Internal Analysis 8Extern.docx
 
Exploring Music Concert Paper Guidelines Instructions.docx
Exploring Music  Concert Paper Guidelines Instructions.docxExploring Music  Concert Paper Guidelines Instructions.docx
Exploring Music Concert Paper Guidelines Instructions.docx
 
Expo 12 Discussion QuestionsThink about the cooperative learni.docx
Expo 12 Discussion QuestionsThink about the cooperative learni.docxExpo 12 Discussion QuestionsThink about the cooperative learni.docx
Expo 12 Discussion QuestionsThink about the cooperative learni.docx
 
ExplanationMaster Honey is a franchise-style company that sel.docx
ExplanationMaster Honey is a franchise-style company that sel.docxExplanationMaster Honey is a franchise-style company that sel.docx
ExplanationMaster Honey is a franchise-style company that sel.docx
 
Explain where industry profits are maximized in the figure below.docx
Explain where industry profits are maximized in the figure below.docxExplain where industry profits are maximized in the figure below.docx
Explain where industry profits are maximized in the figure below.docx
 
Exploratory EssayResearch - 1The ability to Wallow in complex.docx
Exploratory EssayResearch - 1The ability to Wallow in complex.docxExploratory EssayResearch - 1The ability to Wallow in complex.docx
Exploratory EssayResearch - 1The ability to Wallow in complex.docx
 
Exploring MusicExtra Credit #2 Due November 6 in classIn G.docx
Exploring MusicExtra Credit #2 Due November 6 in classIn G.docxExploring MusicExtra Credit #2 Due November 6 in classIn G.docx
Exploring MusicExtra Credit #2 Due November 6 in classIn G.docx
 
Explain why Franz Boas did not accept Morgan’s view about evol.docx
Explain why Franz Boas did not accept Morgan’s view about evol.docxExplain why Franz Boas did not accept Morgan’s view about evol.docx
Explain why Franz Boas did not accept Morgan’s view about evol.docx
 
Explanations 6.1 Qualities of Explanations Questions 0 of 3 com.docx
Explanations  6.1 Qualities of Explanations Questions 0 of 3 com.docxExplanations  6.1 Qualities of Explanations Questions 0 of 3 com.docx
Explanations 6.1 Qualities of Explanations Questions 0 of 3 com.docx
 
Experts PresentationStudentPSY 496Instructor.docx
Experts PresentationStudentPSY 496Instructor.docxExperts PresentationStudentPSY 496Instructor.docx
Experts PresentationStudentPSY 496Instructor.docx
 
Explain whether Okonkwo was remaining truthful to himself by killi.docx
Explain whether Okonkwo was remaining truthful to himself by killi.docxExplain whether Okonkwo was remaining truthful to himself by killi.docx
Explain whether Okonkwo was remaining truthful to himself by killi.docx
 
Explain How these Aspects Work Together to Perform the Primary Fun.docx
Explain How these Aspects Work Together to Perform the Primary Fun.docxExplain How these Aspects Work Together to Perform the Primary Fun.docx
Explain How these Aspects Work Together to Perform the Primary Fun.docx
 
Explain the 3 elements of every negotiation. Why is WinWin used m.docx
Explain the 3 elements of every negotiation. Why is WinWin used m.docxExplain the 3 elements of every negotiation. Why is WinWin used m.docx
Explain the 3 elements of every negotiation. Why is WinWin used m.docx
 
Explain how the Kluckhohn–Strodtbeck and the Hofstede framework ca.docx
Explain how the Kluckhohn–Strodtbeck and the Hofstede framework ca.docxExplain how the Kluckhohn–Strodtbeck and the Hofstede framework ca.docx
Explain how the Kluckhohn–Strodtbeck and the Hofstede framework ca.docx
 
Exploration 8 – Shifting and Stretching Rational Functions .docx
Exploration 8 – Shifting and Stretching Rational Functions .docxExploration 8 – Shifting and Stretching Rational Functions .docx
Exploration 8 – Shifting and Stretching Rational Functions .docx
 
Exploring Innovation in Action Power to the People – Lifeline Ene.docx
Exploring Innovation in Action Power to the People – Lifeline Ene.docxExploring Innovation in Action Power to the People – Lifeline Ene.docx
Exploring Innovation in Action Power to the People – Lifeline Ene.docx
 
Experiment 8 - Resistance and Ohm’s Law 8.1 Introduction .docx
Experiment 8 - Resistance and Ohm’s Law 8.1 Introduction .docxExperiment 8 - Resistance and Ohm’s Law 8.1 Introduction .docx
Experiment 8 - Resistance and Ohm’s Law 8.1 Introduction .docx
 
Experimental Essay The DialecticThe purpose of this paper is to.docx
Experimental Essay The DialecticThe purpose of this paper is to.docxExperimental Essay The DialecticThe purpose of this paper is to.docx
Experimental Essay The DialecticThe purpose of this paper is to.docx
 

Recently uploaded

The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 

Recently uploaded (20)

The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 

ExamName___________________________________MULTIPLE CH.docx

  • 1. Exam Name___________________________________ MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) Analyze the following program fragment: int x; double d = 1.5; switch (d) { case 1.0: x = 1; case 1.5: x = 2; case 2.0: x = 3; } 1) A) The switch control variable cannot be double. B) The program has a compile error because the required break statement is missing in the switch statement. C) The program has a compile error because the required default case is missing in the switch statement. D) No errors. 2) Analyze the following code:
  • 2. boolean even = false; if (even = true) { System.out.println("It is even!"); } 2) A) The program runs fine, but displays nothing. B) The program runs fine and displays It is even!. C) The program has a runtime error. D) The program has a compile error. 3) What is the printout of the following switch statement? char ch = 'a'; switch (ch) { case 'a': case 'A': System.out.print(ch); break; case 'b': case 'B': System.out.print(ch); break; case 'c': case 'C': System.out.print(ch); break; case 'd': case 'D': System.out.print(ch); } 3) A) abc B) abcd C) ab D) aa E) a 1
  • 3. 4) The order of the precedence (from high to low) of the operators +, *, &&, ||, & is: 4) A) *, +, &, &&, || B) *, +, &&, ||, & C) &&, ||, &, *, + D) &, ||, &&, *, + E) *, +, &, ||, && 5) The statement System.out.printf("%10s", 123456) outputs ________. (Note: * represents a space) 5) A) ****123456 B) 12345***** C) 123456**** D) 23456***** 6) The following code displays ________. double temperature = 50; if (temperature >= 100) System.out.println("too hot"); else if (temperature <= 40) System.out.println("too cold"); else System.out.println("just right"); 6) A) too cold B) too hot C) too hot too cold just right D) just right 7) Which of the following code displays the area of a circle if the radius is positive? 7) A) if (radius >= 0) System.out.println(radius * radius * 3.14159); B) if (radius != 0) System.out.println(radius * radius * 3.14159);
  • 4. C) if (radius > 0) System.out.println(radius * radius * 3.14159); D) if (radius <= 0) System.out.println(radius * radius * 3.14159); 8) ________ is the code with natural language mixed with Java code. 8) A) A flowchart diagram B) Java program C) Pseudocode D) A Java statement 9) Analyze the following code: if (x < 100) && (x > 10) System.out.println("x is between 10 and 100"); 9) A) The statement compiles fine. B) The statement has compile errors because (x<100) & (x > 10) must be enclosed inside parentheses and the println(…) statement must be put inside a block. C) The statement compiles fine, but has a runtime error. D) The statement has compile errors because (x<100) & (x > 10) must be enclosed inside parentheses. 10) In Java, the word true is ________. 10) A) same as value 1 B) same as value 0 C) a Boolean literal D) a Java keyword 2
  • 5. 11) How many times will the following code print "Welcome to Java"? int count = 0; do { System.out.println("Welcome to Java"); } while (count++ < 10); 11) A) 11 B) 0 C) 8 D) 9 E) 10 12) What is sum after the following loop terminates? int sum = 0; int item = 0; do { item++; sum += item; if (sum > 4) break; } while (item < 5); 12) A) 5 B) 7 C) 6 D) 8 13) What is i after the following for loop? int y = 0; for (int i = 0; i<10; ++i) { y += i; } 13)
  • 6. A) 9 B) 11 C) 10 D) undefined 14) How many times will the following code print "Welcome to Java"? int count = 0; while (count < 10) { System.out.println("Welcome to Java"); count++; } 14) A) 11 B) 8 C) 0 D) 10 E) 9 15) How many times will the following code print "Welcome to Java"? int count = 0; while (count++ < 10) { System.out.println("Welcome to Java"); } 15) A) 0 B) 10 C) 9 D) 11 E) 8 3 16) What is the number of iterations in the following loop: for (int i = 1; i < n; i++) { // iteration }
  • 7. 16) A) 2*n B) n C) n + 1 D) n - 1 17) Analyze the following fragment: double sum = 0; double d = 0; while (d != 10.0) { d += 0.1; sum += sum + d; } 17) A) The program never stops because d is always 0.1 inside the loop. B) After the loop, sum is 0 + 0.1 + 0.2 + 0.3 + ... + 1.9 C) The program does not compile because sum and d are declared double, but assigned with integer value 0. D) The program may not stop because of the phenomenon referred to as numerical inaccuracy for operating with floating-point numbers. 18) What is Math.rint(3.5)? 18) A) 3.0 B) 5.0 C) 4.0 D) 3 E) 4 19) Which of the following should be declared as a void method? 19) A) Write a method that checks whether current second is an integer from 1 to 100. B) Write a method that prints integers from 1 to 100.
  • 8. C) Write a method that converts an uppercase letter to lowercase. D) Write a method that returns a random integer from 1 to 100. 20) Given the following method static void nPrint(String message, int n) { while (n > 0) { System.out.print(message); n--; } } What is k after invoking nPrint("A message", k)? int k = 2; nPrint("A message", k); 20) A) 2 B) 0 C) 1 D) 3 21) What is Math.ceil(3.6)? 21) A) 3 B) 3.0 C) 4.0 D) 5.0 4 22) ________ is to implement one method in the structure chart at a time from the top to the bottom. 22) A) Bottom-up and top-down approach B) Top-down approach C) Stepwise refinement D) Bottom-up approach 23) What is the output of the following program?
  • 9. import java.util.Date; public class Test { public static void main(String[ ] args) { Date date = new Date(1234567); m1(date); System.out.print(date.getTime() + " "); m2(date); System.out.println(date.getTime()); } public static void m1(Date date) { date = new Date(7654321); } public static void m2(Date date) { date.setTime(7654321); } } 23) A) 7654321 1234567 B) 1234567 7654321 C) 1234567 1234567 D) 7654321 7654321 24) Which of the following statement is most accurate? (Choose all that apply.) 24) A) An object may contain other objects. B) A reference variable refers to an object. C) An object may contain the references of other objects. D) A reference variable is an object. 25) How many JFrame objects can you create and how many can you display? 25) A) three B) one C) two D) unlimited
  • 10. 26) An object is an instance of a ________. 26) A) data B) class C) method D) program 5 27) Analyze the following code fragments that assign a boolean value to the variable even. Code 1: if (number % 2 == 0) even = true; else even = false; Code 2: even = (number % 2 == 0) ? true: false; Code 3: even = number % 2 == 0; 27) A) Code 3 has a compile error, because you attempt to assign number to even. B) All three are correct, but Code 2 is preferred. C) All three are correct, but Code 1 is preferred. D) Code 2 has a compile error, because you cannot have true and false literals in the conditional expression. E) All three are correct, but Code 3 is preferred. 28) What is the printout of the following switch statement?
  • 11. char ch = 'b'; switch (ch) { case 'a': System.out.print(ch); case 'b': System.out.print(ch); case 'c': System.out.print(ch); case 'd': System.out.print(ch); } 28) A) bcd B) bbb C) bb D) abcd E) b 29) Suppose x=10 and y=10. What is x after evaluating the expression (y > 10) && (x-- > 10)? 29) A) 11 B) 9 C) 10 30) To add 0.01 + 0.02 + ... + 1.00, what order should you use to add the numbers to get better accuracy? 30) A) add 1.00, 0.99, 0.98, ..., 0.02, 0.01 in this order to a sum variable whose initial value is 0. B) add 0.01, 0.02, ..., 1.00 in this order to a sum variable whose initial value is 0. 31) How many times are the following loops executed? for (int i = 0; i < 10; i++) for (int j = 0; j < i; j++) System.out.println(i * j) 31)
  • 12. A) 100 B) 10 C) 20 D) 45 6 32) Analyze the following code. public class Test { public static void main(String[ ] args) { System.out.println(m(2)); } public static int m(int num) { return num; } public static void m(int num) { System.out.println(num); } } 32) A) The program runs and prints 2 once. B) The program runs and prints 2 twice. C) The program has a compile error because the two methods m have the same signature. D) The program has a compile error because the second m method is defined, but not invoked in the main method. 33) Which of the following is the best for generating random integer 0 or 1? 33)
  • 13. A) (int)Math.random() B) (int)(Math.random() + 0.2) C) (int)(Math.random() + 0.8) D) (int)Math.random() + 1 E) (int)(Math.random() + 0.5) 34) Variables that are shared by every instances of a class are ________. 34) A) private variables B) class variables C) instance variables D) public variables 35) Which of the following operators are right-associative? 35) A) + B) % C) * D) = E) && 36) What is the number of iterations in the following loop: for (int i = 1; i <= n; i++) { // iteration } 36) A) n B) n + 1 C) n - 1 D) 2*n 37) What is Math.rint(3.6)? 37) A) 4.0 B) 3.0 C) 5.0 D) 3 7 38) What code may be filled in the blank without causing syntax or runtime errors: public class Test { java.util.Date date;
  • 14. public static void main(String[ ] args) { Test test = new Test(); System.out.println(________); } } 38) A) test.date B) date.toString() C) test.date.toString() D) date 39) Suppose x=10 and y=10 what is x after evaluating the expression (y >= 10) || (x-- > 10)? 39) A) 11 B) 9 C) 10 40) What is the value in count after the following loop is executed? int count = 0; do { System.out.println("Welcome to Java"); } while (count++ < 9); System.out.println(count); 40) A) 8 B) 0 C) 9 D) 10 E) 11 8