Search Previous Year Questions

Find real questions from previous competitive exam papers with answers and solutions.

Leave the keyword blank to browse saved questions for your selected exam, newest papers first. Add a keyword, year or topic to narrow the results.

Browse complete papers
Showing 10 question(s)
Clear

Question 151

UP police programmer Grade 2 2013• Part 2: Computer Programming

int i=7,*p=&i,&r=i;

i=5;

output after the statement cout<<i<<“ ”<<*p<<“ ”<<r; would be

  1. AOption (a)

    577

  2. BOption (b)

    555

  3. COption (c)

    777

  4. DOption (d)

    755

View answer & explanation

Correct answer

Answer: (b)B.

555

Why this answer is correct

The correct answer is : option 2

Key Points

Code:

int i = 7; int *p = &i; int &r = i;

i = 5;

cout << i << " " << *p << " " << r;

Step-by-Step Explanation:

  • int i = 7; → Variable i is initialized to 7.
  • int *p = &i; → Pointer p holds the address of i.
  • int &r = i; → r is a reference to i.
  • i = 5; → Value of i is changed to 5.

Now, evaluate the output:

  • i → 5
  • *p → dereferencing pointer to i → 5
  • r → reference to i → 5

Final Output: 5 5 5

Correct Answer: Option 2) 555 ✅

Question 152

UP police programmer Grade 2 2013• Part 2: Computer Programming

The frequency band 2.4GHz- 2.4835GHz belongs to _________ systems.

  1. AOption (a)

    ISM band

  2. BOption (b)

    Bluetooth

  3. COption (c)

    IEEE 802.11a

  4. DOption (d)

    All of the above

View answer & explanation

Correct answer

Answer: (a)A.

ISM band

Why this answer is correct

The correct answer is : option 1 

Key Points

Option Analysis:

Option 1) ISM band

✅ Correct. The 2.4 GHz – 2.4835 GHz frequency band is part of the Industrial, Scientific, and Medical (ISM) radio bands defined by the ITU. This band is license-free and widely used for short-range, low-power communications.

Option 2) Bluetooth

⚠️ Partially True. Bluetooth operates in the ISM band (specifically 2.402 GHz – 2.480 GHz), which lies within the 2.4–2.4835 GHz range. However, Bluetooth is a technology that uses the ISM band, not a band classification itself.

Option 3) IEEE 802.11a

❌ Incorrect. IEEE 802.11a is a Wi-Fi standard that operates in the 5 GHz frequency band, not in the 2.4 GHz band. So, it does not belong to the 2.4–2.4835 GHz range.

Option 4) All of the above

❌ Incorrect. While both ISM and Bluetooth relate to this band, IEEE 802.11a does not. Hence, "All of the above" is not valid.

Final Conclusion:

The question specifically asks about which system the frequency band belongs to. The correct classification of the 2.4–2.4835 GHz band is the ISM band.

✅ Correct Answer: Option 1) ISM band

Question 153

UP police programmer Grade 2 2013• Part 2: Computer Programming

In Java which class cannot be a subclass ?

  1. AOption (a)

    Abstract

  2. BOption (b)

    Parent

  3. COption (c)

    Final

  4. DOption (d)

    None

View answer & explanation

Correct answer

Answer: (c)C.

Final

Why this answer is correct

The correct answer is Final

Key Points

  • Abstract: ❌ An abstract class can be subclassed. It serves as a base class for other classes to inherit and is often used to define common behaviors.
  • Parent: ❌ A parent class can be subclassed to create child classes. This is the essence of inheritance in Java.
  • Final: ✅ A final class cannot be subclassed in Java. When a class is declared as final, it cannot be extended or inherited by any other class.
  • None: ❌ This is incorrect because there is a valid option (Final) that cannot be subclassed.

Additional Information

  • Usage of Final Class: Final classes are used when you want to prevent inheritance, ensuring the integrity of the class's behavior.
  • Example: The String class in Java is a final class, which means it cannot be subclassed.
  • Syntax: To declare a final class: public final class MyClass { // class body }

Hence, the correct answer is: option 3) Final

Question 154

UP police programmer Grade 2 2013• Part 2: Computer Programming

Which of the following parallel programming library doesn’t support shared memory architecture ?

  1. AOption (a)

    OpenMP 

  2. BOption (b)

    MPI 

  3. COption (c)

    PThreads 

  4. DOption (d)

    None of the above

View answer & explanation

Correct answer

Answer: (b)B.

MPI 

Why this answer is correct

The correct answer is MPI

Key Points

  • MPI (Message Passing Interface): ✅ MPI is a library designed for distributed memory systems, where processes communicate through message passing. It does not support shared memory architecture directly as it focuses on inter-process communication in distributed environments.
  • OpenMP: ❌ OpenMP is designed for shared memory systems and provides a parallel programming model based on threads, making it suitable for shared memory architecture.
  • PThreads: ❌ POSIX Threads (PThreads) is a threading library that supports shared memory systems, allowing threads to share memory and data for efficient parallel execution.
  • None of the above: ❌ This option is incorrect as MPI does not support shared memory architecture.

Additional Information

  • Shared Memory Architecture: In shared memory systems, multiple processors access a common memory space, and parallel programming libraries like OpenMP and PThreads are used to exploit this architecture.
  • Distributed Memory Architecture: In distributed memory systems, each processor has its own local memory, and communication between processors is achieved through message passing, which is the focus of MPI.

Hence, the correct answer is: option 2) MPI

Question 155

UP police programmer Grade 2 2013• Part 2: Computer Programming

If we draw a binary search tree of the sequence 30 9 15 45 24 8 5 75 50 80. Then the no. of nodes in left sub tree, right sub tree and height of the tree are as follows: (note: empty tree is considered of height 0)

  1. AOption (a)

    5 4 3 

  2. BOption (b)

    5 4 4

  3. COption (c)

    6 5 4

  4. DOption (d)

    6 5 3

View answer & explanation

Correct answer

Answer: (a)A.

5 4 3 

Why this answer is correct

The correct answer is : option 1

Key Points

Step-by-Step BST Construction:

  1. Insert 30 → root
  2. Insert 9 → left of 30
  3. Insert 15 → right of 9
  4. Insert 45 → right of 30
  5. Insert 24 → right of 15
  6. Insert 8 → left of 9
  7. Insert 5 → left of 8
  8. Insert 75 → right of 45
  9. Insert 50 → left of 75
  10. Insert 80 → right of 75

Resulting BST Structure:

30 /
9 45 / \
8 15 75 / \ /
5 24 50 80

Left Subtree of 30:

Nodes: 9, 8, 5, 15, 24 → Total = 5 nodes

Right Subtree of 30:

Nodes: 45, 75, 50, 80 → Total = 4 nodes

Height of the Tree:

Longest path from root to leaf:

  • Path 1: 30 → 9 → 8 → 5 → 4 nodes
  • Path 2: 30 → 45 → 75 → 80 → 4 nodes

So, height = total edges = 4 - 1 = 3 (since root is level 0)

✅ Final Answer:

  • Left Subtree Nodes: 5
  • Right Subtree Nodes: 4
  • Height: 3

✔ Correct Option: Option 1) 5 4 3

Question 156

UP police programmer Grade 2 2013• Part 2: Computer Programming

Which syntax is correct in order to parallelize a for loop in OpenMP ?

  1. AOption (a)

    #pragma parallel for

  2. BOption (b)

    #for parallel

  3. COption (c)

    pragma omp parallel for

  4. DOption (d)

    pragma openmp parallel for

View answer & explanation

Correct answer

Answer: (c)C.

pragma omp parallel for

Why this answer is correct

The correct answer is # pragma omp parallel for

Key Points

  • # pragma omp parallel for: ✅ This is the correct syntax used in OpenMP to parallelize a for loop. OpenMP is a widely-used API for parallel programming in C, C++, and Fortran. The directive tells the compiler to execute the iterations of the loop in parallel.
  • #pragma parallel for: ❌ This is an incorrect syntax. OpenMP requires the omp keyword for its directives.
  • #for parallel: ❌ This is not a valid OpenMP syntax for parallelizing loops.
  • # pragma openmp parallel for: ❌ The keyword "openmp" is incorrect. OpenMP directives use "omp" as the identifier.

Additional Information

  • OpenMP Basics: OpenMP allows developers to use multi-threading in applications, enabling better performance on multi-core processors.
  • Directive Syntax: OpenMP directives always start with #pragma omp, followed by a specific instruction (e.g., parallel, for).
  • Parallelizing Loops: The parallel for directive splits the iterations of a loop among multiple threads, reducing execution time for large loops.

Hence, the correct answer is: option 3) # pragma omp parallel for

Question 157

UP police programmer Grade 2 2013• Part 2: Computer Programming

Which is an example of functional programming language among the following ? 

  1. AOption (a)

    Haskell

  2. BOption (b)

    Java 

  3. COption (c)

    Python 

  4. DOption (d)

    Fortran

View answer & explanation

Correct answer

Answer: (a)A.

Haskell

Why this answer is correct

The correct answer is Haskell

Key Points

  • Haskell: ✅ Haskell is a widely used functional programming language. It emphasizes immutability, higher-order functions, and declarative programming paradigms, making it a perfect example of a functional programming language.
  • Java: ❌ Java is primarily an object-oriented programming language, though it supports some functional programming features like lambda expressions and streams.
  • Python: ❌ Python is a multi-paradigm programming language that supports functional, object-oriented, and procedural programming, but it is not purely functional.
  • Fortran: ❌ Fortran is primarily a procedural programming language, mainly used in scientific and numerical computing.

Additional Information

  • Functional Programming: Functional programming is a programming paradigm where programs are constructed by applying and composing functions. It avoids changing state and mutable data, focusing on declarative code.
  • Examples of Functional Programming Languages: Haskell, Lisp, Scala, and Clojure are examples of functional programming languages.

Hence, the correct answer is: option 1) Haskell

Question 158

UP police programmer Grade 2 2013• Part 2: Computer Programming

A __________ is a method of producing ciphertext in which a cryptographic key and algorithm are applied to a block of data. 

  1. AOption (a)

    stream cipher

  2. BOption (b)

    block cipher

  3. COption (c)

    both (1) and (2)

  4. DOption (d)

    None of the above

View answer & explanation

Correct answer

Answer: (b)B.

block cipher

Why this answer is correct

The correct answer is block cipher

Key Points

  • Block cipher: ✅ A block cipher is a method of encrypting data where a cryptographic key and algorithm are applied to fixed-size blocks of data (e.g., 64 or 128 bits) at a time, rather than encrypting data bit by bit.
  • Stream cipher: ❌ A stream cipher encrypts data one bit or byte at a time, rather than processing it in blocks.
  • Both (1) and (2): ❌ This option is incorrect because block ciphers and stream ciphers are distinct methods of encryption.
  • None of the above: ❌ This option is incorrect because the correct method is block cipher.

Additional Information

  • Examples of Block Ciphers: Common examples of block cipher algorithms include AES (Advanced Encryption Standard), DES (Data Encryption Standard), and Blowfish.
  • Security: Block ciphers are widely used for secure communications, such as in SSL/TLS protocols, and are considered more secure than stream ciphers for most applications.

Hence, the correct answer is: option 2) block cipher

Question 159

UP police programmer Grade 2 2013• Part 2: Computer Programming

Which of the following variable declaration would not be compiled in a Java program ? 

  1. AOption (a)

    int var; 

  2. BOption (b)

    int VAR; 

  3. COption (c)

    int var1;

  4. DOption (d)

    int 1_var

View answer & explanation

Correct answer

Answer: (d)D.

int 1_var

Why this answer is correct

The correct answer is: Option 4) int 1_var

Key Points

  • Java Variable Naming Rules:
  • Variable names must begin with a letter (A-Z or a-z), _ (underscore), or $ (dollar sign).
  • Variable names cannot start with a digit (0-9).
  • Variable names can only contain letters, digits, underscores, or dollar signs.
  • Variable names are case-sensitive.
  • Reserved keywords in Java cannot be used as variable names.
  • Analysis of each option:
  • int var; ✅ This is a valid declaration. The variable name starts with a letter and follows the naming rules.
  • int VAR; ✅ This is a valid declaration. Variable names are case-sensitive, so VAR is valid and distinct from var.
  • int var1; ✅ This is a valid declaration. The variable name starts with a letter and contains a digit, which is allowed after the first character.
  • int 1_var; ❌ This is invalid because the variable name starts with a digit, which violates the Java variable naming rules.

Additional Information

  • Java Reserved Keywords: Examples include int, class, static, void, etc. These cannot be used as variable names.
  • Best Practices: Use descriptive names for variables to improve code readability.

Hence, the correct answer is: Option 4) int 1_var$

Question 160

UP police programmer Grade 2 2013• Part 2: Computer Programming

_____________ is NOT a goal of the Routing Protocol.

  1. AOption (a)

    decrease routing-related overhead

  2. BOption (b)

    find short routes

  3. COption (c)

    find stable routes

  4. DOption (d)

    none of the above

View answer & explanation

Correct answer

Answer: (d)D.

none of the above

Why this answer is correct

The correct answer is Option 4) none of the above

Key Points

  • Routing Protocol Goals: Routing protocols are designed to find the most efficient, stable, and shortest paths for data packets to travel within a network. Their primary goals include:
  • ✅ Decreasing routing-related overhead: Reducing the amount of resources (CPU, memory, bandwidth) used during routing processes.
  • ✅ Finding short routes: Ensuring that data packets take the most optimal and shortest path to their destination.
  • ✅ Finding stable routes: Ensuring that the routes selected are reliable and do not frequently change due to network instability.
  • Analysis of Options:
  • Option 1: "Decrease routing-related overhead" is a valid goal of routing protocols to make them efficient. Hence, this is NOT the correct answer.
  • Option 2: "Find short routes" is a key goal of routing protocols to optimize network performance. Hence, this is NOT the correct answer.
  • Option 3: "Find stable routes" is essential for ensuring reliable communication. Hence, this is NOT the correct answer.
  • Option 4: "None of the above" is correct because all the listed goals (Options 1, 2, and 3) are valid objectives of routing protocols.

Additional Information

  • Purpose of Routing Protocols: Routing protocols enable routers to communicate with each other and dynamically adapt to changes in the network topology to ensure efficient and reliable data transmission.
  • Examples: Common routing protocols include RIP (Routing Information Protocol), OSPF (Open Shortest Path First), and EIGRP (Enhanced Interior Gateway Routing Protocol).

Hence, the correct answer is: Option 4) none of the above

Page 16
Next