0

programming languages Online Quiz - 292

Description: programming languages Online Quiz - 292
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

main() { signed int bit=512, i=5; for(;i;i--) { printf("%dn", bit = (bit >> (i - (i -1)))); } }

  1. Compile error

  2. 256256256256256

  3. 55555

  4. runtime error


Correct Option: B

void main(){ print(“%d”,scanf(“%s”)) };

  1. Compile error

  2. 11

  3. Hello world

  4. 5


Correct Option: B

void main(){ print(“%d”,printf(“What this prints”)) };

  1. Compile error

  2. What this prints

  3. 11

  4. 15


Correct Option: D

What is the maximum length of command line arguments including space between adjacent arguments

  1. 100

  2. 50

  3. 200

  4. 150


Correct Option: C

main() { signed int bit=512, i=5; for(;i;i--) { printf("%dn", bit = (bit >> (i - (i -1)))); } }

  1. Compile error

  2. 256256256256256

  3. 55555

  4. runtime error


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Compile error - This option is incorrect. There is no compile error in the given code.

Option B) 256256256256256 - This option is incorrect. Let's analyze the code to understand the output.

In the given code, we have a for loop that starts with the value of i as 5 and decrements i by 1 in each iteration until i becomes 0.

Inside the loop, the printf statement is used to print the value of bit.

In each iteration of the loop, the value of bit is updated by shifting it to the right by (i - (i -1)) positions. Initially, i is 5, so the shift is by 1 position. Therefore, the value of bit becomes bit >> 1, which is 512 >> 1 = 256.

In the next iteration, i becomes 4, so the shift is by 2 positions. Therefore, the value of bit becomes bit >> 2, which is 256 >> 2 = 64.

This process continues until i becomes 0.

So, the output of the code will be the values of bit in each iteration, separated by newlines. Therefore, the correct output is 256 64 16 4 1.

Option C) 55555 - This option is incorrect. The output of the code is not 55555.

Option D) Runtime error - This option is incorrect. There is no runtime error in the given code.

The correct answer is B) 256256256256256. This option is correct because it accurately reflects the output of the code.

void main(){ print(“%d”,scanf(“%s”)) };

  1. Compile error

  2. 11

  3. Hello world

  4. 5


Correct Option: B

void main() { int x=20,y=35; x= y++ + x++; y= ++y + ++x; printf(" %d %d" , x,y); }

  1. x=57 & y=94

  2. x=57,y=55

  3. X = 57 Y= 93

  4. X = 37 Y= 65


Correct Option: A

AI Explanation

To determine the values of x and y after executing the given code, let's go through each line of the code step by step:

  1. int x=20, y=35; - This line initializes the variables x and y with the values 20 and 35, respectively.
  2. x = y++ + x++; - This line assigns the value of y++ + x++ to x.
    • y++ is a post-increment operation, meaning that the value of y is used first and then incremented by 1. So, y++ evaluates to 35, and y becomes 36.
    • Similarly, x++ is a post-increment operation, so x++ evaluates to 20, and x becomes 21.
    • Therefore, x is assigned the value 35 + 20 = 55.
  3. y = ++y + ++x; - This line assigns the value of ++y + ++x to y.
    • ++y is a pre-increment operation, meaning that the value of y is incremented by 1 first and then used. So, ++y evaluates to 37, and y becomes 37.
    • Similarly, ++x is a pre-increment operation, so ++x evaluates to 22, and x becomes 22.
    • Therefore, y is assigned the value 37 + 22 = 59.
  4. printf(" %d %d", x, y); - This line prints the values of x and y.

Therefore, the output of the code will be 55 59.

The correct answer is not listed among the options provided.

Which group has had the most impact on modern object-oriented programming practices?

  1. The Gang of Four

  2. The Party of Five

  3. The soft-drink industry

  4. AC/DC


Correct Option: A

What is the best way to preserve type safety in assembly language?

  1. Don't link your modules to modules written in any other language

  2. Make sure you declare all your variables' data types ahead of time

  3. Don't add variables of one type to variables of another

  4. Devout prayer


Correct Option: D

Just-in-time (JIT) compilation improves the performance of languages that compile into bytecode. Which language featured the first JIT compiler?

  1. Java

  2. C#

  3. Smalltalk

  4. Cobol


Correct Option: C

If I told you a key characteristic of my programming language of choice was that it generated threaded code which language would I most likely be talking about?

  1. Pascal

  2. Java

  3. Forth

  4. Python


Correct Option: C

Your local supermarket is all sold out of energy drinks Jolt Cola and Mountain Dew. Which beverage will keep you going packing the most caffeine and sugar into a 12-ounce can?

  1. Sunkist Orange Soda

  2. Coca-Cola Classic

  3. Pepsi-Cola

  4. Dr. Pepper


Correct Option: A

Which of the following is NOT a central tenet of extreme programming?

  1. Refactor your code often

  2. Throw away obsolete code

  3. Debugging is for wimps

  4. Communicate often with the customer


Correct Option: C

What is the relationship between Java and JavaScript?

  1. Netscape invented JavaScript as a stripped-down "lite" version of Java

  2. Java borrowed ideas from JavaScript and made it a full-fledged programming language

  3. They both originate from the same research at Sun Microsystems

  4. There is none; it's all just marketing


Correct Option: D

Why do some consider Ruby to be more "purely" object-oriented than other more popular OOP languages such as Java and C++?

  1. Because Ruby forces object orientation and does not permit procedural or functional style code

  2. Because Ruby makes no distinction between objects and primitive types

  3. Because Ruby's syntax is similar to that of Perl

  4. Because Ruby programmers are full of themselves


Correct Option: B

Failure to validate user input is one of the most common sources of software security vulnerabilities. When is it safe to accept user input without validation?

  1. When the application is running behind a firewall

  2. Never; any program that accepts input can be exploited

  3. When the application is written in Perl using the language's "taint mode"

  4. When the user is your own mother


Correct Option: B

Which of the following is the best way to write reusable code that is easier to maintain?

  1. Use more global variables

  2. Keep variable and function names down to one or two letters

  3. Insert comments throughout your source code files

  4. Use pointer arithmetic wherever possible


Correct Option: C

Of the following who is NOT the inventor of a programming language in current use?

  1. Andrew S. Tanenbaum

  2. Guido van Rossum

  3. Niklaus Wirth

  4. Bjarne Stroustrup


Correct Option: A

To what concept does "the mythical man-month" refer?

  1. The code that would have been written last month if your project was on deadline

  2. The amount of code that you can produce in a month on your salary

  3. The fallacy that assigning more staff to a programming job will complete it faster

  4. The fact that like Sysiphus pushing the boulder you can never finish debugging


Correct Option: C

Hungarian Notation is a variable-naming convention used by some programmers. How did it get its name?

  1. It was called that because of its similarity to Reverse Polish Notation

  2. Its inventor was Hungarian

  3. When you read it out loud it sounds like you're speaking Hungarian

  4. It was invented at the Polytechnic University of Bucharest in Hungary


Correct Option: B
- Hide questions