Test Your Coding Skills: Trivia Quiz!

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Code_Quest_2k18
C
Code_Quest_2k18
Community Contributor
Quizzes Created: 1 | Total Attempts: 448
| Attempts: 448 | Questions: 30
Please wait...
Question 1 / 30
0 %
0/100
Score 0/100
1. User-defined data type can be derived by_____________

Explanation

User-defined data types can be derived by using any of the mentioned options, which are struct, enum, and typedef.

- A struct allows the user to create a composite data type by combining different data types into a single entity.
- An enum allows the user to define a set of named values, which can be used to represent a set of related constants.
- The typedef keyword allows the user to create an alias or a new name for an existing data type, making it easier to use and understand in the code.

Therefore, all of the mentioned options can be used to derive user-defined data types.

Submit
Please wait...
About This Quiz
Test Your Coding Skills: Trivia Quiz! - Quiz

Dive into the intricacies of C programming with this trivia quiz! Test and enhance your understanding of variable naming, function arguments, user-defined data types, and union management. Perfect... see morefor learners aiming to sharpen their coding skills. see less

2. Size of a union is determined by size of the.

Explanation

The size of a union is determined by the biggest member in the union because a union allocates enough memory to hold the largest member among its members. This ensures that the union can accommodate any of its members without wasting unnecessary memory. Therefore, the size of a union is equal to the size of its largest member.

Submit
3. Members of a union are accessed as________________

Explanation

Both union-name.member and union-pointer->member are correct ways to access members of a union. The dot operator (union-name.member) is used when accessing the members of a union directly using the union name. The arrow operator (union-pointer->member) is used when accessing the members of a union through a pointer to the union.

Submit
4. If an argument to a function is declared as const, then

Explanation

If an argument to a function is declared as const, it means that the function is not allowed to modify the argument. The const keyword indicates that the value of the argument should remain unchanged throughout the function. This is useful when we want to ensure that a function does not accidentally modify the argument and helps in maintaining the integrity of the data.

Submit
5. Runtime polymorphism is achieved by____________

Explanation

Runtime polymorphism is achieved by using virtual functions. Virtual functions allow a derived class to override the implementation of a base class function. This means that when a function is called using a base class pointer or reference, the actual implementation of the function in the derived class is executed at runtime. This enables dynamic dispatch, where the appropriate function implementation is determined based on the type of the object being pointed to or referenced. By using virtual functions, different objects of the same base class can exhibit different behaviors, leading to polymorphism.

Submit
6. C++ exception handling mechanism mainly uses how many keywords?

Explanation

The correct answer is three because C++ exception handling mechanism mainly uses three keywords: try, catch, and throw. The try block is used to enclose the code that may throw an exception, the catch block is used to handle the thrown exception, and the throw keyword is used to explicitly throw an exception. These three keywords are essential for implementing exception handling in C++.

Submit
7. Which of the following is/are the new cast operators used in c++.
  1. const_cast
  2. static_cast
  3. dynamic_cast
  4. new_cast

Explanation

The correct answer is 1, 2 and 3 only. These are the new cast operators used in C++. The const_cast is used to cast away the constness of a variable, static_cast is used for general type conversions, and dynamic_cast is used for safe downcasting and cross-casting between classes with virtual functions. The new_cast is not a valid cast operator in C++.

Submit
8. With what data structure can a priority queue be implemented ?

Explanation

A priority queue can be implemented using any of the given data structures: Array, List, or Heap.
- An array can be used to implement a priority queue by storing the elements in a linear structure and maintaining their priority order.
- A list can also be used by keeping the elements in a linked structure and sorting them based on their priority.
- A heap is a specialized tree-based data structure that can efficiently implement a priority queue by maintaining the highest priority element at the root.
Therefore, all of the above data structures can be used to implement a priority queue.

Submit
9. Operation "a = a * b + a" can also be written as :

Explanation

The given operation "a = a * b + a" can be written in multiple ways. The first option "a *= b + 1" is equivalent to "a = a * (b + 1)". The second option "(c = a * b) != (a = c + a)" assigns the product of a and b to c, then checks if c is not equal to the sum of c and a, and assigns the result to a. The third option "a = (b + 1) * a" is equivalent to "a = a * (b + 1)". Therefore, all of the above options are correct ways to write the given operation.

Submit
10. public class myfile   {     public static void main (string[] args)     {         string biz = args[1];         string baz = args[2];         string rip = args[3];         System.out.println("arg is " + rip);     }   } Select how you would start the program to cause it to print: arg is 2

Explanation

The program takes command line arguments and assigns them to variables biz, baz, and rip. The program then prints the value of the rip variable. In order to cause it to print "arg is 2", the command line arguments should be "java myfile 1 3 2 2".

Submit
11. What is the output of the following program? public class Test {     public static void main(String[] args)     {         double data = 444.324;         int sum = 9;         float value = 5.1f;         System.out.println(data + sum + value);               } }

Explanation

The program first adds the double variable "data" and the integer variable "sum", resulting in 453.324. Then, it adds the float variable "value" to the previous result, resulting in 458.42399. This value is then printed as the output.

Submit
12. What type of array is generally generated in command-line argument?

Explanation

A jagged array is a type of array that contains other arrays as its elements. Each of these arrays can have a different length, allowing for more flexibility in storing data. In the context of command-line arguments, a jagged array is often used to store multiple arguments, where each argument is represented by a separate array. This allows for easy access and manipulation of the arguments within the program. Therefore, a jagged array is generally generated in command-line arguments.

Submit
13. Which of the following cannot be a variable name in c?

Explanation

In C, "Volatile" cannot be a variable name because it is a reserved keyword. Reserved keywords are predefined words that have special meanings in the programming language and cannot be used as variable names. "True", "Friend", and "Export" can all be variable names in C.

Submit
14. what will be the output of the program? public class test  {     private static int[] x;     public static void main(string[] args)     {         system.out.println(x[0]);     }  }

Explanation

The program will throw a NullPointerException at runtime because the array "x" is declared but not initialized. Therefore, when trying to access the first element of the array (x[0]), it will throw a NullPointerException.

Submit
15. Which of the following statements about member functions are true or false.
  1. A member function can call another member function directly with using the dot operator.
  2. Member function can access  the private data of the class.

Explanation

The first statement is false because a member function can call another member function directly using the dot operator. The second statement is true because member functions can access the private data of the class they belong to.

Submit
16. Which cause a compiler error?

Explanation

The given line of code "int [ ][ ] scores = {2,7,6}, {9,3,45};" causes a compiler error because the array initializer is not properly formatted. In a 2D array, each row should be enclosed in curly braces, but in this case, the second row is not enclosed correctly. To fix the error, the code should be written as "int [ ][ ] scores = {{2,7,6}, {9,3,45}};".

Submit
17. After defining the function template, the next step to call it in another function such as ______________

Explanation

After defining the function template, the next step is to call it in another function such as "main()". The "main()" function is the entry point of a C++ program, and it is where the program execution begins. Therefore, calling the function template in "main()" allows the program to utilize and execute the template code.

Submit
18. If a program uses inline function, then the function is expanded inline at ____________

Explanation

When a program uses an inline function, the function is expanded inline at run time. This means that instead of the function call, the actual code of the function is inserted at the location where the function is called. This can lead to faster execution as it eliminates the overhead of a function call. However, this expansion happens at run time, not at compile time. Therefore, the correct answer is run time.

Submit
19. Static variables are like ___________ as they are declared in a class declaration and defined in the source file.

Explanation

Static variables are like non-inline member functions as they are declared in a class declaration and defined in the source file. Non-inline member functions are defined outside the class declaration and can be accessed using the scope resolution operator (::). Similarly, static variables are also defined outside the class declaration and can be accessed using the scope resolution operator.

Submit
20. What will happen if the below program is executed? #include  int main()  int main =3;  printf("%d", main);  return 0;  }

Explanation

The program will run without any error and print the value 3. This is because the variable "main" is declared as an integer and assigned the value 3. The printf statement then prints the value of "main", which is 3. There are no syntax errors or logical errors in the code, so it will execute successfully.

Submit
21. Which of the following application makes use of a circular linked list?

Explanation

The correct answer is "Allocating CPU to resources". A circular linked list is used in the context of allocating CPU to resources because it allows for efficient management of resources in a cyclical manner. This means that once a resource is allocated, it can be deallocated and then reallocated to another process in a continuous loop. This is particularly useful in scenarios where resources need to be shared among multiple processes in a round-robin fashion.

Submit
22. What will be the output :   int i=25;   byte b=(byte)i;   System.out.println(b);

Explanation

The output will be -1. In this code, the integer value 25 is assigned to the variable 'i'. Then, the value of 'i' is explicitly casted to a byte data type and assigned to the variable 'b'. The byte data type can hold values from -128 to 127. Since 25 is within this range, the value remains the same. However, when the value of 'b' is printed using System.out.println, it is displayed as -1 because the byte data type is signed and the most significant bit is interpreted as a sign bit.

Submit
23. What is the time complexity of inserting a node in a doubly linked list?

Explanation

The time complexity of inserting a node in a doubly linked list is O(1). This is because in a doubly linked list, each node contains references to both the previous and the next node. Therefore, when inserting a new node, we only need to update the references of the new node and its adjacent nodes, which can be done in constant time regardless of the size of the list.

Submit
24. What is the maximum possible number of edges in a directed graph with no self loops having 8 vertices?

Explanation

The maximum possible number of edges in a directed graph with no self loops can be calculated using the formula n(n-1), where n is the number of vertices. In this case, with 8 vertices, the maximum possible number of edges would be 8(8-1) = 56.

Submit
25. The given array is arr = {2,6,1}. What are the pivots that are returned as a result of subsequent partitioning?

Explanation

The given array {2,6,1} does not have any pivots as a result of subsequent partitioning. In order to have a pivot, the array needs to be partitioned around a specific element. However, in this case, the array is not being partitioned, so there are no pivots returned.

Submit
26. The following expression can be substituted for.     if (isalpha(c) && isdigit(c))

Explanation

not-available-via-ai

Submit
27. The maximum number of arguments that can be passed in a single function are_________________

Explanation

The correct answer is 253. In most programming languages, including C and C++, the maximum number of arguments that can be passed in a single function is limited by the size of the stack. The stack is a limited amount of memory allocated for each function call, and it is used to store local variables and function arguments. The size of the stack determines the maximum number of arguments that can be passed. In many systems, the default stack size is 8 MB, and each argument typically takes up 4 bytes of memory. Therefore, the maximum number of arguments would be 8 MB / 4 bytes = 2,097,152 arguments. However, some memory is also needed for other purposes, so the practical limit is usually lower. In this case, the correct answer is 253, which is a reasonable limit for most practical purposes.

Submit
28. Which interface provides the capability to store objects using a key-value pair?

Explanation

The correct answer is java.util.map. The java.util.map interface provides the capability to store objects using a key-value pair. It allows you to associate a value with a unique key and retrieve the value using that key. The map interface is commonly used to implement data structures such as hash tables and dictionaries.

Submit
29. Which statement gets affected when i++ is changed to ++i?

Explanation

Changing i++ to ++i in the given code will affect the statement "a = i++;". With i++ as the post-increment operator, the value of i will be assigned to a and then incremented by 1. However, if we change it to ++i, the value of i will be incremented by 1 first and then assigned to a. Therefore, the value of a will be different depending on whether we use i++ or ++i.

Submit
30. What will be the output of the program? public class arraytest   {     public static void main(string[ ] args)     {         float f1[ ], f2[ ];         f1 = new float[10];         f2 = f1;         System.out.println("f2[0] = " + f2[0]);     }   }

Explanation

The program creates two float arrays, f1 and f2, with a size of 10. The reference variable f2 is then assigned to the same memory location as f1. Since f1 is a newly created array, all of its elements are initialized to the default value of 0.0. Therefore, when accessing f2[0], which points to the same memory location as f1[0], the output will be 0.0.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 18, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 18, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 04, 2018
    Quiz Created by
    Code_Quest_2k18
Cancel
  • All
    All (30)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
User-defined data type can be derived by_____________
Size of a union is determined by size of the.
Members of a union are accessed as________________
If an argument to a function is declared as const, then
Runtime polymorphism is achieved by____________
C++ exception handling mechanism mainly uses how many keywords?
Which of the following is/are the new cast operators used in c++. ...
With what data structure can a priority queue be implemented ?
Operation "a = a * b + a" can also be written as :
Public class myfile ...
What is the output of the following program? ...
What type of array is generally generated in command-line argument?
Which of the following cannot be a variable name in c?
What will be the output of the program? ...
Which of the following statements about member functions are true or...
Which cause a compiler error?
After defining the function template, the next step to call it in...
If a program uses inline function, then the function is expanded...
Static variables are like ___________ as they are declared in a class...
What will happen if the below program is executed?...
Which of the following application makes use of a circular linked...
What will be the output : ...
What is the time complexity of inserting a node in a doubly linked...
What is the maximum possible number of edges in a directed graph with...
The given array is arr = {2,6,1}. What are the pivots that are...
The following expression can be substituted for. ...
The maximum number of arguments that can be passed in a single...
Which interface provides the capability to store objects using a...
Which statement gets affected when i++ is changed to ++i?
What will be the output of the program? ...
Alert!

Advertisement