DSSSB TGT / PGT · Computer Science

Programming in C/C++ Previous Year Questions

89 Programming in C/C++ (Computer Science) questions asked in DSSSB TGT / PGT previous year papers, each with the correct answer and explanation. Read them free on UTpaper, or attempt the full papers as timed online tests.

  • 89 questions
  • Official answer key
  • Free

Other Computer Science topics

Q1From DSSSB TGT Computer Science Practice Set 4
In the context of while loop and do-while loop in C++, which of the following is not true?
  1. ABoth the loops are repetitive in nature
  2. BBoth are conditional loops
  3. CBoth will be executed at least once
  4. DBoth are terminated when the condition becomes false.
Show answerHide answer

Correct answer: (C) Both will be executed at least once

Explanation

A do-while loop always runs at least once because it checks the condition after the body. A while loop may run zero times, so (C) is not true.

Q2From DSSSB TGT Computer Science Practice Set 4
Which of the following is not correct in C++?
  1. Ax−=2; is the same as x = x−2;
  2. Bx*= 2; is the same as x = x*2;
  3. Cx% =2; is the same as x = x/2;
  4. Dx/=2; is the same as x = x/2;
Show answerHide answer

Correct answer: (C) x% =2; is the same as x = x/2;

Explanation

x %= 2 means x = x % 2 (remainder), not x = x / 2 (division). So (C) is incorrect.

Q3From DSSSB TGT Computer Science Practice Set 3
Consider the code segment written below in C++ : if (count < 10)//if#1 if ((count%4) ==2)//if#2 cout<<" condition;white/n"; else//(Indentation is wrong) cout<<" condition is:tan/n"; There are 2 if statements and one else. To which if, the else statement belong?
  1. AIt belongs to if # 1
  2. BIt belongs to if # 2
  3. CIt belongs to both the if statements.
  4. DIt is independent.
Show answerHide answer

Correct answer: (B) It belongs to if # 2

Explanation

In C++ an else pairs with the nearest preceding unmatched if (the dangling-else rule), whatever the indentation. So the else belongs to if#2.

Q4From DSSSB TGT Computer Science Practice Set 3
Consider the following Inheritance in C++ : class Person { char AadharNo[12]; protected : char Name[20]; public : ______ ______ void Readdata( ); }; class Student : public Person { int Grade; public : ______ ______ }; What will be the visibility mode of Name and Readdata ( ) in the derived class student ?
  1. AName → Protected, Readdata → Protected
  2. BName → Protected, Readdata → Public
  3. CName → Private, Readdata → Protected
  4. DName → Public, Readdata → Public
Show answerHide answer

Correct answer: (B) Name → Protected, Readdata → Public

Explanation

With public inheritance, protected members stay protected and public members stay public in the derived class. So Name is protected and Readdata() is public. The private AadharNo is not accessible in Student.

Q5From DSSSB TGT Computer Science Practice Set 3
Which of the following commands in C++ will open a text file NOTES.TXT for reading the content from it ?
  1. Aifstream F ("NOTES.TXT");
  2. Bofstream F ("NOTES.TXT");
  3. Cfstream F ("NOTES.TXT");
  4. Dfstream F ("NOTES.TXT", ios :: read);
Show answerHide answer

Correct answer: (A) ifstream F ("NOTES.TXT");

Explanation

ifstream opens a file for input (reading). ofstream is for writing. ios::read is not a valid mode.

Q6From DSSSB TGT Computer Science Practice Set 2
How many characters does an escape sequence (\On, \Hn, \n, \f) in C++ consume?
  1. A1
  2. B3
  3. C2
  4. DNone of these
Show answerHide answer

Correct answer: (A) 1

Explanation

An escape sequence is written with two or more characters in the source code, but it represents and stores a single character, so it takes 1 character (1 byte).

Q7From DSSSB TGT Computer Science Practice Set 1
Consider the following code segment in C++. How many times the for loop will be repeated? int main ( ) { int f = 1; for (; f ;) cout <<"f = " <<f++<<"\n"; return 0; }
  1. A10 times
  2. BNot even once
  3. CRepeated forever
  4. DOnly once
Show answerHide answer

Correct answer: (C) Repeated forever

Explanation

for(; f ;) has no update expression of its own, and f starts at 1 and is incremented each time by f++. f never becomes 0 in normal counting, so the condition stays true and the loop runs forever.

Q8From DSSSB TGT Computer Science Practice Set 1
What does the following C statement mean? scanf ("%4s', str);
  1. ARead exactly 4 charaters from console
  2. BRead maximum 4 characters from console
  3. CRead a string in multiples of 4
  4. DNone of the above
Show answerHide answer

Correct answer: (B) Read maximum 4 characters from console

Explanation

A width in %4s limits input: scanf reads at most 4 non-whitespace characters into str. It may read fewer if whitespace comes first.

Q9DSSSB PGT Computer Science (Technical), 11 Jul 2021
In C++, namespace defines a ________ for the identifiers that are used in a program.
  1. Asize
  2. Bscope
  3. Csyntax
  4. Dstandard
Show answerHide answer

Correct answer: (B) scope

Explanation

A namespace defines a named scope for identifiers, so names such as std::cout do not clash with the same names elsewhere.

Q10DSSSB PGT Computer Science (Technical), 11 Jul 2021
In C++, operator '>>' is used along with object cin for reading input is known as ________.
  1. Aextraction
  2. Boutput
  3. Cget in
  4. Dput to
Show answerHide answer

Correct answer: (A) extraction

Explanation

>> with cin is the extraction (get from) operator, and << with cout is the insertion (put to) operator.

Q11DSSSB PGT Computer Science (Technical), 11 Jul 2021
Which of the following statement(s) is/are correct regarding void keyword in C++? I. To specify the return type of a function when it is not returning any value. II. To indicate an empty argument list to a function.
  1. AOnly I
  2. BOnly II
  3. CBoth I and II
  4. DNeither I nor II
Show answerHide answer

Correct answer: (C) Both I and II

Explanation

void is used as the return type of a function that returns nothing, and as in f(void) it shows an empty argument list.

Q12DSSSB PGT Computer Science (Technical), 11 Jul 2021
In C++, bool data type is used to hold how many values?
  1. An²
  2. B2
  3. C2n
  4. D2ⁿ
Show answerHide answer

Correct answer: (B) 2

Explanation

bool holds only two values: true and false.

Q13DSSSB PGT Computer Science (Technical), 11 Jul 2021
Which of the following is specified by function prototype in C++? I. Return Type II. Function name III. Number and types of argument
  1. AI and II
  2. BI and III
  3. CII and III
  4. DI, II and III
Show answerHide answer

Correct answer: (D) I, II and III

Explanation

A function prototype states the return type, the function name, and the number and types of its arguments.

Q14DSSSB PGT Computer Science (Technical), 11 Jul 2021
What is the symbol and associativity of the assignment operator in C++?
  1. A=, left to right
  2. B==, left to right
  3. C(R), right to left
  4. D=, right to left
Show answerHide answer

Correct answer: (D) =, right to left

Explanation

The assignment operator is = and it associates right to left, so a = b = c assigns c to b first, then b to a.

Q15DSSSB PGT Computer Science (Technical), 11 Jul 2021
Which statement is correct about static member function in C++? I. It can access to only other static members declared in the same class. II. It cannot be called using the class name (instead of its objects)
  1. AOnly I
  2. BOnly II
  3. CBoth I and II
  4. DNeither I nor II
Show answerHide answer

Correct answer: (A) Only I

Explanation

A static member function can access only static members of its class, and it can be called with the class name (Class::f()). So only I is correct.

Q16DSSSB PGT Computer Science (Technical), 11 Jul 2021
Which statement is NOT correct regarding ternary operator in C++?
  1. AIts symbol is?:
  2. BIt is also known as conditional operator
  3. COperator overloading is possible in it
  4. DIt is similar to if else
Show answerHide answer

Correct answer: (C) Operator overloading is possible in it

Explanation

The ternary operator ?: is one of the C++ operators that cannot be overloaded, along with ::, . and .*. The other statements about it are true.

Q17DSSSB PGT Computer Science (Technical), 11 Jul 2021
By default in C++, the member of a class are ________, while, by default the member of structure are ________.
  1. APrivate; private
  2. BPublic; public
  3. CPrivate; public
  4. DPublic; private
Show answerHide answer

Correct answer: (C) Private; public

Explanation

In C++, class members are private by default, while struct members are public by default.

Q18DSSSB PGT Computer Science (Technical), 11 Jul 2021
Match the following file stream classes in C++ with its functions. A. Fstream base — i. Provides support for simultaneous input and output operation B. If stream — ii. Provides output operation C. Of stream — iii. Provides operations common to file streams D. F stream — iv. Provides input operation
  1. AA-i, B-ii, C-iv, D-iii
  2. BA-iv, B-iii, C-i, D-ii
  3. CA-i, B-iii, C-iv, D-ii
  4. DA-iii, B-iv, C-ii, D-i
Show answerHide answer

Correct answer: (D) A-iii, B-iv, C-ii, D-i

Explanation

fstreambase provides operations common to file streams, ifstream gives input, ofstream gives output, and fstream supports simultaneous input and output.

Q19DSSSB PGT Computer Science (Technical), 11 Jul 2021
Which of the following statement is NOT correct regarding Virtual function in C++? I. It must be a member of some class. II. It is accessed by using object points.
  1. AOnly I
  2. BOnly II
  3. CBoth I and II
  4. DNeither I nor II
Show answerHide answer

Correct answer: (D) Neither I nor II

Explanation

Both statements are true: a virtual function must be a member of a class, and it is accessed through object pointers (base-class pointers) for run-time polymorphism. So neither is incorrect.

Q20DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
What is the output of the code written in C? void main() { int k = 8, v = 8, i; i = k/++v; printf("%d/n", i); }
  1. A0
  2. B1
  3. C0.8
  4. DError
Show answerHide answer

Correct answer: (A) 0

Explanation

++v makes v = 9 before the division. Then i = 8/9 = 0 because integer division drops the fraction. printf prints 0 (followed by the literal text "/n").

Q21DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2
Consider the following C declaration. Assume that objects of data type short, float and long occupy 2 bytes, 4 bytes and 8 bytes respectively. What is the memory requirement for variable t? struct { short a[5]; union { float v; long z; } u; } t;
  1. A22 bytes
  2. B18 bytes
  3. C24 bytes
  4. D10 bytes
Show answerHide answer

Correct answer: (B) 18 bytes

Explanation

short a[5] takes 5 × 2 = 10 bytes. The union takes the size of its largest member, long, which is 8 bytes. Total = 10 + 8 = 18 bytes, ignoring alignment padding.

Q22DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 3
What is the output of the code written in C? void main() { int k, v; k = (v=20, v+2); printf("%d/n", k); }
  1. A2
  2. B20
  3. C22
  4. DError
Show answerHide answer

Correct answer: (C) 22

Explanation

The comma operator evaluates v = 20, then v + 2, and returns the last value, so k = 22. (The "/n" is printed literally after it.)

Q23DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
Which one is the reserved word in C language?
  1. AAutomatic
  2. BInteger
  3. CConstant
  4. DVolatile
Show answerHide answer

Correct answer: (D) Volatile

Explanation

volatile is a C keyword (type qualifier). Automatic, Integer and Constant are not keywords; the C keywords are auto, int and const.

Q24DSSSB TGT Computer Science (Technical), 7 Aug 2021, Shift 2
What is the output of the code written in C? void main() { int k, val = 1; k = ++val * ++val; printf("%d", k); }
  1. A1
  2. B4
  3. C9
  4. D16
Show answerHide answer

Correct answer: (C) 9

Explanation

Modifying val twice in one expression is undefined behaviour in C, but common compilers (e.g. GCC) apply both increments first, making val = 3, and then compute 3 * 3 = 9.

Q25DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
Which statements is correct regarding main() function in C++? I. It is a user defined function. II. It is a pre-defined function.
  1. AOnly I
  2. BOnly II
  3. CBoth I and II
  4. DNeither I nor II
Show answerHide answer

Correct answer: (A) Only I

Explanation

main() is called by the system, but its body is written by the programmer, so it is treated as a user-defined function, not a library (pre-defined) function.

Q26DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
Which inbuilt function in C is used to read string from system console?
  1. APuts()
  2. BCgets()
  3. CGetche()
  4. DGetchar()
Show answerHide answer

Correct answer: (B) Cgets()

Explanation

cgets() (from conio.h) reads a string from the console. puts() writes a string, and getche()/getchar() read single characters.

Q27DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 3
What is the output of the following code written in C? void main() { printf("%d%d%d", 62, 062, 0x62); }
  1. A506298
  2. B629850
  3. C625098
  4. D986250
Show answerHide answer

Correct answer: (C) 625098

Explanation

62 is decimal, 062 is octal = 6×8 + 2 = 50, and 0x62 is hexadecimal = 6×16 + 2 = 98. With no separators, the output is 625098.

Q28DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
Which statement(s) is/are true about formation of identifier in C? I. It consist of alphabets, digits and underscore. II. An identifier can start with an underscore.
  1. AOnly I
  2. BOnly II
  3. CBoth I and II
  4. DNeither I nor II
Show answerHide answer

Correct answer: (C) Both I and II

Explanation

A C identifier may contain letters, digits and underscores, and may begin with a letter or an underscore (but not a digit). Both statements are true.

Q29DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
In C++ a wide-character constant begins with the letter ________.
  1. AW
  2. BC
  3. CL
  4. DS
Show answerHide answer

Correct answer: (C) L

Explanation

A wide-character literal is written with the prefix L, for example L'a', and has type wchar_t.

Q30DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1
What is the output of the code written in C? void main() { printf("%d", 7%-3); printf("%d", -7%3); }
  1. A1 −1
  2. B−1 −1
  3. C−1 1
  4. D1 1
Show answerHide answer

Correct answer: (A) 1 −1

Explanation

In C the result of % takes the sign of the dividend: 7 % −3 = 1 and −7 % 3 = −1. The two printf calls print 1 and −1.

Q31DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
Which of the following is NOT an arithmetic operator in C?
  1. A%
  2. B+
  3. C&&
  4. D−
Show answerHide answer

Correct answer: (C) &&

Explanation

&& is the logical AND operator. +, − and % are arithmetic operators.

Q32DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
What will be the output of the following code? #include <stdio.h> int main() { int arr[] = {1, 2, 3, 4, 5}; printf("%d %d \n", arr[2], *(arr + 2)); return 0; }
  1. A3 3
  2. B2 2
  3. CCompilation Error
  4. DUndefined Behavior
Show answerHide answer

Correct answer: (A) 3 3

Explanation

arr[2] and *(arr + 2) both mean the third element, 3, so "3 3" is printed.

Q33DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
Which of the following is NOT a type of loop in C?
  1. Ado-while loop
  2. Bfor loop
  3. Cforeach loop
  4. Dwhile loop
Show answerHide answer

Correct answer: (C) foreach loop

Explanation

C has three loops: for, while and do-while. There is no foreach loop in C.

Q34DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
What is the output of the following code? #include <stdio.h> void func(int *p) { int q = 10; p = &q; } int main() { int x = 20, *ptr = &x; func(ptr); printf("%d\n", *ptr); return 0; }
  1. ACompile time error
  2. B20
  3. C10
  4. DGarbage value
Show answerHide answer

Correct answer: (B) 20

Explanation

C passes the pointer by value, so p = &q changes only the local copy in func. ptr still points to x, and 20 is printed.

Q35DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
What will be the output of the following expression? #include<stdio.h> int main() { printf("%d",7>=7); return 0; }
  1. A1
  2. BTRUE
  3. Cfalse
  4. D0
Show answerHide answer

Correct answer: (A) 1

Explanation

7 >= 7 is true, and in C a true relational expression has the value 1, so printf prints 1.

Q36DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
What will happen if the following declaration is used in C? int a, b, c = 10;
  1. AOnly c is initialized to 10; a and b are uninitialized.
  2. BSyntax error due to missing initialization of a and b.
  3. Ca, b, and c are all initialized to 10.
  4. DRuntime error
Show answerHide answer

Correct answer: (A) Only c is initialized to 10; a and b are uninitialized.

Explanation

In int a, b, c = 10; the initialiser belongs only to c. a and b are declared but left uninitialised (garbage if local).

Q37DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
What will be the output of the following C code? #include <stdio.h> void main() { printf("%d", printf("Tata Consultancy")); }
  1. ATata Consultancy
  2. BTata Consultancy15
  3. CTata Consultancy16
  4. D15Tata Consultancy
Show answerHide answer

Correct answer: (C) Tata Consultancy16

Explanation

The inner printf prints "Tata Consultancy" first and returns the number of characters printed, 16 (4 + space + 11). The outer printf then prints 16.

Q38DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
Which of the following is NOT a keyword in C?
  1. Avariable
  2. Bsizeof
  3. Csigned
  4. Dauto
Show answerHide answer

Correct answer: (A) variable

Explanation

"variable" is not a C keyword. sizeof, signed and auto are all reserved keywords in C.

Q39DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)
Which function is used in C to open a file in binary mode for writing?
  1. Afopen("file.txt", "wb")
  2. Bfopen("file.txt", "bw")
  3. Cfopen("file.txt", "binary")
  4. Dfopen("file.txt", "b")
Show answerHide answer

Correct answer: (A) fopen("file.txt", "wb")

Explanation

The mode "wb" opens a file for writing in binary mode. The mode string is "w" followed by "b", not "bw" or "binary".

Q40DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
What will be the output of the following code? #include<stdio.h> int main() { int x=5,y; y=x++ + ++x; printf("%d",y); return 0; }
  1. A11
  2. Bcompile time error
  3. C12
  4. D10
Show answerHide answer

Correct answer: (C) 12

Explanation

x++ gives 5 (x becomes 6), then ++x makes x 7, so y = 5 + 7 = 12 on common compilers. Strictly, modifying x twice in one expression is undefined behaviour in C.

Q41DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
What will be the output of the following code when the input is HelloWorld? #include <stdio.h> int main() { char str[5]; // Buffer for input int result = scanf("%4s", str); if (result == 1) { printf("Input: %s\n", str); } else { printf("Input error or no input.\n"); } return 0; }
  1. AInput: Hell
  2. BInput: Hello
  3. CInput error or no input
  4. DInput: HelloWorld
Show answerHide answer

Correct answer: (A) Input: Hell

Explanation

The width %4s makes scanf read at most 4 characters, so str gets "Hell" plus '\0' (fits in 5 bytes). scanf returns 1, so "Input: Hell" is printed.

Q42DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
What will be the output of the following code? #include <stdio.h> int main() { char str[20] = "Hello, World!"; printf("%s\n", str + 7); return 0; }
  1. AWorld!
  2. B, World!
  3. CCompilation error
  4. DHello, World!
Show answerHide answer

Correct answer: (A) World!

Explanation

str + 7 points to index 7 of "Hello, World!". Index 5 is ',' and 6 is the space, so printing starts at 'W' and gives "World!".

Q43DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
Which of the following is the correct syntax of an if-else statement in C?
  1. Aif (condition) { statements } else { statements }
  2. Bif (condition) then { statements } else { statements }
  3. Cif [condition] then { statements } else { statements }
  4. Dif condition: statements else: statements
Show answerHide answer

Correct answer: (A) if (condition) { statements } else { statements }

Explanation

C syntax is if (condition) { ... } else { ... }. The condition must be in parentheses, and C has no "then" keyword or colon syntax (that is Python).

Q44DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
What will be the output of the following code? #include <stdio.h> int main() { if (5 > 10) printf("5 is greater than 10"); else printf("5 is not greater than 10"); return 0; }
  1. ANo output
  2. BSyntax error
  3. C5 is greater than 10
  4. D5 is not greater than 10
Show answerHide answer

Correct answer: (D) 5 is not greater than 10

Explanation

5 > 10 is false, so the else branch runs and prints "5 is not greater than 10".

Q45DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
#include <stdio.h> int main() { FILE *file = fopen("input.txt", "r"); int value; fscanf(file, "%d", &value); fseek(file, 0, SEEK_SET); fscanf(file, "%d", &value); fclose(file); printf("%d\n", value); return 0; } What will be the output of the code if input.txt contains 42?
  1. AUndefined behavior
  2. B42
  3. CEOF
  4. DIt depends on the system
Show answerHide answer

Correct answer: (B) 42

Explanation

The first fscanf reads 42. fseek(file, 0, SEEK_SET) moves back to the start, so the second fscanf reads 42 again, and 42 is printed.

Q46DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
Which of the following is a correct way to declare a char type variable x in C?
  1. Achar x;
  2. Bchar = 'x';
  3. Cch x;
  4. Dcharacter x;
Show answerHide answer

Correct answer: (A) char x;

Explanation

A C variable is declared as type followed by name, so char x; declares a char variable x. "ch" and "character" are not C types.

Q47DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
What is the output of the following code? #include <stdio.h> int main() { for (int i = 1; i <= 3; i++) { for (int j = 1; j <= i; j++) { printf("*"); } printf("\n"); } return 0; }
  1. A* ** ***
  2. B*** ** *
  3. C*** *** ***
  4. DCompilation Error
Show answerHide answer

Correct answer: (A) * ** ***

Explanation

The outer loop runs i = 1 to 3, and the inner loop prints i stars each time, so the rows are *, ** and ***.

Q48DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
What does the += operator do in C?
  1. AAdds the right operand to the left operand and assigns the result to the left operand.
  2. BIt is used to concatenate two strings.
  3. CIt is an invalid operator.
  4. DAssigns the value of the right operand to the left operand.
Show answerHide answer

Correct answer: (A) Adds the right operand to the left operand and assigns the result to the left operand.

Explanation

a += b is shorthand for a = a + b: the right operand is added to the left one and the result is stored in the left operand.

Q49DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
What is the output of the following code? #include <stdio.h> void func(void); int main() { func(10); return 0; } void func(void) { printf("Function called\n"); }
  1. ACompilation error
  2. BCompiles successfully but no output displayed
  3. CPrints 'Function called'
  4. DPrints 'Function not called'
Show answerHide answer

Correct answer: (A) Compilation error

Explanation

func is declared as void func(void), so it takes no arguments. Calling func(10) passes an argument, which the compiler rejects as too many arguments.

Q50DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)
In C, which of the following file opening modes allow both reading and appending data in a file?
  1. A"w+"
  2. B"a"
  3. C"r"
  4. D"a+"
Show answerHide answer

Correct answer: (D) "a+"

Explanation

Mode "a+" opens a file for reading and appending: you can read anywhere, and every write goes to the end. "a" only appends, and "w+" truncates the file first.

How to use these DSSSB TGT / PGT Computer Science questions

Every question here was asked in a real DSSSB TGT / PGT paper; the paper and shift are shown on the card, and the number opens the question on its own page. Try each one before tapping Show answer, then attempt the full DSSSB TGT / PGT papers as timed tests to check your speed under exam conditions.

More DSSSB TGT / PGT subjects