programming languages Online Quiz - 54

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

Which of the following denotes file modes that can be used in C program?

  1. "r"

  2. "w"

  3. "a"

  4. all the above

Correct Option: D

To solve this question, the user needs to know about file modes in C programming.

In C programming, the file modes are used to specify the type of access that is required to open the file. Each mode represents a different type of operation that can be performed on the file. The three most commonly used file modes are "r" for reading, "w" for writing, and "a" for appending.

Option D is correct because all of the given options denote file modes that can be used in a C program.

Option A ( "r" ) is used to open a file for reading purposes.

Option B ( "w" ) is used to open a file for writing purposes. If the file already exists, the contents of the file are overwritten. If the file does not exist, a new file is created.

Option C ( "a" ) is used to open a file for appending purposes. If the file already exists, new data is written to the end of the file. If the file does not exist, a new file is created.

Therefore, the answer is: D

What will happen? int main(int argc, char*argv) { char ptr = NULL; free(ptr); return 0; }

  1. core dump

  2. nothing

  3. undefined behavior

  4. all the above

Correct Option: B

Given: 31. // some code here 32. try { 33. // some code here 34. } catch (SomeException se) { 35. // some code here 36. } finally { 37. // some code here 38. } Under which three circumstances will the code on line 37 be executed? (Choose three.)

  1. The instance gets garbage collected.

  2. The code on line 33 throws an exception.

  3. . The code on line 35 throws an exception

  4. The code on line 31 throws an exception

  5. The code on line 33 executes successfully

Correct Option: B,C,E

The code used for denoting unsigned decimal integer in scanf is :

  1. %d

  2. %ud

  3. %u

  4. all the above

Correct Option: C

Which of the following differences between malloc and calloc are true? 1) malloc allocates number of bytes passed as argument 2) calloc allocates the product of number of elements multiplied by the size of each element, which are both passed as arguments. 3) both malloc and calloc return void* 4) both malloc and calloc initialize allocated memory to all 0

  1. 1, 2, 3, 4

  2. 1, 2, 3

  3. 1,2

  4. 1

Correct Option: B

In theory, which is faster, the call to strcpy or the call to memcpy? #include #include int main(){ char msg[12] = "Hello World"; char buffer1[12]; char buffer2[12]; strcpy(buffer1, msg); memcpy(buffer2, msg, sizeof(msg)); return 0; }

  1. strcpy

  2. memcpy

  3. both memcpy and strcpy

  4. none

Correct Option: B

What is the output?int i = 3;if (!i) i++; i++;if (i==3) i+=2; i+=2;printf("%d\n", i);

  1. 3

  2. 5

  3. 7

  4. 6

Correct Option: D

Which takes the first precedence in evaluation among the following operators?

  1. ||

  2. !

  3. &&

  4. All the Above has equal precedence

Correct Option: B

What gets printed? int i = 3; if (!i) i++; i++; if (i==3) i+=2; i+=2; printf("%d\n", i);

  1. 6

  2. 7

  3. 3

  4. 5

Correct Option: A

What is the command to display a file in reverse

  1. rev filename

  2. cat -r filename

  3. tac filename

  4. filerev filename

Correct Option: C

what is the command to list inode number along its file long listing?

  1. ls -n

  2. ll -d

  3. ls -il

  4. lsi

Correct Option: C

$touch {a}_{b,c} What is the output

  1. creates a_b,c file

  2. syntax error

  3. changes the timestamps of a_bc file

  4. creates a_b and a_c files

Correct Option: D

How can preserve timestamps of a file while copying

  1. bydeflut it preserves

  2. cp -in

  3. cp -p

  4. cp -t

Correct Option: C
  1. type filename

  2. type - -info filename

  3. file filename

  4. none

Correct Option: C

mutt is a

  1. mail client

  2. web browser

  3. text browser

  4. backup engine

Correct Option: A
  1. clear

  2. reset

  3. tput clear

  4. all

Correct Option: D

What is the latest stable version of the linux kernal?

  1. 2.6.37R

  2. 2.6.37

  3. 2.6.38

  4. 2.6.55

Correct Option: B

What is the output of the command $sed 's/([a-z]) *([a-z])/\2,\1/' file


  2. Sagar, praveen


  4. sagar,Praveen

Correct Option: B

Which is not a browser?

  1. Lynx

  2. Emacs/w3

  3. links

  4. browsee

Correct Option: D
- Hide questions