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 131

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

What are the following looping structures are available in javascripts ? 

  1. AOption (a)

    for, foreach

  2. BOption (b)

    foreach, while loop 

  3. COption (c)

    do-while loop, foreach

  4. DOption (d)

    for, while loop

View answer & explanation

Correct answer

Answer: (a)A.

for, foreach

Why this answer is correct

The correct answer is Option 1: for, foreach

Key Points

  • for loop: ✅ The for loop is a widely used looping structure in JavaScript. It allows you to iterate through a block of code a specific number of times.
  • foreach loop: ✅ The foreach loop is used to iterate over array elements. It applies a callback function to each element of the array.
  • while loop: ❌ The while loop is another valid looping structure in JavaScript, but it is not listed in Option 1, making it incorrect in this context.
  • do-while loop: ❌ The do-while loop is a valid looping structure in JavaScript, but it is not part of Option 1.

Additional Information

  • for loop: The syntax of a for loop is: for (initialization; condition; increment/decrement) { // code }. It is used for precise iteration over a known range.
  • foreach loop: The foreach loop is specifically designed for array traversal. Example syntax: array.forEach((element) => { // code }).
  • while loop: The while loop runs as long as the condition evaluates to true. Syntax: while (condition) { // code }.
  • do-while loop: The do-while loop runs the code at least once before checking the condition. Syntax: do { // code } while (condition);.

Hence, the correct answer is: Option 1: for, foreach

Question 132

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

How many hosts and subnets are possible if you have an IP of 151.242.16.49 with a subnet mask of 7 bits ?

  1. AOption (a)

    512 hosts and 126 subnets 

  2. BOption (b)

    512 hosts and 128 subnets

  3. COption (c)

    126 subnets and 510 hosts

  4. DOption (d)

    128 subnets and 510 hosts

View answer & explanation

Correct answer

Answer: (d)D.

128 subnets and 510 hosts

Why this answer is correct

The correct answer is : option 4

Key Points

Given an IP address: 151.242.16.49 and a subnet mask with 7 bits borrowed.

Step 1: Determine Class of IP

151 is in the range 128–191 → It is a Class B IP.

Default subnet mask for Class B = 255.255.0.0 → 16 bits for network.

Step 2: Subnetting Information

  • 7 bits are borrowed from host part (total 16+7 = 23 bits for network).
  • Remaining bits for host = 32 - 23 = 9 bits.

Step 3: Calculate Number of Subnets and Hosts

  • Number of subnets = 27 = 128
  • Number of hosts per subnet = 29 - 2 = 510
  • (We subtract 2 for network and broadcast addresses)

Final Answer: 128 subnets and 510 hosts

Correct Option: Option 4) ✅

Question 133

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

What will be output by the following code segment ?

int sum = 0;

int count = 1;

while (count < 5)

{ sum = sum + count;

count = count + 2;

}

System.out.println(sum);

  1. AOption (a)

    4

  2. BOption (b)

    5

  3. COption (c)

    7

  4. DOption (d)

    9

View answer & explanation

Correct answer

Answer: (a)A.

4

Why this answer is correct

The correcty answer is : option 1

Key Points

Code:

int sum = 0; int count = 1;

while (count < 5) { sum = sum + count; count = count + 2; }

System.out.println(sum);

Step-by-Step Execution:

  • Initial: sum = 0, count = 1
  • First Iteration:

count (1) < 5 → true

sum = 0 + 1 = 1

count = 1 + 2 = 3

  • Second Iteration:

count (3) < 5 → true

sum = 1 + 3 = 4

count = 3 + 2 = 5

  • Third Iteration:

count (5) < 5 → false → loop ends

Final Value of sum = 4

Output: 4

Correct Option: Option 1) 4 ✅

Question 134

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

To connect a computer with a device in the same room, you might be likely to use a _____ 

  1. AOption (a)

    coaxial cable

  2. BOption (b)

    ground station 

  3. COption (c)

    dedicated line

  4. DOption (d)

    none of the above

View answer & explanation

Correct answer

Answer: (a)A.

coaxial cable

Why this answer is correct

The correct answer is: coaxial cable

Key Points

  • Coaxial Cable: ✅ Coaxial cables are commonly used to connect a computer to devices such as routers, modems, or other peripherals in the same room. They are widely used for local area networking or connecting devices over short distances due to their reliability and speed.
  • Ground Station: ❌ Ground stations are used for satellite communication, not for connecting devices in the same room.
  • Dedicated Line: ❌ A dedicated line refers to a fixed, point-to-point connection often used for telecommunications or internet services, not for connecting devices within the same room.
  • None of the Above: ❌ This option is not correct since coaxial cable is the appropriate choice for this scenario.

Additional Information

  • Use Case: Coaxial cables are widely used for short-distance connections within the same room or building because they are cost-effective and have good shielding against electromagnetic interference.
  • Alternatives: Other connection types for devices in the same room could include Ethernet cables, USB connections, or wireless technologies such as Wi-Fi or Bluetooth.

Hence, the correct answer is: Option 1) Coaxial Cable

Question 135

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

When you normalize a relation by breaking it into two smaller relations, what must you do to maintain data integrity ? 

  1. AOption (a)

    Link the relations by a common field and create primary key for the new relation

  2. BOption (b)

    Remove any functional dependencies from both relations 

  3. COption (c)

    Assign both relations the same primary key field(s)

  4. DOption (d)

    None of the above

View answer & explanation

Correct answer

Answer: (a)A.

Link the relations by a common field and create primary key for the new relation

Why this answer is correct

The correct answer is Link the relations by a common field and create a primary key for the new relation

Key Points

  • Normalization: When normalizing a database, a relation (table) may be broken into two or more smaller relations to eliminate redundancy and ensure data consistency.
  • Data Integrity: To maintain data integrity after breaking a relation, the smaller relations must be linked by a common field (foreign key) to ensure that the data can be joined back together logically when needed.
  • Primary Key: Each smaller relation must have a primary key to uniquely identify its rows. This ensures there are no duplicate records and enforces entity integrity.

Additional Information

  • Linking Relations: The common field between the relations usually acts as a foreign key in one table and a primary key in another. This creates a relationship between the tables, such as one-to-many or many-to-many.
  • Functional Dependencies: While functional dependencies may be removed during normalization, this step alone does not maintain data integrity; linking the relations is essential.
  • Same Primary Key: Assigning the same primary key to both relations is incorrect, as each relation must have its own unique primary key.

Hence, the correct answer is: option 1) Link the relations by a common field and create a primary key for the new relation

Question 136

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

Bounded transmission media involves all of the following except _____

  1. AOption (a)

    twisted pair cable

  2. BOption (b)

    microwave 

  3. COption (c)

    coaxial cable

  4. DOption (d)

    fiber optic cable

View answer & explanation

Correct answer

Answer: (b)B.

microwave 

Why this answer is correct

The correct answer is microwave

Key Points

  • Bounded transmission media: ✅ Bounded transmission media refers to communication channels that are physically contained within a medium, such as cables. Examples include twisted pair cables, coaxial cables, and fiber optic cables.
  • Microwave: ❌ Microwave transmission is not a bounded transmission medium. It is a form of wireless communication that uses electromagnetic waves to transmit data between two points.
  • Twisted pair cable: ✅ Twisted pair cables are a type of bounded transmission media commonly used for telephone and Ethernet networks.
  • Coaxial cable: ✅ Coaxial cables are bounded transmission media used for cable television and internet connections.
  • Fiber optic cable: ✅ Fiber optic cables are bounded transmission media that use light signals to transmit data with high speed and reliability.

Additional Information

  • Bounded vs Unbounded: Bounded transmission media are confined within a physical medium, while unbounded transmission media (e.g., microwave, radio waves, satellite) use wireless channels.
  • Applications: Bounded media are typically used for local networks, while unbounded media are used for long-distance and wireless communication.

Hence, the correct answer is: option 2) microwave

Question 137

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

What is the following code segment doing ?

FILE *fp = fopen(“abc.txt”,“r”);

if (fp) {

fseek(fp, 0L, SEEK_END);

printf(“%d”, ftell(fp)); 

fclose(fp);

}

  1. AOption (a)

    Finding the number of lines in the file abc.txt

  2. BOption (b)

    Finding the size of the file abc.txt

  3. COption (c)

    Finding the number of spaces in the file abc.txt

  4. DOption (d)

    The code is not doing anything meaningful

View answer & explanation

Correct answer

Answer: (b)B.

Finding the size of the file abc.txt

Why this answer is correct

The correct answer is : option 2

Key Points

Code:

FILE *fp = fopen("abc.txt", "r");

if (fp) { fseek(fp, 0L, SEEK_END); printf("%d", ftell(fp)); fclose(fp); }

Explanation:

  • fopen("abc.txt", "r") — Opens the file abc.txt in read mode.
  • fseek(fp, 0L, SEEK_END) — Moves the file pointer to the end of the file.
  • ftell(fp) — Returns the current position of the file pointer in bytes. Since the pointer is at the end, it returns the size of the file in bytes.
  • printf() — Prints the size of the file.
  • fclose() — Closes the file.

What the code does:

It finds and prints the size of the file abc.txt in bytes.

Incorrect Interpretations:

  • It does not count lines → Option 1 is incorrect.
  • It does not count spaces → Option 3 is incorrect.
  • The code has meaningful logic → Option 4 is incorrect.

Correct Answer: Option 2) Finding the size of the file abc.txt ✅

Question 138

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

A functional dependency is a 

  1. AOption (a)

    Many to many relationship between two sets of attributes 

  2. BOption (b)

    One to one relationship between two sets of attributes 

  3. COption (c)

    Many to one relationship between two sets of attributes 

  4. DOption (d)

    None of the above

View answer & explanation

Correct answer

Answer: (b)B.

One to one relationship between two sets of attributes 

Why this answer is correct

The correct answer is One to one relationship between two sets of attributes

Key Points

  • Functional Dependency: A functional dependency occurs when one set of attributes uniquely determines another set of attributes. It represents a one-to-one relationship between two sets of attributes.
  • One-to-One Relationship: ✅ In a functional dependency, for every value of the determinant (left-hand side attribute), there is exactly one corresponding value in the dependent attribute (right-hand side).
  • Many-to-Many Relationship: ❌ This does not represent a functional dependency because multiple values on the left-hand side could correspond to multiple values on the right-hand side.
  • Many-to-One Relationship: ❌ While many-to-one mapping is possible, functional dependency strictly refers to one-to-one determination.
  • None of the Above: ❌ Incorrect, as functional dependency has a precise definition involving one-to-one determination.

Additional Information

  • Example: Consider attributes A and B in a database. If A → B (A determines B), then for every value of A, there is a unique value of B.
  • Usage: Functional dependencies are critical in database normalization to reduce redundancy and maintain data integrity.
  • Notation: Functional dependency is denoted as X → Y, where X determines Y.

Hence, the correct answer is: option 2) One to one relationship between two sets of attributes

Question 139

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

In the code given below variables a and n are known as

void func(float a[], int n) { … }

  1. AOption (a)

    Actual arguments 

  2. BOption (b)

    Formal parameters

  3. COption (c)

    Static variables

  4. DOption (d)

    Global variables

View answer & explanation

Correct answer

Answer: (b)B.

Formal parameters

Why this answer is correct

The Correct Answer is: Option 2) Formal Parameters

Key Points

  • Formal Parameters: ✅ Formal parameters are the variables declared in the function's definition. In this case, a and n are formal parameters of the function func.
  • Actual Arguments: ❌ Actual arguments are the values or variables passed to the function when it is called. These are not part of the function definition.
  • Static Variables: ❌ Static variables retain their value between function calls, but a and n are not declared as static.
  • Global Variables: ❌ Global variables are declared outside of all functions and are accessible throughout the program. However, a and n are declared within the function's parameter list, making them local to the function.

Additional Information

  • The formal parameters are placeholders that receive the actual values (arguments) passed to the function during a function call.
  • In the given code, a is an array of floats, and n is an integer. These variables are used within the function func to perform operations.
  • Formal parameters are initialized with the values of the actual arguments when the function is invoked.

Hence, the correct answer is: Option 2) Formal Parameters

Question 140

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

Consider the code segment given below

union U {

int i, a[10];

char c;

}u;

The space allocated to the variable u is equal to

  1. AOption (a)

    The sum total of space required for 11 integers and a character

  2. BOption (b)

    The space required by one integer

  3. COption (c)

    The space required by one character

  4. DOption (d)

    The space required by 10 integers

View answer & explanation

Correct answer

Answer: (d)D.

The space required by 10 integers

Why this answer is correct

The correct answer is : option 4

Key Points

Concept:

In C, a union is a special data type where all members share the same memory location. The size of the union is determined by the member that requires the maximum memory.

Given:

union U { int i, a[10]; char c; } u;

Step-by-Step Size Analysis:

  • int i → occupies typically 4 bytes
  • int a[10] → 10 integers = 10 × 4 = 40 bytes
  • char c → occupies 1 byte

Since all members of a union share the same memory, the total memory allocated is: maximum of (4, 40, 1) = 40 bytes

Important Note:

The union will allocate memory equivalent to its largest member, which is a[10].

Correct Answer: Option 4) The space required by 10 integers ✅