0% found this document useful (0 votes)
10 views

CS_4402_Graded_Quiz_Unit_6

The document contains a series of programming-related questions and answers, covering topics such as object-oriented programming, scripting languages, recursion, and programming constructs. Each question is followed by multiple-choice options, with the correct answer indicated. The overall performance is perfect, with a score of 100%.

Uploaded by

krisrulzk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

CS_4402_Graded_Quiz_Unit_6

The document contains a series of programming-related questions and answers, covering topics such as object-oriented programming, scripting languages, recursion, and programming constructs. Each question is followed by multiple-choice options, with the correct answer indicated. The overall performance is perfect, with a score of 100%.

Uploaded by

krisrulzk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Marks 25.00/25.

00
Grade 100.00 out of 100.00

Question 1
Correct
Mark 1.00 out of 1.00

A programming language is said to support object oriented programming if it includes all of the following constructs EXCEPT:

Select one:
a. Encapsulation and data abstraction
b. Inheritance
c. Dynamic polymorphism
d. Data Abstraction 

The correct answer is: Data Abstraction

Question 2
Correct
Mark 1.00 out of 1.00

Real world objects contain what two things?

Select one:
a. state and behavior 
b. methods and attributes
c. variables and behaviors
d. instances and allocations

The correct answer is: state and behavior


Question 3
Correct
Mark 1.00 out of 1.00

Which of the following examples is NOT a scripting language?

Select one:
a. Perl
b. Python
c. Rexx
d. Haskell 

The correct answer is: Haskell

Question 4
Correct
Mark 1.00 out of 1.00

The ability to select the appropriate subprogram at run-time based upon an evaluation of types is known as? (NOTE: there are 4
possible answers and you can specify any of the 4).

Answer: dynamic polymorphism 

The correct answer is: dynamic polymorphism

Question 5
Correct
Mark 1.00 out of 1.00

What type of command repeatedly executes the program body (or a block) to determine when execution should stop?

Select one:
a. Iterative command 
b. Simultaneous command
c. Definitive command
d. Assignment command

The correct answer is: Iterative command


Question 6
Correct
Mark 1.00 out of 1.00

Given that n and count are both of type int, which statement is true about the following code segments?

I for (count=1; count <= n; count++)


System.out.println(count);

II count = 1;
while (count <= n)
{
System.out.println(count);
count++;
}

Select one:
a. I and II are exactly equivalent for all input values of n. 
b. I and II are exactly equivalent for all input values n>= 1, but differ when n<= 0.
c. I and II are exactly equivalent only when n = 0.
d. I and II are exactly equivalent only when n is even.
e. I and II are not equivalent for any input values of n.

The correct answer is: I and II are exactly equivalent for all input values of n.
Question 7
Correct
Mark 1.00 out of 1.00

The following fragment intends that a user will enter a list of positive integers at the keyboard and terminate the list with a sentinel:

int value = 0;
final int SENTINEL = -999;
while(value != SENTINEL)
{
// code to process value
value = IO.readInt();
}

Select one:
a. The sentinel gets processed
b. The last nonsentinel value entered in the list fails to get processed.
c. A poor choice of SENTINEL value causes the loop to terminate before all values have been processed.
d. The code will always process a value that is not on the list 
e. Entering the SENTINEL value as the first value causes a run-time error.

The correct answer is: The code will always process a value that is not on the list

Question 8
Correct
Mark 1.00 out of 1.00

In programming languages, which category uses repetition to solve a problem?

Select one:
a. Selection
b. Iteration 
c. Recursion
d. Concurrency

The correct answer is: Iteration


Question 9
Correct
Mark 1.00 out of 1.00

The output of compilation is code generation which typically translates a language construct into assembly language and from there
into machine executable code. What language construct was the following segment of assembler code generated from?
compute R1,expression
jump.eq R1,L1
statement-1
jump L2
L1: statement-2
L2:

Select one:
a. while statement
b. for loop statement
c. case statement
d. if statement 

The correct answer is: if statement

Question 10
Correct
Mark 1.00 out of 1.00

What will the following regular expresssion match to?


([\w]+[-._+&])*[\w]+@([-\w]+[.])+[a-zA-Z]{2,6}

Select one:
a. A strong password
b. A phone number field
c. An email address 
d. The URL of a web site

The correct answer is: An email address


Question 11
Correct
Mark 1.00 out of 1.00

Which of the following is NOT a programming structure?

Select one:
a. sequence
b. selection
c. imperative programming 
d. repetition

The correct answer is: imperative programming

Question 12
Correct
Mark 1.00 out of 1.00

True/False: Perl was originally developed by Linus Trovalds as a scripting language for Windows.

Select one:
True
False 

The correct answer is 'False'.

Question 13
Correct
Mark 1.00 out of 1.00

What command is used to distinguish the imperative programming languages from other programming languages?

Select one:
a. Assignment command 
b. Simultaneous command
c. Iterative command
d. Definitive command

The correct answer is: Assignment command


Question 14
Correct
Mark 1.00 out of 1.00

True/False: An algorithm can often be implemented with either recursion or iteration, however iteration typically takes less memory.

Select one:
True 
False

The correct answer is 'True'.

Question 15
Correct
Mark 1.00 out of 1.00

The following code segment is an example of:


void f() {
... g() ...
}
void g() {
... f() ...
}

Select one:
a. a direct recursive call
b. an indirect recursive call 
c. a nested function call
d. functional programming

The correct answer is: an indirect recursive call


Question 16
Correct
Mark 1.00 out of 1.00

What elements will the Perl language @a array consist of ?


$_ = ' a b c ';

my @a = split();

Select one:
a. ' ', 'a', ' ', 'b', ' ', 'c', ' '
b. undef, 'a', 'b', 'c', undef
c. 'a', 'b', 'c' 
d. ' ', 'a', 'b', 'c'

The correct answer is: 'a', 'b', 'c'

Question 17
Correct
Mark 1.00 out of 1.00

Which of the following regex expressions would match the following: MyDogIs12

Select one:
a. {a-z}{A-Z}{0-9}
b. [a-zA-Z]
c. [a-z0-9]
d. [a-zA-Z0-9] 

The correct answer is: [a-zA-Z0-9]


Question 18
Correct
Mark 1.00 out of 1.00

True/False: Actual parameters can only be specified as variables

Select one:
True
False 

The correct answer is 'False'.

Question 19
Correct
Mark 1.00 out of 1.00

What is used to execute Java bytecode?

Select one:
a. Java Virtual Machine 
b. Java Virtual Processor
c. Java Interpreter
d. Java interceptor

The correct answer is: Java Virtual Machine


Question 20
Correct
Mark 1.00 out of 1.00

What values are stored in x and y after execution of the following program segment?

int x=-30, y=40;


if (x >=0)
{
if (x<=100)
{
y=x*3;
if (y<50)
x/= 10;
}
else
y = x * 2;
}
else
y = -x;

Select one:
a. x=30 y=60
b. x=30 y=90
c. x=-30 y=30 
d. x=3 y=-3
e. x=30 y=40

The correct answer is: x=-30 y=30


Question 21
Correct
Mark 1.00 out of 1.00

Consider the following code segment


if (n != 0 && n / n > 1000)
statement1;
else
statement2;

if n is of type int and has a value of 0 when the segment is executed, what will happen?

Select one:
a. Neither statement1 nor statement2 will be executed; control will pass to the first statement following the if statement
b. A syntax error will occur
c. statement1, but not statement2, will be executed
d. statement2, but not statement1 will be executed 

The correct answer is: statement2, but not statement1 will be executed

Question 22
Correct
Mark 1.00 out of 1.00

True/False: The real disadvantage of call-by-reference is that the mechanism is inherently unsafe.

Select one:
True 
False

The correct answer is 'True'.


Question 23
Correct
Mark 1.00 out of 1.00

True/False: The ability of the compiler to select, at compile time, the most appropriate data type or method to use based upon data
type is known as dynamic polymorphism?

Select one:
True
False 

The correct answer is 'False'.

Question 24
Correct
Mark 1.00 out of 1.00

In programming languages, which category must make the appropriate decision at run-time between two or more statements or
expressions that occur within a program?

Select one:
a. Selection 
b. Iteration
c. Recursion
d. Sequence

The correct answer is: Selection


Question 25
Correct
Mark 1.00 out of 1.00

The following segment of code in Perl produces the ouput 2. This indicates that Perl is.
print 1+"1"

Select one:
a. weakly typed 
b. strongly typed
c. dynamically scoped
d. compiled

The correct answer is: weakly typed

You might also like