File size: 33,292 Bytes
9aaf868 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 |
"""
Contains 200 example coding multiple choice questions for the demo application,
organized by category.
"""
# Define the examples by category
CODING_EXAMPLES_BY_CATEGORY = {
"Python": [
{
"question": "Which of the following is NOT a valid way to iterate through a list in Python?",
"choices": [
"for item in my_list:",
"for i in range(len(my_list)):",
"for index, item in enumerate(my_list):",
"for item from my_list:",
],
"answer": "D",
},
{
"question": "In Python, what does the `__str__` method do?",
"choices": [
"Returns a string representation of an object for developers",
"Returns a string representation of an object for end users",
"Converts a string to an object",
"Checks if an object is a string",
],
"answer": "B",
},
{
"question": "What is the output of this Python code: `print(list(filter(lambda x: x % 2 == 0, range(10))))`?",
"choices": [
"[0, 2, 4, 6, 8]",
"[1, 3, 5, 7, 9]",
"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
"[]",
],
"answer": "A",
},
{
"question": "What is the output of the following Python code?\nx = [1, 2, 3]\ny = x\ny.append(4)\nprint(x)",
"choices": ["[1, 2, 3]", "[1, 2, 3, 4]", "[4, 1, 2, 3]", "Error"],
"answer": "B",
},
{
"question": "What is the correct way to check if two variables point to the same object in Python?",
"choices": ["is", "==", "equals()", "==="],
"answer": "A",
},
{
"question": "What is the output of this Python code?\nprint(0.1 + 0.2 == 0.3)",
"choices": ["False", "True", "Error", "None"],
"answer": "A",
},
{
"question": "In Python, what is a generator?",
"choices": [
"A function that returns an iterator",
"A tool that creates new modules",
"A class that generates random numbers",
"A method for creating new objects",
],
"answer": "A",
},
{
"question": "In Python, what does the `*args` parameter do?",
"choices": [
"Allows a function to accept a variable number of positional arguments",
"Makes arguments optional",
"Multiplies all arguments",
"Unpacks a dictionary into keyword arguments",
],
"answer": "A",
},
{
"question": "What is the output of `print(2 ** 3 ** 2)` in Python?",
"choices": ["64", "36", "512", "None of the above"],
"answer": "C",
},
{
"question": "What does the `collections.Counter` class in Python do?",
"choices": [
"Counts occurrences of elements in an iterable",
"Implements a countdown timer",
"Tracks the number of function calls",
"Counts the number of objects in memory",
],
"answer": "A",
},
{
"question": "What is the output of `print(list(zip([1, 2, 3], [4, 5, 6, 7])))`?",
"choices": [
"[(1, 4), (2, 5), (3, 6)]",
"[(1, 4), (2, 5), (3, 6), (None, 7)]",
"[(1, 4), (2, 5), (3, 6), (7, None)]",
"Error",
],
"answer": "A",
},
{
"question": "What is a Python decorator?",
"choices": [
"A function that takes another function and extends its behavior",
"A design pattern for creating objects",
"A tool for formatting code",
"A class for implementing UI elements",
],
"answer": "A",
},
{
"question": "What is the output of `print([i for i in range(10) if i % 2 == 0])`?",
"choices": [
"[0, 2, 4, 6, 8]",
"[1, 3, 5, 7, 9]",
"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]",
"[]",
],
"answer": "A",
},
{
"question": "What is the purpose of `__init__.py` files in Python packages?",
"choices": [
"To mark a directory as a Python package",
"To initialize variables when a package is imported",
"To document the package contents",
"To define package-level constants",
],
"answer": "A",
},
{
"question": "What is the output of `print(sum(range(5)))`?",
"choices": ["10", "15", "4", "Error"],
"answer": "A",
},
],
"JavaScript": [
{
"question": "What is a closure in JavaScript?",
"choices": [
"A function that remembers its lexical scope",
"A way to close browser windows",
"A method to terminate functions",
"A design pattern for security",
],
"answer": "A",
},
{
"question": "Which of these is NOT a JavaScript framework/library?",
"choices": ["React", "Angular", "Django", "Vue"],
"answer": "C",
},
{
"question": "Which of these is a valid way to declare a constant in JavaScript?",
"choices": [
"const PI = 3.14",
"constant PI = 3.14",
"final PI = 3.14",
"define PI = 3.14",
],
"answer": "A",
},
{
"question": 'What does the "this" keyword refer to in JavaScript?',
"choices": [
"The current object",
"The parent object",
"The global window object",
"The function itself",
],
"answer": "A",
},
{
"question": "What is the difference between `==` and `===` in JavaScript?",
"choices": [
"`==` checks equality with type conversion, `===` checks equality without type conversion",
"`==` checks reference equality, `===` checks value equality",
"`==` is used for numbers, `===` is used for strings",
"There is no difference",
],
"answer": "A",
},
{
"question": "What does the `async/await` feature do in JavaScript?",
"choices": [
"Simplifies asynchronous programming",
"Creates multithreaded code",
"Prevents memory leaks",
"Optimizes rendering in browsers",
],
"answer": "A",
},
{
"question": "What is the main purpose of Redux in web development?",
"choices": [
"State management",
"DOM manipulation",
"Server-side rendering",
"API communication",
],
"answer": "A",
},
{
"question": "Which of the following is NOT a primitive type in JavaScript?",
"choices": ["number", "string", "boolean", "array"],
"answer": "D",
},
{
"question": "What is the output of `console.log(typeof null)` in JavaScript?",
"choices": ["'object'", "'null'", "'undefined'", "Error"],
"answer": "A",
},
{
"question": "What is event bubbling in JavaScript?",
"choices": [
"When an event triggers on an element and then propagates up to parent elements",
"When multiple events occur simultaneously",
"When events are queued for later execution",
"When events are canceled before execution",
],
"answer": "A",
},
{
"question": "What is the output of `console.log(1 + '2' + 3)` in JavaScript?",
"choices": ["'123'", "6", "'33'", "Error"],
"answer": "A",
},
{
"question": "What is a JavaScript Promise?",
"choices": [
"An object representing a future completion or failure of an asynchronous operation",
"A guarantee that a function will execute without errors",
"A contract between different parts of an application",
"A method for securing API endpoints",
],
"answer": "A",
},
],
"SQL & Databases": [
{
"question": 'What does the SQL function "ROUND()" do?',
"choices": [
"Rounds a number to the nearest integer",
"Concatenates two or more strings",
"Converts a string to lowercase",
"Returns the length of a string",
],
"answer": "A",
},
{
"question": "What does ACID stand for in database systems?",
"choices": [
"Atomicity, Consistency, Isolation, Durability",
"Associativity, Commutativity, Identity, Distributivity",
"Authentication, Cryptography, Integrity, Decentralization",
"Availability, Consistency, Integration, Distribution",
],
"answer": "A",
},
{
"question": "What is the purpose of normalization in databases?",
"choices": [
"To reduce data redundancy and improve data integrity",
"To improve query performance",
"To encrypt sensitive data",
"To compress data and save storage space",
],
"answer": "A",
},
{
"question": "Which SQL statement is used to retrieve data from a database?",
"choices": ["SELECT", "FETCH", "GET", "RETRIEVE"],
"answer": "A",
},
{
"question": "What does the SQL command `GROUP BY` do?",
"choices": [
"Groups rows based on a column value",
"Sorts rows in ascending order",
"Filters rows based on a condition",
"Joins two tables",
],
"answer": "A",
},
{
"question": "What is the purpose of the `HAVING` clause in SQL?",
"choices": [
"To filter groups that match a condition",
"To join tables",
"To select columns",
"To sort results",
],
"answer": "A",
},
{
"question": "What is a primary key in a database?",
"choices": [
"A unique identifier for each record",
"The first column in a table",
"The fastest way to query data",
"A mandatory field in every table",
],
"answer": "A",
},
{
"question": "What is the difference between `DELETE` and `TRUNCATE` in SQL?",
"choices": [
"`DELETE` can use WHERE condition, `TRUNCATE` removes all rows",
"`DELETE` is faster, `TRUNCATE` is slower",
"`DELETE` is for tables, `TRUNCATE` is for databases",
"`DELETE` is permanent, `TRUNCATE` can be rolled back",
],
"answer": "A",
},
{
"question": "Which of these is a NoSQL database?",
"choices": ["MongoDB", "MySQL", "PostgreSQL", "Oracle"],
"answer": "A",
},
{
"question": "What is a foreign key in a relational database?",
"choices": [
"A field that links to a primary key in another table",
"A key used for encryption",
"A key that must be unique across all tables",
"A backup key used when the primary key fails",
],
"answer": "A",
},
{
"question": "What is the purpose of an index in a database?",
"choices": [
"To improve query performance",
"To enforce data integrity",
"To encrypt sensitive data",
"To compress data storage",
],
"answer": "A",
},
],
"Algorithms & Data Structures": [
{
"question": "What is the time complexity of binary search?",
"choices": ["O(1)", "O(log n)", "O(n)", "O(n²)"],
"answer": "B",
},
{
"question": "Which data structure would be most efficient for implementing a priority queue?",
"choices": ["Array", "Linked List", "Heap", "Stack"],
"answer": "C",
},
{
"question": "Which of these sorting algorithms has the worst worst-case time complexity?",
"choices": ["Merge sort", "Quick sort", "Heap sort", "Bubble sort"],
"answer": "D",
},
{
"question": "In Big O notation, which of these is the most efficient?",
"choices": ["O(n²)", "O(n log n)", "O(n)", "O(1)"],
"answer": "D",
},
{
"question": "What is a recursive function?",
"choices": [
"A function that calls itself",
"A function that runs in the background",
"A function that cannot be modified",
"A function that returns multiple values",
],
"answer": "A",
},
{
"question": "Which algorithm is used for finding the shortest path in a weighted graph?",
"choices": ["Dijkstra's algorithm", "Binary search", "Quicksort", "Depth-first search"],
"answer": "A",
},
{
"question": "Which of these sorting algorithms has the best average-case time complexity?",
"choices": ["Merge Sort", "Bubble Sort", "Insertion Sort", "Selection Sort"],
"answer": "A",
},
{
"question": "Which data structure follows the LIFO (Last In First Out) principle?",
"choices": ["Stack", "Queue", "Linked List", "Tree"],
"answer": "A",
},
{
"question": "What is the time complexity of inserting an element into a hash table?",
"choices": ["O(1) average case", "O(log n)", "O(n)", "O(n²)"],
"answer": "A",
},
{
"question": "What is the space complexity of a recursive Fibonacci implementation?",
"choices": ["O(n)", "O(log n)", "O(1)", "O(2^n)"],
"answer": "A",
},
{
"question": "What is the primary advantage of a B-tree over a binary search tree?",
"choices": [
"Better performance with disk-based storage",
"Simpler implementation",
"Lower memory usage",
"Faster in-memory operations",
],
"answer": "A",
},
{
"question": "What is the worst-case time complexity of quicksort?",
"choices": ["O(n²)", "O(n log n)", "O(n)", "O(log n)"],
"answer": "A",
},
{
"question": "Which data structure is most suitable for implementing a dictionary?",
"choices": ["Hash Table", "Array", "Linked List", "Stack"],
"answer": "A",
},
{
"question": "What is the time complexity of breadth-first search on a graph?",
"choices": ["O(V + E)", "O(V * E)", "O(log V)", "O(V²)"],
"answer": "A",
},
{
"question": "What is dynamic programming?",
"choices": [
"A method for solving complex problems by breaking them into simpler subproblems",
"A programming paradigm that uses dynamic typing",
"A technique for automatically allocating memory",
"A method for optimizing code at runtime",
],
"answer": "A",
},
],
"Web Development": [
{
"question": "Which of these is NOT a RESTful API method?",
"choices": ["GET", "PUT", "SEARCH", "DELETE"],
"answer": "C",
},
{
"question": "What does CSS stand for?",
"choices": [
"Computer Style Sheets",
"Creative Style System",
"Cascading Style Sheets",
"Colorful Style Sheets",
],
"answer": "C",
},
{
"question": "Which protocol is used for secure web browsing?",
"choices": ["HTTP", "FTP", "HTTPS", "SMTP"],
"answer": "C",
},
{
"question": "In CSS, which property is used to change the text color of an element?",
"choices": ["color", "text-color", "font-color", "text-style"],
"answer": "A",
},
{
"question": "What is the purpose of the `useState` hook in React?",
"choices": [
"To add state to functional components",
"To create side effects in components",
"To optimize rendering performance",
"To handle form submissions",
],
"answer": "A",
},
{
"question": "What does API stand for?",
"choices": [
"Application Programming Interface",
"Automated Program Interaction",
"Application Process Integration",
"Advanced Programming Implementation",
],
"answer": "A",
},
{
"question": "What is JWT used for?",
"choices": [
"Authentication and information exchange",
"JavaScript web testing",
"Java web toolkit",
"JSON web transformation",
],
"answer": "A",
},
{
"question": "Which of these is NOT a valid HTTP status code?",
"choices": [
"200 OK",
"404 Not Found",
"500 Internal Server Error",
"600 Server Timeout",
],
"answer": "D",
},
{
"question": "What is the purpose of CORS in web development?",
"choices": [
"To allow or restrict resources from being requested from another domain",
"To optimize CSS rendering",
"To compress HTTP responses",
"To validate HTML syntax",
],
"answer": "A",
},
{
"question": "What is the difference between localStorage and sessionStorage?",
"choices": [
"localStorage persists after browser close, sessionStorage doesn't",
"localStorage has a smaller storage limit than sessionStorage",
"localStorage is encrypted, sessionStorage isn't",
"localStorage is for text only, sessionStorage can store objects",
],
"answer": "A",
},
{
"question": "What is the purpose of a service worker in web development?",
"choices": [
"To enable offline functionality and background processing",
"To manage server-side rendering",
"To optimize database queries",
"To handle user authentication",
],
"answer": "A",
},
{
"question": "What is the purpose of the `<meta viewport>` tag?",
"choices": [
"To control the viewport's size and scale for responsive design",
"To improve SEO rankings",
"To define metadata for social media sharing",
"To specify the character encoding of the document",
],
"answer": "A",
},
],
"Software Engineering & DevOps": [
{
"question": "Which design pattern is used when you need to create objects without specifying their concrete classes?",
"choices": [
"Observer Pattern",
"Factory Pattern",
"Singleton Pattern",
"Decorator Pattern",
],
"answer": "B",
},
{
"question": 'In version control, what does "git rebase" do?',
"choices": [
"Integrates changes from one branch onto another",
"Reverts all changes to the last commit",
"Creates a new branch",
"Deletes the remote repository",
],
"answer": "A",
},
{
"question": "What does the command `docker run` do?",
"choices": [
"Creates and starts a container",
"Builds a Docker image",
"Lists running containers",
"Stops a running container",
],
"answer": "A",
},
{
"question": "What is the purpose of containerization technologies like Docker?",
"choices": [
"To package applications with all dependencies",
"To create virtual machines",
"To encrypt sensitive data",
"To compress code for distribution",
],
"answer": "A",
},
{
"question": "What does MVC stand for in software architecture?",
"choices": [
"Model-View-Controller",
"Multiple-Version-Control",
"Most-Valuable-Component",
"Managed-Virtual-Container",
],
"answer": "A",
},
{
"question": "What does the `git pull` command do?",
"choices": [
"Fetches changes from a remote repository and merges them",
"Uploads local changes to a remote repository",
"Creates a new branch",
"Lists all commits",
],
"answer": "A",
},
{
"question": "What is the purpose of a load balancer?",
"choices": [
"Distributes network traffic across multiple servers",
"Increases the speed of database queries",
"Manages memory allocation in applications",
"Compresses data before storage",
],
"answer": "A",
},
{
"question": "Which of these is NOT a principle of SOLID?",
"choices": [
"Single responsibility",
"Open/closed",
"Liskov substitution",
"Dynamic typing",
],
"answer": "D",
},
{
"question": "What is the purpose of Continuous Integration (CI)?",
"choices": [
"To automatically build and test code changes",
"To deploy applications to production",
"To monitor application performance",
"To manage database migrations",
],
"answer": "A",
},
{
"question": "What is the difference between CI and CD?",
"choices": [
"CI is about integration and testing; CD is about delivery or deployment",
"CI is for code; CD is for databases",
"CI is manual; CD is automated",
"CI is for development; CD is for production only",
],
"answer": "A",
},
{
"question": "What is Infrastructure as Code (IaC)?",
"choices": [
"Managing infrastructure through code and automation",
"Writing code that runs on multiple platforms",
"Converting legacy systems to modern code",
"Implementing code reviews for infrastructure teams",
],
"answer": "A",
},
{
"question": "What is the purpose of a Kubernetes pod?",
"choices": [
"The smallest deployable unit that can contain one or more containers",
"A storage volume for container data",
"A network interface for container communication",
"A security policy for container isolation",
],
"answer": "A",
},
{
"question": "What is the purpose of a blue-green deployment?",
"choices": [
"To reduce downtime and risk by running two identical environments",
"To separate development and production environments",
"To implement color-coded security levels",
"To optimize resource usage in cloud environments",
],
"answer": "A",
},
],
"Programming Concepts": [
{
"question": "What is the result of `5 & 3` in binary operations?",
"choices": ["1", "7", "8", "15"],
"answer": "A",
},
{
"question": "What is the purpose of the `static` keyword in Java?",
"choices": [
"It makes a variable or method belong to the class, not instances",
"It prevents a class from being inherited",
"It restricts access to a method or variable",
"It makes a variable unchangeable",
],
"answer": "A",
},
{
"question": "In OOP, what is encapsulation?",
"choices": [
"The bundling of data and methods that operate on that data",
"The ability of a class to inherit from multiple classes",
"The hiding of implementation details",
"The ability of objects to take different forms",
],
"answer": "A",
},
{
"question": "Which language is primarily used for iOS development?",
"choices": ["Java", "Swift", "C#", "Kotlin"],
"answer": "B",
},
{
"question": "What is the difference between TCP and UDP?",
"choices": [
"TCP is connection-oriented; UDP is connectionless",
"TCP is secure; UDP is not",
"TCP is faster; UDP is more reliable",
"TCP is for web; UDP is for email",
],
"answer": "A",
},
{
"question": "Which of these is NOT a primitive data type in Java?",
"choices": ["int", "float", "String", "char"],
"answer": "C",
},
{
"question": "What is a memory leak?",
"choices": [
"Memory allocated that is never freed",
"When a program uses too much memory",
"When memory is corrupted by a virus",
"When cache memory overflows",
],
"answer": "A",
},
{
"question": "What is the purpose of the `virtual` keyword in C++?",
"choices": [
"It allows a method to be overridden in derived classes",
"It makes a class abstract",
"It restricts a class from being instantiated",
"It optimizes method calls at compile time",
],
"answer": "A",
},
{
"question": "What is the key feature of a blockchain?",
"choices": [
"Distributed immutable ledger",
"Centralized data storage",
"Fast transaction processing",
"Unlimited scalability",
],
"answer": "A",
},
{
"question": "Which protocol is used for sending emails?",
"choices": ["SMTP", "HTTP", "FTP", "SSH"],
"answer": "A",
},
{
"question": "What is the difference between a thread and a process?",
"choices": [
"Threads share memory space; processes have separate memory",
"Threads run on multiple CPUs; processes run on a single CPU",
"Threads are for I/O operations; processes are for computation",
"Threads are managed by the application; processes by the OS",
],
"answer": "A",
},
{
"question": "What is the purpose of a mutex?",
"choices": [
"To ensure only one thread can access a resource at a time",
"To speed up multi-threaded operations",
"To allocate memory dynamically",
"To compress data for transmission",
],
"answer": "A",
},
{
"question": "What is the difference between a stack and a heap in memory management?",
"choices": [
"Stack is for static memory allocation; heap is for dynamic allocation",
"Stack is slower; heap is faster",
"Stack is for global variables; heap is for local variables",
"Stack is managed by the OS; heap by the application",
],
"answer": "A",
},
],
"C & C++": [
{
"question": 'What is the output of this C code?\nint x = 5;\nprintf("%d", x++);\n',
"choices": ["5", "6", "4", "Error"],
"answer": "A",
},
{
"question": "What is a pointer in C?",
"choices": [
"A variable that stores the address of another variable",
"A variable that can point to multiple values",
"A function that returns multiple values",
"A special type of array",
],
"answer": "A",
},
{
"question": "What does the `const` keyword do in C++?",
"choices": [
"Declares that a variable or function cannot be modified",
"Creates a constant expression",
"Defines a compile-time constant",
"All of the above",
],
"answer": "D",
},
{
"question": "What is the difference between `new` and `malloc` in C++?",
"choices": [
"`new` calls constructors, `malloc` doesn't",
"`new` is faster than `malloc`",
"`new` is for arrays, `malloc` is for single objects",
"`new` is deprecated in modern C++",
],
"answer": "A",
},
{
"question": "What is the purpose of the `volatile` keyword in C?",
"choices": [
"Tells the compiler that a variable may change unexpectedly",
"Makes a variable thread-safe",
"Prevents a variable from being optimized",
"Stores the variable in non-volatile memory",
],
"answer": "A",
},
{
"question": "What is a memory leak in C++?",
"choices": [
"When memory is allocated with `new` but not freed with `delete`",
"When a program uses more memory than available",
"When memory is corrupted by buffer overflow",
"When memory is accessed after being freed",
],
"answer": "A",
},
{
"question": 'What is the output of this C code?\nint a = 10, b = 5;\nprintf("%d", a | b);\n',
"choices": ["15", "0", "5", "10"],
"answer": "A",
},
{
"question": "What is the purpose of the `inline` keyword in C++?",
"choices": [
"Suggests that the compiler replace function calls with the function body",
"Forces a function to be defined in a header file",
"Makes a function thread-safe",
"Prevents a function from being overridden",
],
"answer": "A",
},
{
"question": "What is the difference between a struct and a class in C++?",
"choices": [
"Members are public by default in struct, private in class",
"Structs cannot have methods, classes can",
"Structs are for POD types, classes for objects",
"Structs cannot be inherited from, classes can",
],
"answer": "A",
},
],
}
|