UGC NET Computer Science Programming Languages and Computer Graphics Previous Year Questions (PYQs)
Practise 141 Programming Languages and Computer Graphics questions asked in UGC NET Computer Science from 2018–2026. Questions cover Language design, Programming paradigms, C and C++ constructs, Java, Storage management and Web technologies. Every question is shown with its options and the correct answer, free to read.
141 PYQs2018–2026Answers includedFree
Practise Programming Languages and Computer Graphics as timed sets
Focused 10-question sets with instant scoring, explanations, and weak-area analysis.
A. Pivot point B. Fixed point C. Mirror image D. Distortion
I. Reflection II. Shear III. Rotation IV. Scaling
AA-III, B-IV, C-I, D-II
BA-III, B-IV, C-II, D-I
CA-IV, B-III, C-II, D-I
DA-I, B-II, C-III, D-IV
Answer:(A) A-III, B-IV, C-I, D-II
Explanation
A pivot point remains fixed during rotation, a fixed point is associated with scaling, a mirror image is produced by reflection, and shear produces distortion. Therefore the matching is A-III, B-IV, C-I, D-II.
Arrange these C++ data types in non-decreasing order of representation length.
A. char
B. int
C. float
D. double
AB, A, C, D
BA, B, D, C
CD, C, B, A
DA, B, C, D
Answer:(D) A, B, C, D
Explanation
A char uses the least storage, followed by int; float is normally smaller than double. Hence the non-decreasing order is char, int, float, double: A, B, C, D.
A. long signed int B. double C. long double D. unsigned character
I. %lf II. %Lf III. %c IV. %ld
AA-II, B-I, C-IV, D-III
BA-IV, B-I, C-II, D-III
CA-III, B-I, C-II, D-IV
DA-I, B-II, C-IV, D-III
Answer:(B) A-IV, B-I, C-II, D-III
Explanation
A long signed int uses %ld, double uses %lf, long double uses %Lf, and an unsigned character is read or printed with %c. Hence the matching is A-IV, B-I, C-II, D-III.
#include <stdio.h>
int main() {
int i;
for (i = 0; i++ < 10;)
printf("%d", i++);
return 0;
}
A0123456789
B12345678
C13579
D2468
Answer:(C) 13579
Explanation
Each loop test increments i once, and printf prints i before incrementing it again. The printed values are therefore 1, 3, 5, 7, and 9; the next condition sees 10 and terminates the loop.
The number of pixel columns divided by the number of scan lines displayed by a system is called:
APixmap
BBitmap
CAspect ratio
DDepth
Answer:(C) Aspect ratio
Explanation
Aspect ratio is the ratio of horizontal pixels (or columns) to vertical scan lines. A bitmap/pixmap is an image representation, while depth refers to bits per pixel.
Which statements about C++ constructors are correct?
A. They have the same name as the class.
B. They can return values.
C. They are called automatically when an object is created.
D. They can be overloaded.
E. They can be inherited.
AA, B, C and D only
BA, C and D only
CB, C and D only
DC, D and E only
Answer:(B) A, C and D only
Explanation
A constructor is named for its class, is invoked on object creation, and may be overloaded. It has no return type or return value, and constructors are not inherited, so A, C, and D are the correct statements.
Right shifting a positive integer by four places divides it by 2⁴. Thus 16 >> 4 equals 16 / 16 = 1; the other answers correspond to fewer shifts or a different operation.
The shown transformation is a reflection about which axis?
Original and reflected triangle positions about the vertical axis.
AA and D only
BA and C only
CB and C only
DB and D only
Answer:(C) B and C only
Explanation
The object moves from the left side of the vertical axis to the right side while retaining its vertical coordinates and reversing left/right orientation. Thus it is a reflection about the y-axis, equivalently the line x = 0. Statements B and C describe the same reflection.
Assertion (A): The control points have only local control over the shape of the B-Splines.
Reason (R): Bezier curves do have local control.
ABoth A and R are correct and R is the correct explanation of A
BBoth A and R are correct but R is NOT the correct explanation of A
CA is correct but R is not correct
DA is not correct but R is correct
Answer:(C) A is correct but R is not correct
Explanation
A B-spline curve is built from piecewise polynomial segments, so moving one control point reshapes only the nearby segments of the curve while the rest of the curve stays unchanged. This local-control property makes Assertion A correct.
Bezier curves behave the opposite way. Every control point contributes to a single blending function that spans the entire curve, so moving any one control point reshapes the whole curve. Bezier curves therefore have global control, not local control, which makes Reason R incorrect.
Which of the following statements are true?
A. Painters' algorithm is also called depth sort algorithm.
B. Gourad shading is an interpolating shading method.
C. Gourad shading is an averaging shading method.
D. The Z-buffer algorithm finds the largest depth value Z.
AA, B Only
BB, C Only
CC, D Only
DA, D Only
Answer:(A) A, B Only
Explanation
A. Painters' algorithm is also called depth sort algorithm. — correct. The algorithm sorts polygons by depth and paints them from farthest to nearest, which is exactly why it is also known as the depth-sort algorithm.
B. Gourad shading is an interpolating shading method. — correct. Gouraud shading computes intensity at each vertex and then linearly interpolates those intensity values across the surface of the polygon.
C. Gourad shading is an averaging shading method. — incorrect. Averaging is only used as an intermediate step to compute a vertex normal from the surrounding polygon normals, but the shading method itself is classified by intensity interpolation, not by averaging.
D. The Z-buffer algorithm finds the largest depth value Z. — incorrect. The Z-buffer algorithm keeps the smallest depth value at each pixel, since the point nearest to the viewer is the one that should be visible, not the farthest one.
Which of the following statements are true?
A. The ++ operator can be overloaded to perform decrementation of a variable.
B. It is necessary that a constructor in a class should always be public.
C. Size of an object is equal to the sum of sizes of data members and member functions within the class.
D. A static data member is useful when all objects of a class are to share a common item of information.
E. The this pointer always contains the address of the object using which the member function is being called.
AA, B, C Only
BB, C, E Only
CA, D, E Only
DB, D, E Only
Answer:(C) A, D, E Only
Explanation
A. The ++ operator can be overloaded to perform decrementation of a variable. — correct. Operator overloading in C++ only binds a symbol to a function definition, and the language does not enforce that the overloaded body must match the operator's conventional meaning, so a programmer can legally define operator++ to decrement.
B. It is necessary that a constructor in a class should always be public. — incorrect. Constructors can be declared private or protected, which is exactly how patterns such as the singleton pattern prevent direct external instantiation.
C. Size of an object is equal to the sum of sizes of data members and member functions within the class. — incorrect. Member functions are stored once as shared code, not copied into every object, so only the data members contribute to an object's size, along with any compiler-added overhead such as vtable pointers.
D. A static data member is useful when all objects of a class are to share a common item of information. — correct. A static data member has a single shared copy across all objects of the class, so it is the natural way to hold information common to every instance.
E. The this pointer always contains the address of the object using which the member function is being called. — correct. Every non-static member function implicitly receives a this pointer bound to the specific object invoking it.
Assertion (A): We can build an object from a class containing a pure virtual function.
Reason (R): A class containing a pure virtual function is called an abstract class.
ABoth A and R are correct and R is the correct explanation of A
BBoth A and R are correct but R is NOT the correct explanation of A
CA is correct but R is not correct
DA is not correct but R is correct
Answer:(D) A is not correct but R is correct
Explanation
A class that declares a pure virtual function becomes an abstract class, and C++ does not allow an abstract class to be instantiated directly.
Assertion A claims an object can be built directly from such a class, but this is false because the compiler blocks any attempt to instantiate a class that still has an unimplemented pure virtual function.
Reason R correctly states the definition that a class containing a pure virtual function is called an abstract class, so this part is true.
Since A is false and R is true, the correct choice is that A is not correct but R is correct.
For implicit type conversion, arrange the following from a lower size type to a higher size type.
A. double
B. unsigned long int
C. unsigned int
D. long double
E. long int
AE, C, B, A, D
BC, B, E, D, A
CE, C, A, B, D
DC, E, B, A, D
Answer:(D) C, E, B, A, D
Explanation
C++ usual arithmetic conversions rank integer and floating types from smaller to larger capacity, and conversions always move from a lower-ranked type to a higher-ranked one during mixed-type expressions.
The standard low-to-high ordering used for these five types is unsigned int, long int, unsigned long int, double, long double.
unsigned int (C) sits just above int in rank.
long int (E) has a wider representable range than unsigned int on this ranking.
unsigned long int (B) extends long int further with an unsigned range.
double (A) and then long double (D) are the two floating types, with long double holding the widest range and precision of all five.
Match List-I (Quadric surfaces) with List-II (Equations).
List-I (Quadric Surface)
List-II (Equation)
A. One-sheeted hyperboloid
I. x²/a² + y²/b² = cz
B. Two-sheeted hyperboloid
II. x²/a² + y²/b² - z²/c² = 1
C. Elliptic paraboloid
III. x²/a² - y²/b² = cz
D. Hyperbolic paraboloid
IV. z²/c² - x²/a² - y²/b² = 1
AA-I, B-II, C-III, D-IV
BA-II, B-III, C-IV, D-I
CA-II, B-IV, C-I, D-III
DA-IV, B-II, C-I, D-III
Answer:(C) A-II, B-IV, C-I, D-III
Explanation
Each quadric surface has a distinct standard equation determined by its sign pattern and which variable stands alone.
A one-sheeted hyperboloid has two positive squared terms and one negative term equal to 1, giving x²/a² + y²/b² - z²/c² = 1, so A pairs with II.
A two-sheeted hyperboloid flips this pattern with one positive term and two negative terms equal to 1, giving z²/c² - x²/a² - y²/b² = 1, so B pairs with IV.
An elliptic paraboloid has two positive squared terms equal to a linear term, giving x²/a² + y²/b² = cz, so C pairs with I.
A hyperbolic paraboloid has one positive and one negative squared term equal to a linear term, giving x²/a² - y²/b² = cz, so D pairs with III.
Which of the following is not true about constructors?
AWhen an object is created and initialized at the same time, a copy constructor gets called
BThey do not have return types, not even void
CThey can be virtual
DThey cannot be inherited, though a derived class can call the base class constructor
Answer:(C) They can be virtual
Explanation
Constructors in C++ follow a specific set of rules, and one of the most consistently tested facts is that a constructor can never be declared virtual.
A. When an object is created and initialized at the same time, a copy constructor gets called — this describes copy-initialization from another object of the same type, which correctly describes when the copy constructor runs.
B. They do not have return types, not even void — correct, constructors never specify a return type.
C. They can be virtual — this is false. A constructor cannot be virtual because virtual dispatch relies on the object's vtable pointer, which is only fully set up once construction is already underway, so the object does not yet exist in a state that supports dynamic dispatch during its own construction.
D. They cannot be inherited, though a derived class can call the base class constructor — correct, constructors are not inherited, but a derived class constructor can invoke a base class constructor through its initializer list.
Since virtual constructors are impossible in C++, statement C is the one that is not true.
A normalized matrix maps a 3D window specified by coordinates (1, 1, 1) and (4, 5, 6) onto a viewport specified by coordinates (2, 4, 2) and (8, 10, 8). Which of the following matrices correctly represents this transformation?
A window-to-viewport transform scales each axis to match the viewport's extent, then translates so the window's minimum corner (1, 1, 1) lands on the viewport's minimum corner (2, 4, 2).
Scale factors, viewport extent divided by window extent on each axis:
sx = (8-2)/(4-1) = 2
sy = (10-4)/(5-1) = 3/2
sz = (8-2)/(6-1) = 6/5
Translation offsets, solved so (1,1,1) maps to (2,4,2):
tx = 2 - sx(1) = 0
ty = 4 - sy(1) = 5/2
tz = 2 - sz(1) = 4/5
Substituting these into the scale-then-translate matrix gives:
2 0 0 0
0 3/2 0 5/2
0 0 6/5 4/5
0 0 0 1
This matches option A exactly.
As a check, the window's max corner (4, 5, 6) should land on the viewport's max corner (8, 10, 8): 2(4) = 8, 3/2(5) + 5/2 = 10, 6/5(6) + 4/5 = 8, confirming the matrix is correct.
Arrange the following applet life cycle methods in sequence.
A. start()
B. paint()
C. init()
D. stop()
AA, B, C, D
BC, A, B, D
CA, C, B, D
DB, A, C, D
Answer:(B) C, A, B, D
Explanation
An applet's lifecycle begins when it is loaded and ends when the browser leaves or reloads the page, and the JVM calls its lifecycle methods in a fixed order.
init() runs first, setting up the applet's initial state when it is loaded.
start() runs next, beginning or resuming the applet's execution right after initialization.
paint() then renders the applet's visual output on screen.
stop() runs last, when the applet becomes inactive, such as when the browser navigates away from the page.
The resulting order is init() → start() → paint() → stop(), which is C, A, B, D.
int x = 128, y = 110;
do {
if (x > y) x = x - y;
else y = y - x;
} while (x != y);
printf("%d", x);
A18
B2
C92
D74
Answer:(B) 2
Explanation
The loop repeatedly replaces the larger value by the difference, which is Euclid's subtraction algorithm. It ends when x and y both equal gcd(128, 110) = 2, so it prints 2.
Cohen-Sutherland is the standard line-clipping algorithm; the option reverses its two names. Seed-fill and scan-line methods are filling techniques, while inverse scaling is a transformation idea.
int i, j;
for (i = 1; i < 5; i += 2)
for (j = 1; j < i; j += 2)
printf("%d", j);
A1
B1 2
C1 3
D1 1 3
Answer:(A) 1
Explanation
The outer loop uses i = 1 and then i = 3. At i = 1, j starts at 1 and fails j < i, so nothing prints. At i = 3, j = 1 satisfies the test and prints once; incrementing j to 3 ends that inner loop. Hence the only printed value is 1, without spaces because the format string contains none.
Which pointer expression refers to the array element ar[m][n][o]?
A((*(ar) + m + n) + o)
B(((*ar + m) + n) + o)
C(((ar + m) + n) + o)
D((*(ar + m) + n) + o)
Answer:(D) ((*(ar + m) + n) + o)
Explanation
For a multidimensional array, ar + m reaches the mth two-dimensional slice; *(ar + m) + n reaches the nth row; and *(*(ar + m) + n) + o reaches the oth element. Dereferencing that final address gives the element.
int *i, a = 12, b = 2, c;
c = (a = a + b, b = a / b, a = a * b, b = a - b);
i = &c;
printf("%d", --(*i));
A91
B90
C98
D92
Answer:(B) 90
Explanation
The displayed code supplies the source's evidently omitted terminating semicolon. The comma expressions execute left to right: a becomes 14, b becomes 7, a becomes 98, and b becomes 91. The assignment sets c to the final expression value 91; --(*i) decrements c through its pointer before printing, giving 90. It does not print 91 because the pre-decrement happens before printf, and 98 is only the intermediate value of a.
For C operators &&, +=, >>, >=, and ?:, what is the precedence order from higher to lower?
A
, >=, ?:, +=, &&
B
, &&, >=, ?:, +=
C
, >=, &&, ?:, +=
D
=, >>, &&, +=, ?:
Answer:(C)
, >=, &&, ?:, +=
Explanation
C precedence places shift operators above relational operators, relational above logical AND, logical AND above conditional, and conditional above assignment. Therefore the order is >>, >=, &&, ?:, +=.
Adding an integer to a pointer yields another pointer. Subtracting two pointers into the same array yields an integer difference (ptrdiff_t). Pointer plus pointer is invalid; pointer minus integer yields a pointer, not a number; and pointer minus pointer does not yield a pointer. Therefore A and E only are legal as stated.
Editorially repaired version of an NTA-dropped item. Treat the following descriptions as a one-to-one matching. Which mapping is correct?
List I
List II
A. Overloading
I. An overridden method call is selected at runtime
B. Early binding
II. A function call is resolved at compile time
C. Method overriding
III. Supports compile-time polymorphism
D. Late binding
IV. Supports runtime polymorphism
AA-III, B-II, C-I, D-IV
BA-IV, B-II, C-III, D-I
CA-III, B-I, C-IV, D-II
DA-IV, B-I, C-III, D-II
Answer:(A) A-III, B-II, C-I, D-IV
Explanation
Overloading is compile-time polymorphism, so A maps to III. Early binding resolves a call at compile time, so B maps to II. Method overriding uses runtime dispatch, so C maps to I; late binding enables runtime polymorphism, so D maps to IV. The resulting mapping is A-III, B-II, C-I, D-IV.
Match oblique, cavalier, cabinet, and orthographic projection with their defining projection properties.
List I
List II
A. Oblique projection
I. Perpendicular lines are foreshortened
B. Cavalier projection
II. Perpendicular lines are not foreshortened
C. Cabinet projection
III. Projectors are perpendicular to the plane
D. Orthographic projection
IV. Projector angle to plane is not 90°
AA-III, B-II, C-IV, D-I
BA-IV, B-II, C-I, D-III
CA-III, B-I, C-IV, D-II
DA-IV, B-I, C-III, D-II
Answer:(B) A-IV, B-II, C-I, D-III
Explanation
Oblique projectors meet the plane at an angle other than 90 degrees. Cavalier projection keeps receding lengths unforeshortened, cabinet projection foreshortens them, and orthographic projection uses projectors perpendicular to the plane. The mapping is A-IV, B-II, C-I, D-III.
Which statement is not true about global variables?
AValues of global variables sent to a called function may be changed inadvertently by that function.
BFunctions lose their independence and isolation when they use global variables.
CIt is not immediately apparent to a reader which values are sent to a called function.
DA function that uses global variables does not suffer from reusability.
Answer:(D) A function that uses global variables does not suffer from reusability.
Explanation
Global variables make functions less reusable because their behaviour depends on hidden shared state. The first three statements describe real drawbacks of using globals. The correct option follows from the stated definition or calculation; the other options omit a necessary condition or describe a different concept.
The light given off by a phosphor during exposure to an electron beam is known as
AFluorescence
BPhosphorescence
CPersistence
DRetracing
Answer:(A) Fluorescence
Explanation
Fluorescence is the immediate light emission while the electron beam strikes the phosphor. Persistence refers to how long the glow remains after excitation stops. The correct option follows from the stated definition or calculation; the other options omit a necessary condition or describe a different concept.
I. Current file position II. Beginning of file III. Desired file position IV. End-of-file test
AA-II, B-III, C-I, D-IV
BA-III, B-I, C-IV, D-II
CA-III, B-I, C-II, D-IV
DA-II, B-IV, C-III, D-I
Answer:(B) A-III, B-I, C-IV, D-II
Explanation
fseek sets a desired file position, ftell reports the current position, feof tests end-of-file status, and rewind returns the file pointer to the beginning. The correct option follows from the stated definition or calculation; the other options omit a necessary condition or describe a different concept.
A. Convert world coordinates to viewing coordinates.
B. Map viewing coordinates to normalized viewing coordinates using window–viewport specifications.
C. Construct the world-coordinate scene using modelling-coordinate transformations.
D. Map normalized viewport coordinates to device coordinates.
AD, C, B, A
BD, C, A, B
CC, A, B, D
DB, C, A, D
Answer:(C) C, A, B, D
Explanation
The conceptual order is modelling to world coordinates, world to viewing coordinates, normalization, and device mapping: C, A, B, D. The supplied page appears to print the first character of option 3 unclearly; the logical sequence and official key select option 3.
Consider the conditional statement if (m == 20 - 10 || n > 10). What is the order of execution of the following operations?
A. ==
B. -
C. ||
D. >
AD, B, A, C
BB, D, C, A
CB, D, A, C
DA, B, D, C
Answer:(C) B, D, A, C
Explanation
Subtraction has higher precedence than relational and equality operations; those comparisons are evaluated before the final logical OR. Thus the order is −, >, ==, ||. The correct option follows from the stated definition or calculation; the other options omit a necessary condition or describe a different concept.
AA data member of a class can be declared static and is normally used to maintain values common to the entire class.
BA friend function can be invoked like a normal function without the help of any object.
CThe scope-resolution operator (::) can be overloaded like normal operators.
DMultiple inheritance may duplicate inherited members from a grandparent base class; this may be avoided by making the common base class virtual.
Answer:(C) The scope-resolution operator (::) can be overloaded like normal operators.
Explanation
C++ does not allow the scope-resolution operator (::) to be overloaded. The other statements correctly describe static data, friend functions and virtual inheritance. The correct option follows from the stated definition or calculation; the other options omit a necessary condition or describe a different concept.
The major adverse side effects of scan conversion are:
A. Staircase appearance
B. Unequal brightness of slanted lines
C. Picket-fence problem
D. Rasterization
E. Pre-filtering and post-filtering
AA and B only
BA, B and C only
CB, C and D only
DC, D and E only
Answer:(B) A, B and C only
Explanation
Aliasing in scan conversion produces jagged/staircase edges, non-uniform brightness on slanted lines and the picket-fence effect. Rasterization and filtering are processes/remedies, not the adverse effects.
int x = 10, y = 15; x = ((x = y) ? (y + x) : (y - x));
What is the value of x after execution?
A5
B25
C15
D30
Answer:(D) 30
Explanation
The assignment x = y evaluates to 15, which is true. The conditional therefore selects y + x; both are 15 at that point, so x becomes 30. The correct option follows from the stated definition or calculation; the other options omit a necessary condition or describe a different concept.
Which of the following statements about
pointers in C are TRUE.
A. Pointers can be used to access array elements
B. Pointers can store the address of another
pointer
C. Pointers are automatically dereferenced in
expression
D. Pointers cannot be used to access structure
members
A(A) and (C) Only
B(A) and (B) Only
C(B) and (C) Only
D(C) and (D) Only
Answer:(B) (A) and (B) Only
Explanation
(A) is true: array elements are reachable through pointer arithmetic such as *(arr + i). (B) is true: a pointer is itself a variable with an address, so a pointer to a pointer is legal. (C) is false — dereferencing is explicit, through the * operator. (D) is false — structure members are reachable with p->member. Only (A) and (B) hold, so option B is correct.
Cal(a, b) {
if( b!=1 ) {
if( a!=1 ) {
printf("*");
Cal(a/2,b);
}
else {
b=b-1;
Cal(10,b);
}
}
}
How many times * is going to be printed, if the
function is called with Cal(10, 10); ?
A25
B23
C24
D27
Answer:(D) 27
Explanation
Each pass halves a by integer division, 10 → 5 → 2 → 1, printing * on the three calls where a ≠ 1. Reaching a = 1 decrements b and restarts with a = 10. That cycle runs for b = 10 down to b = 2, so nine times, giving 9 × 3 = 27 stars. Option D is correct.
Which of the following is correct way to declare a
functional pointer in C ?
Aint *func (int, int);
Bint (*func) (int, int);
Cint (func*) (int, int);
Dint func (int, int);
Answer:(B) int (*func) (int, int);
Explanation
In int (func)(int, int); the parentheses bind * to func first, so func is a pointer to a function taking two ints and returning int. Option A declares a function returning int, and options C and D place the asterisk where the syntax does not allow it. Option B is correct.
#include<stdio.h>
int main() {
int x[] = {2,4,6,8,10};
int a, b=0, *y=x+4;
for( a=0; a<5; a++) {
b = b +(*y-a) - *(y-a);
}
printf("%d\n",b);
return 0;
}
What will be the output of the above C program
?
A4
B6
C8
D10
Answer:(D) 10
Explanation
y points at x[4] = 10, and *y stays 10 throughout. Each iteration adds (10 − a) − x[4−a]: for a = 0 to 4 that is 10−10 = 0, 9−8 = 1, 8−6 = 2, 7−4 = 3 and 6−2 = 4. The running total is 0+1+2+3+4 = 10, so the program prints 10 — option D.
Which of the following are TRUE about
constructors in C++ ?
A. A constructor can be overloaded.
B. A constructor does not have a return type.
C. A constructor must be declared as a friend
function.
D. A constructor is called when an object is
destroyed.
A(B), (C), (D) Only
B(B), (C) Only
C(A), (B), (C) Only
D(A), (B) Only
Answer:(D) (A), (B) Only
Explanation
(A) is true — constructors can be overloaded on their parameter lists. (B) is true — a constructor has no return type, not even void. (C) is false: a constructor is an ordinary member function and is never required to be a friend. (D) is false: destruction invokes the destructor, not the constructor. Only (A) and (B), so option D.
f1 receives copies of the two pointers, so swapping them inside the function leaves a and b untouched and the first printf prints ONE TWO. f2 receives the addresses of a and b, so swapping *x and *y rewrites the caller’s own pointers and the second printf prints TWO ONE. The full output is ONE TWO TWO ONE — option A.
Which of the following C++ statements correctly
declares an abstract class ?
Aclass A { virtual void show ()=0 ; };
Bclass A { void show ()=0 ; };
Cclass A { void show() { } ; } ;
Dclass A { show ()=0; };
Answer:(A) class A { virtual void show ()=0 ; };
Explanation
A C++ class is abstract when it declares at least one pure virtual function, written virtual void show() = 0;. Option B omits virtual, so = 0 is not valid there; option C defines an ordinary member; option D has neither a return type nor virtual. Option A is correct.
A half adder adds two bits, so (A)-(IV). A decoder turns n inputs into 2ⁿ outputs, giving (B)-(I). A register is storage inside the CPU, so (C)-(II). Main memory holds the program while it runs, so (D)-(III). Option C is correct.
Consider the following statements regarding
combinational and sequential circuits.
A. Output of combinational circuits depends on
the only current input.
B. Output of combinational circuit depends on
the both current input and previous output.
C. Output of sequential circuit depends on the
current input.
D. Output of sequential circuit depends on both
current input and previous output.
A(A) and (C) Only
B(A) and (D) Only
C(B) and (D) Only
D(B) and (C) Only
Answer:(B) (A) and (D) Only
Explanation
A combinational circuit’s output is a pure function of its present inputs, which makes (A) true and (B) false. A sequential circuit adds memory, so its output depends on both the present input and the stored previous state, making (D) true and (C) false. Only (A) and (D) — option B.
#include<iostream.h>
using namespace std;
void swap(int &x, int &y)
{
int temp=x;
x=y;
y=temp;
}
int main()
{
int a=5, b=10;
swap(a,b);
swap(a,b);
cout<<a<<" "<<b;
return 0;
}
What will be the output of the above code?
A5, 10
B10, 5
C5, 5
D10, 10
Answer:(A) 5, 10
Explanation
swap takes its parameters by reference, so the first call genuinely exchanges a and b, giving a = 10 and b = 5. The second call exchanges them straight back, restoring a = 5 and b = 10. The program prints 5 10, so option A is correct.
#include<iostream.h>
using namespace std;
class Base {
public:
Base(){
cout<<"Base Const";
}
virtual ~Base() {
cout<<"Base dest";
}
};
class Derived : public Base {
public:
Derived() {
cout<<"Derived Const";
}
~Derived() {
cout<<"Derived dest";
}
};
int main() {
Base *b = new Derived();
delete b;
return 0;
}
ABase Const Derived Const Derived dest Base dest
BBase Const Derived Const Base dest Derived dest
CDerived Const Base Const Base dest Derived dest
DBase Const Derived Const Base dest
Answer:(A) Base Const Derived Const Derived dest Base dest
Explanation
Constructing a Derived object runs the Base constructor first and then the Derived one, printing Base Const Derived Const. Because ~Base is declared virtual, deleting through the Base* dispatches to ~Derived first and then ~Base, printing Derived dest Base dest. The full output is option A.
#include<stdio.h>
int temp =0;
int fun(int x, int y)
{
int z; temp++;
if(y==3) return (x*x*x);
else {
z=fun(x,y/3);
return (z*z*z);
}
}
int main() {
fun(4,81);
printf("%d",temp);
}
what will be the output of the following code :
A3
B4
C5
D6
Answer:(B) 4
Explanation
fun increments temp on entry and then recurses with y/3 until y reaches 3. The calls use y = 81, 27, 9 and 3, so temp is incremented four times including the base case, leaving temp = 4. Option B is correct.
Arrange the following steps of file handling in C
in the correct order :
A. Close the file
B. Read from or write to the file
C. Open the file
D. Check for error
A(A), (C), (D), (B)
B(D), (B), (C), (A)
C(C), (D), (B), (A)
D(B), (D), (A), (C)
Answer:(C) (C), (D), (B), (A)
Explanation
File handling in C runs: open the file (C), check that the open succeeded (D), read from or write to it (B), then close it (A). Checking for error immediately after opening is what makes the subsequent I/O safe. That order is option C.
#include<stdio.h>
void main()
{
int arr[5] = {10,20,30,40,50};
int *p = (int*) (&arr +1);
printf("%d%d", *(arr+1), *(p-1));
}
A10 50
B20 50
C30 40
D20 40
Answer:(B) 20 50
Explanation
(arr+1) is arr[1] = 20. Because &arr has type int()[5], &arr + 1 steps a whole array forward, so p points just past arr[4]; p − 1 therefore points at arr[4] = 50. The program prints 20 50, so option B is correct.
#include<stdio.h>
void main()
{
int arr[ ] = {1, 2, 3, 4, 5};
int *p = arr;
printf("%d", *p++);
printf("%d", *(p+1));
}
Find the output of the above code?
A1,2
B1,3
C2,3
D1,4
Answer:(B) 1,3
Explanation
*p++ yields the current target arr[0] = 1 and then advances p to arr[1]. The second statement evaluates *(p + 1), which is arr[2] = 3. The output is 1 followed by 3, so option B is correct.
A program that is used by other routines to accomplish a particular task, is called :
AMicro program
BMicro operation
CRoutine
DSubroutine
Answer:(D) Subroutine
Explanation
The key idea is stated in the problem: A program that is used by other routines to accomplish a particular task, is called :. The correct answer is D: Subroutine. It follows the governing definition, algorithm, or calculation in this programming languages and computer graphics item; the other choices fail to satisfy one or more stated conditions.
Consider a triangle PQR with coordinates as P(0,0), Q(2,2) and R(10,4). If this triangle is to be magnified to four times its size while keeping R(10, 4) fixed, then the coordinates of the magnified triangle are :
A(—20, —12), Q(—20, —4) and R(10, 4)
B(—30, —12), Q(—22, —4) and R(10, 4)
C(—25, —10), Q(22, —4) and R(10, 4)
D(30, —12), Q(—22, 4) and R(10, 4)
Answer:(B) (—30, —12), Q(—22, —4) and R(10, 4)
Explanation
The key idea is stated in the problem: Consider a triangle PQR with coordinates as P(0,0), Q(2,2) and R(10,4). If this triangle is to be magnified to four times its size while keeping R(10, 4) fixed, then the coordinates of the magnified triangle are :. The correct answer is B: (—30, —12), Q(—22, —4) and R(10, 4). It follows the governing definition, algorithm, or calculation in this programming languages and computer graphics item; the other choices fail to satisfy one or more stated conditions.
BVirtual functions do not permit calling of derived class functions using a base class pointer
CWe can never build an object from a class containing a pure virtual function
DPure virtual functions can never have a body
Answer:(C) We can never build an object from a class containing a pure virtual function
Explanation
The key idea is stated in the problem: Which of the following statements is TRUE ?. The correct answer is C: We can never build an object from a class containing a pure virtual function. It follows the governing definition, algorithm, or calculation in this programming languages and computer graphics item; the other choices fail to satisfy one or more stated conditions.
What is the output of the following program ? #include<stdio.h> int main( ) { int i=3; while (i— —) { int i=10; i=} printf("%d", i); } printf("%d", i); }
A990
B9990
C999-1
D99-1
Answer:(C) 999-1
Explanation
The key idea is stated in the problem: What is the output of the following program ? #include<stdio.h> int main( ) { int i=3; while (i— —) { int i=10; i=} printf("%d", i); } printf("%d", i); }. The correct answer is C: 999-1. It follows the governing definition, algorithm, or calculation in this programming languages and computer graphics item; the other choices fail to satisfy one or more stated conditions.
A system bus in which each data item is transferred during a time slice known in advance to both units source and destination is called :
AMIMD
BDMA
Casynchronous bus
Dsynchronous bus
Answer:(D) synchronous bus
Explanation
The key idea is stated in the problem: A system bus in which each data item is transferred during a time slice known in advance to both units source and destination is called :. The correct answer is D: synchronous bus. It follows the governing definition, algorithm, or calculation in this programming languages and computer graphics item; the other choices fail to satisfy one or more stated conditions.
Which of the following are tautology ?
A. @3PAQ)3(23Q)
B. (€3Q)Q)>PvQ) (CQ) (VAP) 3Q)((PV>P)R)
D. (Q4(PAAP))3(R(PA=P)) Choose the correct answer from the options given below :
The key idea is stated in the problem: Which of the following are tautology ?
A. @3PAQ)3(23Q)
B. (€3Q)Q)>PvQ) (CQ) (VAP) 3Q)((PV>P)R)
D. (Q4(PAAP))3(R(PA=P)) Choose the correct answer from the options given below :. The correct answer is C: (A) and(B) Only. It follows the governing definition, algorithm, or calculation in this programming languages and computer graphics item; the other choices fail to satisfy one or more stated conditions.
Consider the three points P1(1, 2, 0), P2(3, 6, 20) and P3(2, 4, 6) and a view point C(0, 0, —10). Choose the correct options.
A. P1 obscure P2, if viewed from
C.
B. 2 obscure P1, if viewed from
C.
C. P3 does not obscure P1, if viewed from
C.
D. P2 does not obscure P3, if viewed from
C. Choose the correct answer from the options given below :
Find the number of tuples by applying the operation Xb x05 aye"
X (S, Si, C)
Y (S, P, D)
(J, 1, M)
(B, 2, N)
(R, 3, H)
(T, 4, G)
(J, S₁, CA)
(B, P₁, AB)
(R, D₁, DC)
(A, H₁, MD)
A1
B3
C4
D6
Answer:(C) 4
Explanation
The key idea is stated in the problem: Find the number of tuples by applying the operation Xb x05 aye". The correct answer is C: 4. It follows the governing definition, algorithm, or calculation in this programming languages and computer graphics item; the other choices fail to satisfy one or more stated conditions.
The clipping process in computer graphics is used for
AAdding graphics
BCopying
CZooming
DRemoving objects and lines
Answer:(D) Removing objects and lines
Explanation
Clipping identifies which parts of a scene lie outside a defined window or viewport and removes them before rendering, so only the visible portion is drawn.
A. Adding graphics — clipping never creates new content, it only discards what falls outside the visible region.
B. Copying — copying duplicates content, unrelated to boundary testing against a window.
C. Zooming — zooming changes scale through a transformation such as scaling, not through removing out-of-bound geometry.
D. Removing objects and lines — correct. Clipping algorithms such as Cohen-Sutherland test each line or object against the clip boundary and discard the portions outside it.
#include <stdio.h>
int main(){
int a, b, c;
a = 0x10;
b = 010;
c = a + b;
printf("%d", c);
return 0;
}
A20
B24
CGarbage
Derror
Answer:(B) 24
Explanation
C interprets a leading 0x as a hexadecimal literal and a leading 0 as an octal literal, so both variables here hold different decimal values than their digits suggest.
a = 0x10 is hexadecimal 10, which equals 16 in decimal.
b = 010 is octal 10, which equals 8 in decimal.
c = a + b = 16 + 8 = 24, and printf("%d", c) prints this decimal value directly.
A. 20 — would only follow from treating both literals as decimal, ignoring the 0x and leading-zero prefixes.
B. 24 — correct, from 16 + 8.
C. Garbage — the code has no undefined behavior, both variables are assigned valid literal values.
D. error — the program is syntactically valid and compiles without any error.
Each element of array a is a struct containing a name, an integer, and a pointer to another struct in the same array, so tracing the pointers requires following which array index each p field actually points to.
a[0].z is "Nagpur", the string stored directly in the first element.
ptr is initialized to a, which is the same address as a[0], so ptr->z is also a[0].z, which is "Nagpur".
a[2].p is initialized to a, the address of a[0], so a[2].p->z dereferences back to a[0].z, again "Nagpur".
A. Nagpur Raipur Kanpur — would only hold if each printed value came from a different array index, but ptr and a[2].p both resolve back to a[0].
B. Nagpur Nagpur Nagpur — correct, because a[0].z, ptr->z, and a[2].p->z all trace back to the same struct, a[0].
C. Kanpur Kanpur Kanpur — would require all three expressions to resolve to a[2], but only a[2].z itself is "Kanpur", not the pointer-dereferenced values used here.
D. Error — the program is syntactically valid, and the self-referential array initialization is legal because a is already declared by the time its own elements are initialized with pointers into it.
Which two-dimensional transformation is used to resize a two-dimensional object?
ATranslation
BRotation
CScaling
DShearing
Answer:(C) Scaling
Explanation
Resizing an object means changing its dimensions, which is exactly what the scaling transformation does by multiplying coordinates by scale factors along each axis.
A. Translation — moves an object to a new position without changing its size or shape.
B. Rotation — turns an object about a pivot point, preserving its size.
C. Scaling — correct. It multiplies the x and y coordinates by scale factors, enlarging or shrinking the object.
D. Shearing — slants an object's shape along an axis, distorting it rather than resizing it uniformly.
Match List I with List II on curve and surface representations.
List-I
List-II
A. Bezier curves
I. 3 dim objects that have translation rotational symmetry
B. B-Splines
II. Fractal geometry
C. Sweep representations
III. Bias and tension
D. Natural objects
IV. painting drawing CAD
List I / List II: computer graphics representation techniques
AA-IV, B-I, C-III, D-II
BA-II, B-III, C-IV, D-I
CA-IV, B-III, C-I, D-II
DA-II, B-IV, C-I, D-III
Answer:(C) A-IV, B-III, C-I, D-II
Explanation
Each List-I technique matches a distinct computer-graphics concept.
Bezier curves are the standard curve tool in painting, drawing, and CAD software — A-IV.
Beta-splines, an extension of B-splines, are controlled by two extra shape parameters called bias and tension — B-III.
Sweep representations build 3D solids by sweeping a 2D profile along a path (translational sweep) or around an axis (rotational sweep), producing objects with translational or rotational symmetry — C-I.
Natural objects such as mountains, clouds, and coastlines are modeled using fractal geometry because of their irregular, self-similar structure — D-II.
This gives the mapping A-IV, B-III, C-I, D-II.
A. A-IV, B-I, C-III, D-II — swaps B and C's correct pairings.
B. A-II, B-III, C-IV, D-I — swaps A and D's correct pairings.
C. A-IV, B-III, C-I, D-II — correct, matches every pairing above.
D. A-II, B-IV, C-I, D-III — swaps A and D's correct pairings while keeping C right.
The Sutherland-Hodgman algorithm clips a polygon against a clipping window by processing the window's edges one at a time and successively trimming the polygon against each edge in turn. This edge-by-edge approach only produces a correct single output polygon when the clipping window is convex — against a concave clip window the result can split into multiple disjoint pieces that a single output polygon cannot represent correctly. This is why the classic Sutherland-Hodgman method is specifically described as working on convex polygons.
A. Smooth curves — Sutherland-Hodgman clips straight-edged polygons, not curves.
B. Line segment — line clipping uses different algorithms, such as Cohen-Sutherland or Liang-Barsky.
C. Convex polygons — correct. The algorithm's edge-by-edge clipping only guarantees a correct result for a convex clip polygon.
D. Concave polygons — clipping against a concave polygon can produce multiple disconnected pieces that break the algorithm's single-polygon output assumption.
Consider the rectangle with vertices (0, 0), (0, 2), (3, 0), (3, 2). There is scaling of 2 towards x-axis and 3 towards y-axis. The new coordinates of the rectangle are
A(0, 0), (6, 0), (0, 4), (6, 4)
B(0, 0), (6, 0), (0, 4), (3, 2)
C(0, 0), (6, 0), (0, 6), (6, 6)
D(0, 0), (4, 0), (0, 6), (4, 6)
Answer:(C) (0, 0), (6, 0), (0, 6), (6, 6)
Explanation
Scaling a point (x, y) by factors Sx and Sy transforms it to (x·Sx, y·Sy). Here Sx = 2 and Sy = 3, so every vertex is transformed by (x·2, y·3):
(0, 0) → (0, 0)
(0, 2) → (0, 6)
(3, 0) → (6, 0)
(3, 2) → (6, 6)
The new rectangle has vertices (0, 0), (6, 0), (0, 6), (6, 6).
A. (0, 0), (6, 0), (0, 4), (6, 4) — uses a y-scale of 2 instead of 3.
B. (0, 0), (6, 0), (0, 4), (3, 2) — mixes scaled and unscaled coordinates.
C. (0, 0), (6, 0), (0, 6), (6, 6) — correct, matches applying Sx=2 and Sy=3 to every vertex.
D. (0, 0), (4, 0), (0, 6), (4, 6) — uses an x-scale of 4/3 instead of 2.
main ( )
{
static float a [ ] = {13.24, 1.5, 4.5, 5.4, 3.5};
float *j, *k;
j = a;
k = a + 4;
j = j * 2;
k = k/2;
printf("%f %f", *j, *k);
}
A13.25, 4.5
B1.5, 3.5
C13.24, 1.5, 4.5, 5.4, 3.5
DIllegal use of pointer in main function
Answer:(D) Illegal use of pointer in main function
Explanation
In standard C, pointer arithmetic only permits adding or subtracting an integer from a pointer, or subtracting two pointers of the same type — it does not permit multiplying or dividing a pointer by a number. The lines j = j * 2 and k = k / 2 apply * and / directly to the pointer variables j and k, which are not valid pointer operations in C.
A standards-conforming C compiler rejects both lines with a type error such as "invalid operands to binary * (have 'float *' and 'int')", so the program never successfully compiles and no output is produced.
A. 13.25, 4.5 — assumes the pointer arithmetic silently executes and produces a numeric result, which a real compiler would reject.
B. 1.5, 3.5 — also assumes valid execution of illegal pointer arithmetic.
C. 13.24, 1.5, 4.5, 5.4, 3.5 — assumes the whole array prints, which does not follow from this code even if it compiled.
D. Illegal use of pointer in main function — correct. Multiplying or dividing a pointer by a scalar is not legal C, so the code fails to compile.
Answer:(C) x is an array of three function pointer
Explanation
Reading the declarator (*(*arrfptr[3])())[10] from the identifier outward, with [] binding tighter than unary * at each step, resolves x's type layer by layer:
arrfptr[3] — arrfptr is an array of 3 elements.
(*arrfptr[3]) — each of those 3 elements is a pointer.
(*arrfptr[3])() — each pointer points to a function taking no arguments.
*(*arrfptr[3])() — each such function returns a pointer.
(*(*arrfptr[3])())[10] — that returned pointer points to an array of 10 elements.
So x is an array of 3 pointers to functions, where each function returns a pointer to an array of 10 elements.
A. x is a pointer — wrong. arrfptr is declared as an array, not a single pointer, so x itself is not a pointer.
B. x is a array of three pointer — wrong. This captures the array-of-three-pointers layer correctly but drops that each pointer specifically targets a function, so it under-describes the type.
C. x is an array of three function pointer — correct. It is the only option that names both the array-of-three structure and the function-pointer nature of its elements.
D. Error in x declaration — wrong. The declarator is syntactically valid C, so it does not produce a declaration error.
Among the given options, C is the closest full match to the derived type, so it is the intended answer.
Simplify it by filling in the following blank with a single Boolean expression without changing the behaviour of the conditional code:
if (------)
return 'true';
else
return 'false';
Ax > 25
Bx <= 25
Cy > 100
Dy <= 100
Answer:(B) x <= 25
Explanation
List which combinations of x and y return true in the original code.
The original returns true for (x<=25 && y<=100) and for the implicit else case (x<=25 && y>100). Both true-returning cases share x<=25, and y does not matter in either.
The two false-returning cases both require x>25, again regardless of y.
So the function's output depends only on x — it returns true exactly when x<=25, which is the single condition option B gives.
If a constructor 'Date' is declared explicitly and has to be defined outside the class, which of the following is correct?
ADate::Date(int dd) { /.../ }
Bexplicit Date:: Date(int dd) { /.../ }
CSuch a constructor cannot be defined
DConstructor always has to be defined inside the class
Answer:(A) Date::Date(int dd) { /.../ }
Explanation
The explicit specifier is only valid on the declaration of a constructor inside the class body — it controls whether the compiler may use the constructor for implicit conversions, and C++ does not allow it to be repeated on an out-of-class definition.
So the out-of-class definition uses the scope resolution operator with no explicit keyword, exactly as in Date::Date(int dd) { /*...*/ }.
Which one of the following allows the session to continue?
AWhen a user quits a browser
BWhen the user logs out and is invalidated by the servlet
CWhen the session is timed out due to inactivity
DWhen the user refreshes the browser and there is a persistent cookie
Answer:(D) When the user refreshes the browser and there is a persistent cookie
Explanation
A session ends when its cookie is lost, when the server explicitly invalidates it, or when it times out — all three of the other options describe exactly those endings.
A persistent cookie survives a page refresh because it is stored on disk rather than only in browser memory, so the browser resends the same session identifier on the next request and the server matches it back to the still-active session.
Which of the following lists defined in HTML share similar elements?
A. Unordered lists
B. Ordered lists
C. Definition Lists
D. Correlated lists
E. Enumerated lists
Choose the most appropriate answer from the options given below:
AA, B, D only
BA, C, E only
CA, B, C only
DA, C, D only
Answer:(C) A, B, C only
Explanation
HTML actually defines exactly three list types, because unordered lists (<ul>), ordered lists (<ol>), and definition lists (<dl>) are the only standard list elements in the HTML specification.
"Correlated lists" and "enumerated lists" are not real HTML elements, so they cannot belong to the group of genuine HTML list types.
A, B, and C are the three actual HTML list categories.
NTA's official final answer key for this exact sitting marked this question as dropped (full marks awarded to all candidates), consistent with the genuine interpretive ambiguity in what "share similar elements" was intended to mean here.
A. If the implementation of generated or derived classes differ only through a parameter, we have
I. To use class hierarchy
B. If the actual types of objects used cannot be known at compile time, then we have
II. Improved run-time efficiency
C. If inline operations are essential and templates are used then we have
III. To use templates
D. To gain access to differing instances for derived classes through base we have
IV. To use explicit casting
List I and List II for the matching question
AA-I, B-II, C-IV, D-III
BA-III, B-I, C-II, D-IV
CA-I, B-III, C-II, D-IV
DA-II, B-I, C-III, D-IV
Answer:(B) A-III, B-I, C-II, D-IV
Explanation
Match each C++ design scenario to the technique it calls for.
A-III, B-I, C-II, D-IV
When generated classes differ only through a parameter, templates parameterize that difference, matching III. When the actual object types are unknown until runtime, a class hierarchy with virtual dispatch is needed, matching I. Combining inline operations with templates avoids virtual-call overhead, giving improved run-time efficiency, matching II. Accessing a derived class's specific members through a base class pointer requires an explicit downcast, matching IV.
In what sequence the initialization, testing and execution of body is done while using do-while loop?
A. Commenting
B. Execution of the body
C. Initialisation
D. Testing the condition
Choose the correct answer from the following
AD,B,C
BD,C,B
CC,A,B
DC,B,D
Answer:(D) C,B,D
Explanation
A do-while loop always runs its body at least once before checking the condition.
Execution starts with initializing any loop variables, then runs the loop body, and only after that tests the condition to decide whether to repeat, giving the order Initialisation, Execution of the body, Testing the condition, which is C,B,D.
Assertion (A): A Raster scan device is a CRT graphic device and can use a television monitor for display.
Reason (R): In Raster scan display the picture is composed of a series of dots. These dots are traced out as a series of horizontal lines. Television works in a similar fashion.
In the light of the above statements, choose the correct answer from the options given below:
ABoth A and R are true and R is the correct explanation of A
BBoth A and R are true but R is not the correct explanation of A
CA is true but R is false
DA is false but R is true
Answer:(A) Both A and R are true and R is the correct explanation of A
Explanation
A raster scan CRT builds its image from a series of dots traced out along horizontal scan lines, which is exactly how a television picture tube also draws its image.
That shared horizontal-line scanning mechanism is precisely why a raster scan device can reuse television display hardware, so Reason R directly explains why Assertion A is true.
int arr[3][4][2] = {{{2,4},{7,8},{3,4},{5,6}},{{7,6},{3,4},{5,3},{2,3}},{{8,9},{7,2},{3,4},{5,1}}};
Which one of the following can be used to refer to element 1 in the above 3-d array?
Aarr[3][4][2]
B((*(arr+2)+3)+1)
C*(arr+2) + *(arr+3) + *(arr+1)
Darr[2][3][2]
Answer:(B) ((*(arr+2)+3)+1)
Explanation
The value 1 appears only once in the array, inside the innermost pair {5,1} at arr[2][3], so the target element is arr[2][3][1].
((*(arr+2)+3)+1) dereferences arr+2 to reach the third 2-D block, then +3 to reach its fourth row {5,1}, then +1 to reach the second element of that row, which is exactly arr[2][3][1] = 1
A. arr[3][4][2] — indexes one past the valid range in every dimension, since the declared sizes only allow indices up to 2, 3, and 1.
B. ((*(arr+2)+3)+1) — correct. Reaches arr[2][3][1], the position holding the value 1.
**C. *(arr+2) + (arr+3) + (arr+1) — adds three pointer-typed row addresses together instead of dereferencing them, which is not valid element access.
D. arr[2][3][2] — uses index 2 on the innermost dimension, whose declared size is only 2, so valid indices only go up to 1.
Allowing different derived classes to be used interchangeably through the interface provided by a common base class is called ______.
ADerived polymorphism
BCompile time polymorphism
CStatic polymorphism
DRun time polymorphism
Answer:(D) Run time polymorphism
Explanation
When a program calls a virtual function through a base class pointer or reference, the actual derived-class implementation that runs is decided while the program is executing, based on the real object type behind that pointer.
This late binding of the interface to different derived-class behaviors is exactly what run time polymorphism means, letting derived classes stand in for the base class interchangeably at runtime.
Compile time (static) polymorphism instead covers function overloading and templates, where the exact function is fixed at compile time, so those terms do not describe interchangeable derived-class substitution.
In ______ curve the last and the first vertices of the polygon lie on the curve and all other vertices define the derivatives, order and shape of the curve.
AB-Spline Curve
BBoxline curve
CBezier curve
DGaussian curve
Answer:(C) Bezier curve
Explanation
A Bezier curve is defined so that it always passes through exactly the first and last control points of its defining polygon, while the interior control points do not lie on the curve itself.
Those interior points instead pull the curve's shape and set the tangent directions (derivatives) at the endpoints, and the total number of control points fixes the degree (order) of the resulting polynomial curve.
A B-spline curve, by contrast, generally does not pass through any of its control points under a basic uniform knot vector, so the described endpoint-interpolation property specifically identifies the Bezier curve.
FFTs are ________ techniques used to encode digital video and audio information and helps analyse the signal in __________ domain.
AEncryption, time
BEncryption, frequency
CCompression, time
DCompression, frequency
Answer:(D) Compression, frequency
Explanation
The Fast Fourier Transform converts a time-domain signal into its frequency-domain representation, which is the standard first step used in multimedia compression schemes for audio and video.
By concentrating a signal's energy into fewer significant frequency coefficients, FFT-based transforms let compression algorithms discard perceptually less important components, which is a compression technique, not an encryption one, and the analysis it performs happens in the frequency domain rather than the time domain.
A. shared interfaces
B. run-time polymorphism
C. less redundant information
D. dynamic binding
Choose the Correct answer from the options given below:
AA, B, C only
BA, B, D only
CB, C, D only
DA, C, D only
Answer:(B) A, B, D only
Explanation
Inheritance lets derived classes share a common base class interface, and that shared interface is what makes dynamic binding of overridden operations to their runtime types meaningful, which in turn is what produces run-time polymorphism.
A. shared interfaces — correct. A base class interface is exactly what derived classes inherit and share.
B. run-time polymorphism — correct. Late binding through the shared interface is what lets derived classes substitute for the base class at runtime.
C. less redundant information — more accurately a benefit of code reuse in general, not of inheritance's structural mechanism specifically. A deep or poorly designed hierarchy does not automatically reduce redundancy and can increase coupling instead.
D. dynamic binding — correct. It is the mechanism that ties an overridden operation to the object's actual runtime type.
Because different course references group these four benefits differently, this item is worth checking against the specific textbook list used in the course.
Which of the following are correct using the constructor?
A. string s1
B. string s2 (s1)
C. string s3 {7}
D. string s4 {'a'}
E. string s5{7,'a'}
Choose the most appropriate answer from the options given below:
AA, B, D, E only
BA, B, C only
CA, B, D only
DA and B only
Answer:(A) A, B, D, E only
Explanation
Checking each declaration against the actual std::string constructor overloads shows every one compiles except the single bare integer in braces.
A. string s1 — calls the default constructor, creating an empty string. Valid.
B. string s2(s1) — calls the copy constructor. Valid.
C. string s3{7} — braced-init tries to match the initializer_list<char> constructor with a single int element, which requires a narrowing int-to-char conversion that is disallowed in list-initialization, and there is no other single-int constructor to fall back on. Not valid.
D. string s4{'a'} — correct, matches the initializer_list<char> constructor with one char element, producing the string "a". Valid.
E. string s5{7,'a'} — correct, since the two elements have different types (int and char), the initializer_list<char> overload cannot bind them without narrowing, so overload resolution instead selects the (size_type count, char ch) constructor, producing a string of seven 'a' characters. Valid.
With C excluded and A, B, D, E all valid, the correct option is A, B, D, E only.
Suppose that a corporate website appearance varies according to the department that owns various documents. All the documents need to follow the corporate look and feel. The HR department does not need a separate style sheet. It needs only the sheet containing the difference from the corporate sheet.
Which of the following statements justify the above scenario?
A. The styles sheets cannot stack on each other
B. The style sheets can stack on each other
C. The style sheets can override each other
D. The style sheets cannot override each other
Choose the most appropriate answer from the options given below:
AA, C Only
BB, C Only
CB, D only
DA, D only
Answer:(B) B, C Only
Explanation
The scenario describes exactly how CSS cascading works. The HR department's sheet layers on top of the corporate sheet, only needing to specify the differences.
Style sheets can stack on each other, meaning a page can apply multiple linked style sheets together, which lets the HR sheet build on the corporate one instead of duplicating it.
Style sheets can also override each other, so where the HR sheet defines a rule, it takes precedence over the corporate sheet's matching rule while everything else the HR sheet does not touch still applies from the corporate sheet.
This stacking and overriding behavior is the reason the HR department only needs a sheet for its differences, which matches statements B and C, not the two statements that deny stacking or overriding are possible.
Each item is matched by the way it captures or produces image data.
A camera's sensor captures an entire image at once as a full two-dimensional grid of pixels, making it a 2-D array input device, giving A-III.
A liquid crystal display works by modulating light that passes through its layers, which is why it is classified as a transmissive device, giving B-I.
An ink jet printer builds an image from individual dots that are either fired or not at each position, which is a binary (on/off) decision per pixel, matching binary image output, giving C-IV.
A flat-bed scanner builds its image by moving a single sensor line across the page, capturing one row (a one-dimensional array) at a time, giving D-II.
Hidden surface removal problem with minimal 3D pipeline can be solved with
APainter's algorithm
BWindow Clipping algorithm
CBrute force rasterization algorithm
DFlood fill algorithm
Answer:(A) Painter's algorithm
Explanation
Painter's algorithm removes hidden surfaces with minimal extra pipeline machinery by simply depth-sorting polygons from farthest to nearest and drawing them in that order, so nearer surfaces naturally overwrite farther ones on the frame buffer.
Window clipping only restricts geometry to the viewport and does not resolve visibility, brute-force rasterization scan-converts polygons without any depth logic of its own, and flood fill is a region-filling technique unrelated to depth or visibility at all.
A. num > 65 || num < 65 — equivalent, num is not 65 exactly when it is either greater or smaller than 65.
B. !(num == 65) — equivalent, this is the direct logical negation of equality.
C. num − 65 — equivalent as a truth value, since this expression is nonzero (treated as true in C) precisely when num is not 65, and zero (false) only when num equals 65.
D. !(num = 65) — not equivalent. The single = is an assignment, not a comparison, so this always assigns 65 to num first. The expression (num = 65) then evaluates to 65, which is truthy, so !(num = 65) is always false and it also destructively overwrites num's original value, unlike num != 65.
A pointer's entire purpose is indirect access, it stores an address and reaches a value only by dereferencing through that address. Referencing a value directly is what an ordinary variable does, not what a pointer does, so pointers cannot be used to reference a value directly.
Pointers do find a variable's address (via the address-of operator), do simulate call by reference (by passing an address for the callee to dereference), and do manipulate dynamic data structures such as linked lists and trees.
This transformation is called
[x̅ y̅ z̅ w̅]ᵀ = [[a₁ b₁ c₁ d₁],[a₂ b₂ c₂ d₂],[a₃ b₃ c₃ d₃],[e f g h]] [x y z 1]ᵀ
AScaling
BShear
CHomography
DSteganography
Answer:(C) Homography
Explanation
In a standard affine transform such as scaling or shear, the bottom row of the 4×4 homogeneous matrix is fixed at [0 0 0 1], leaving the homogeneous coordinate w unchanged. Here the bottom row is the general [e f g h], which lets w vary with x, y, and z, producing perspective-style division effects on the transformed coordinates.
This general projective (perspective-capable) form of a homogeneous coordinate transform is called a homography, distinguishing it from simpler affine operations like pure scaling or shear.
AUsing the '=', instead of '==' to determine if two values are equal
BDivide by zero
CFailing to initialize counter and total variables before the body of loop
DUsing commas instead of two required semicolon in a for loop header
Answer:(B) Divide by zero
Explanation
Confusing = with ==, forgetting to initialize a counter or accumulator, and mixing up separators in a for-loop header are all classic logic-level mistakes, code that compiles and runs but produces the wrong result because of a flawed program design.
Divide by zero is different in kind. It is a runtime error, an operation that fails or crashes during execution rather than one that silently produces an incorrect result, which is what sets logic errors apart.
AAll function calls in C pass arguments using call by value.
BCall by reference enables a called function to modify a variable in calling function.
CCall by value is always more efficient than call by reference.
DProgrammers use pointers and indirection operation to simulate call by reference.
Answer:(C) Call by value is always more efficient than call by reference.
Explanation
A. All function calls in C pass arguments using call by value. — true. Even when a pointer is passed, the pointer's own value (the address) is copied, C has no native pass-by-reference mechanism.
B. Call by reference enables a called function to modify a variable in calling function. — true, that is the defining behavior of reference-style parameter passing.
C. Call by value is always more efficient than call by reference. — false. Copying a large struct or array by value is more expensive than passing a small pointer or reference to it, so call by value is not always the more efficient choice.
D. Programmers use pointers and indirection operation to simulate call by reference. — true, this is exactly how C achieves reference-like behavior without a native reference type.
It is always important and useful to include an 'alt' attribute on an 'img' tag in HTML. Which of the reasons given below is/are correct?
A. Users who cannot see the image due to vision impairment can be given a textual description that a screen reader speaks aloud.
B. If the image fails to load (slow connection, broken path, etc.), the alt text is displayed instead.
C. It gives SEO (Search Engine Optimization) benefits.
Choose the correct answer from the options given below:
AA only
BB and C only
CC only
DA, B, and C
Answer:(D) A, B, and C
Explanation
The alt attribute serves accessibility (screen readers read it aloud for visually impaired users), graceful degradation (it is shown when the image cannot load), and SEO (search engines use it to understand and index image content). All three statements are therefore correct.
int f(unsigned int N) {
unsigned int counter = 0;
while (N > 0) {
counter += N & 1;
N = N >> 1;
}
return counter == 1;
}
A1 if N is odd, otherwise 0
B1 if N is a power of 2, otherwise 0
C1 if the binary representation of N is all 1s, otherwise 0
D1 if the binary representation of N has any 1s, otherwise 0
Answer:(B) 1 if N is a power of 2, otherwise 0
Explanation
The loop adds (N & 1) to counter for every bit while right-shifting N, so counter ends up holding the number of set bits (population count) of N. counter == 1 is true exactly when N has a single 1-bit, i.e. when N is a power of 2. An odd number such as 3 has two 1-bits, so option A is wrong.
Consider the following recursive function F() in Java that takes an integer and returns a String:
public static String F(int N) {
if (N <= 0) return "-";
return F(N - 3) + N + F(N - 2) + N;
}
What is the value of F(5)?
A-2-25-3-135
B-2-25-1-3-135
C-1-145-2-245
D-2-25-3-1-135
Answer:(D) -2-25-3-1-135
Explanation
The function concatenates strings: the base case returns a dash, and each non-base call returns F(N-3) then N then F(N-2) then N. Expanding, F(5) needs F(2) and F(3). F(2) evaluates to "-2-2" because both recursive calls hit the base case. F(1) evaluates to "-1-1", so F(3) becomes "-3-1-13". Substituting everything back, F(5) equals "-2-2" then 5 then "-3-1-13" then 5, giving "-2-25-3-1-135".
Match List-I (Programming Terms) with List-II (Meaning).
List-I
List-II
A. JNDI
I. Runtime support for running a Java program
B. RMI
II. The API in support of naming and directory services
C. JDK
III. The methods and runtime support for calling remote methods
D. JRE
IV. The compiler and class libraries to develop Java applications
AA-II, B-III, C-IV, D-I
BA-II, B-IV, C-III, D-I
CA-I, B-III, C-IV, D-II
DA-III, B-II, C-IV, D-I
Answer:(A) A-II, B-III, C-IV, D-I
Explanation
JNDI (Java Naming and Directory Interface) is the API for naming and directory services (II). RMI (Remote Method Invocation) provides the mechanism for invoking methods on remote JVM objects (III). JDK bundles the compiler and class libraries to build Java applications (IV). JRE supplies the runtime support (JVM plus libraries) needed to run a Java program (I).
Match List-I (Programming Paradigms) with List-II (Characteristics).
List-I
List-II
A. Imperative
I. Declarative, clausal representation, theorem proving
B. Object-oriented
II. Side-effect-free, declarative, expression evaluation
C. Logic
III. Imperative, abstract data type
D. Functional
IV. Command-based, procedural
AA-IV, B-III, C-I, D-II
BA-III, B-IV, C-I, D-II
CA-IV, B-III, C-II, D-I
DA-II, B-III, C-I, D-IV
Answer:(A) A-IV, B-III, C-I, D-II
Explanation
Imperative programming is command-based and procedural (IV). Object-oriented programming is imperative in style and organised around abstract data types/objects (III). Logic programming uses declarative clauses and resolution/theorem proving (I). Functional programming is declarative, side-effect-free and based on expression evaluation (II).
You have eight black-and-white images taken with a 1-megapixel camera and one 8-colour image taken with an 8-megapixel camera. How much disk space in total is needed to store these images?
A1 GB
B4 MB
C3 MB
D3 GB
Answer:(B) 4 MB
Explanation
A black-and-white pixel needs 1 bit, so each 1-MP image is 1,000,000 bits = 125 KB, and eight of them total about 1 MB. An 8-colour image needs 3 bits per pixel, so 8 MP x 3 bits = 24,000,000 bits = about 3 MB. Total is roughly 1 MB + 3 MB = 4 MB.
The midpoint (Bresenham) algorithm for rasterizing lines is optimized relative to the DDA algorithm in that:
A. It avoids round-off operations.
B. It is incremental.
C. It uses only integer arithmetic.
D. All straight lines can be displayed as exactly straight.
Choose the correct answer from the options given below:
AA and B only
BA and C only
CA, B, C, and D
DA, B, and C only
Answer:(D) A, B, and C only
Explanation
Bresenham's advantages over DDA are that it is incremental, uses only integer arithmetic and avoids the floating-point rounding DDA needs (A, B, C). Statement D is false: like every raster algorithm it only produces a discrete approximation of a line, not an exact geometric straight line.
Find the transformation matrix M that maps the square with vertices (1,1), (-1,1), (-1,-1), (1,-1) to the parallelogram with corresponding vertices (2,1), (0,1), (-2,-1), (0,-1).
A[[1, 1, 0], [0, 1, 0], [0, 0, 1]]
B[[1, 0, 0], [1, 1, 0], [0, 0, 1]]
C[[1, 1, 1], [0, 1, 0], [0, 0, 1]]
D[[1, 1, 0], [1, 1, 0], [0, 0, 1]]
Answer:(A) [[1, 1, 0], [0, 1, 0], [0, 0, 1]]
Explanation
Write the homogeneous matrix with unknown top-left entries a, b, c, d. From (1,1) to (2,1): a + b = 2 and c + d = 1. From (-1,1) to (0,1): -a + b = 0, so a = b = 1; then c + d = 1 with -c + d = 1 gives c = 0, d = 1. So x = x + y, y = y, a horizontal shear: [[1,1,0],[0,1,0],[0,0,1]].
A Bezier curve P(t) is defined by four control points in the xy-plane: P0 = (-2, 0), P1 = (-2, 4), P2 = (2, 4), P3 = (2, 0). Which statements are correct?
A. P(t) has degree 3.
B. P(1/2) = (0, 3).
C. P(t) may extend outside the convex hull of its control points.
Choose the correct answer from the options given below:
AA and B only
BA and C only
CB and C only
DA, B, and C
Answer:(A) A and B only
Explanation
Four control points give a cubic Bezier curve, degree 3 (A). At t = 1/2 the Bernstein weights are 1/8, 3/8, 3/8, 1/8; x = (-2 - 6 + 6 + 2)/8 = 0 and y = (0 + 12 + 12 + 0)/8 = 3, so P(1/2) = (0, 3) (B). Statement C is false: a Bezier curve always lies within the convex hull of its control points.
Statement I: The maximum number of sides a triangle can have after being clipped to a rectangular viewport is 6.
Statement II: In 3D graphics, the perspective transformation is nonlinear in z.
In light of the above statements, choose the correct answer from the options given below:
ABoth Statement I and Statement II are true
BBoth Statement I and Statement II are false
CStatement I is true but Statement II is false
DStatement I is false but Statement II is true
Answer:(D) Statement I is false but Statement II is true
Explanation
Clipping a 3-sided polygon against a 4-sided rectangle can add at most one vertex per clipping edge, giving up to 3 + 4 = 7 sides, so Statement I (which says 6) is false. Perspective projection divides coordinates by depth z, a nonlinear operation, so Statement II is true.
The <map> element defines an image map, and its <area> elements specify clickable regions. It is unrelated to a navigation sitemap or visual highlighting.
A compiler uses 1-byte chars, 2-byte shorts, 4-byte ints, and 8-byte doubles. Every primitive must begin at an address that is a multiple of its size; fields cannot be reordered. How much space is consumed by an array A[10] of this structure?
struct { short s; char c; short t; char d; double r; int i; }
A150 bytes
B320 bytes
C240 bytes
D200 bytes
Answer:(C) 240 bytes
Explanation
The layout is s at bytes 0–1, c at 2, padding at 3, t at 4–5, d at 6, then one byte of padding before double r at 8–15 and int i at 16–19. The structure is rounded to 24 bytes for 8-byte alignment, so ten elements occupy 240 bytes.
public static float f(long m, long n) {
float result = (float)m / (float)n;
if (m < 0 || n < 0) return 0.0f;
else result -= f(m + 2, n * 3);
return result;
}
Which real value best approximates f(1, 3)?
A0.2
B0.4
C0.6
D0.8
Answer:(A) 0.2
Explanation
The recurrence alternates terms: 1/3 − 3/9 + 5/27 − 7/81 + …, stopping once m becomes negative in the recursive call chain. The partial sums settle near 0.2, whereas the larger choices ignore the alternating subtraction.
Which statements regarding XML are true?
A. XML is a set of tags designed to tell browsers how to display a web page.
B. XML defines syntax for representing data, while the data meaning depends on the application.
C. <Letter>, <LETTER>, and <letter> are different XML tags.
A(A) and (B) only
B(A) and (C) only
C(B) and (C) only
D(A), (B), and (C)
Answer:(C) (B) and (C) only
Explanation
XML describes and transports structured data; it is not a display-language such as HTML. XML names are case-sensitive, so B and C are true.
In 3D computer graphics, which statements are correct?
A. Under perspective projection, parallel lines generally do not remain parallel, except lines parallel to the view plane.
B. The perspective step uses a division by the depth coordinate after homogeneous transformation.
C. Perspective transformation is linear.
A(A) and (B) only
B(A) and (C) only
C(B) and (C) only
D(A), (B), and (C)
Answer:(A) (A) and (B) only
Explanation
Perspective makes parallel lines converge unless they are parallel to the image plane, and the perspective divide introduces the depth dependence. Because of that division, the resulting mapping is not linear.
For Gouraud and Phong shading, which statements are true?
A. Gouraud shading requires more computation than Phong shading.
B. Gouraud shading interpolates vertex colours across a polygon.
C. Phong shading interpolates vertex normals across a polygon.
A(A) and (B) only
B(A) and (C) only
C(B) and (C) only
D(A), (B), and (C)
Answer:(C) (B) and (C) only
Explanation
Gouraud shading interpolates precomputed colours. Phong shading interpolates normals and evaluates lighting per pixel, so it is normally more computationally expensive; B and C are true.
Match List-I with List-II. List I gives 3x3 matrices representing 2D transformations and
List-II shows the corresponding transformation diagrams.
List I (Matrix) List II (Transformation Diagram)
2 00
A. |0 2 0
001 MO ,
Shear — x (2).a
List I
List II
Items are listed in the question stem.
Match each item to its stated description or complexity.
A0 2
(B) jo 1 2 seale (2, 2).a
00 1L
(788)
a
05 —0.866 0
(C) |0.866 0.5 0
0 0 1 rotate(60°).
(II)
a
120
@) jo 1 0 a
001 (Iv)translate (2, 2).aChoose the correct answer from the options given below:
A-IV, B-II, C-III, D-I (2) A-IV. B-II, C-II, D-I
BOCR review required
CA-II, B-II, C-IV, D-I (4) A-II, B-IV, C-II, D-I
DOCR review required
Answer:(D) OCR review required
Explanation
Read each homogeneous matrix: diagonal 2s give scaling, the translation entries give translation, the sine/cosine block gives rotation, and the off-diagonal term gives x-shear. This produces the mapping in option D.
Given below are different properties of 3D projections from A-D. Identify the correct order on
the basis of property true of (i) a perspective projection only, (ii) an orthographic projection
only, (iii) both orthographic and projective transformations and (iv) neither orthographic nor
projective transformation, respectively.
A. B. C. D. Straight lines are mapped to straight lines.
Distances and angles are (in general) preserved.
Far away objects appear the same size as closer ones.
Requires homogeneous coordinates in order for it to be encoded into a linear
transformation.
AOCR review required
BOCR review required
CD, C. B.A (2) B,C,D.A
D,C, A,B (4) C,D,BA
DOCR review required
Answer:(C) D, C. B.A (2) B,C,D.A
D,C, A,B (4) C,D,BA
Explanation
Perspective alone makes distant objects appear smaller; orthographic projection preserves parallel scale but not general distances and angles; both map lines to lines; homogeneous coordinates encode perspective in the pipeline.
Statement I: Bezier curves are curves that interpolate all of their control points.
Statement II: A cubic bezier curve has four control points.
In the light of the above statements, choose the correct answer from the options given below
ABoth Statement I and Statement II are true
BBoth Statement I and Statement II are false
CStatement I is correct but Statement II is false
DStatement I is incorrect but Statement II is true.
Answer:(D) Statement I is incorrect but Statement II is true.
Explanation
Bezier curves generally approximate rather than interpolate their interior control points; only the endpoints are interpolated. A cubic Bezier curve has four control points, so only statement II is true.
Consider the following statements with respect to approaches to fill area on raster systems:
P. To determine the overlap intervals for scan lines that cross the area
Q. To start from a given interior position and paint outward from this point until a encounter the specified boundary conditions
Select the correct answer:
AP only
BQ only
CBoth P and Q
DNeither P nor Q
Answer:(C) Both P and Q
Explanation
Raster graphics algorithms use two standard approaches to fill interior regions:
P — describes scan-line polygon filling, where intersection spans along successive scan lines intersecting polygon boundaries are calculated.
Q — describes seed fill algorithms (boundary-fill and flood-fill), which start from an interior pixel and propagate outward until boundary conditions are met.
Because both P and Q are standard area-fill techniques in computer graphics, option C is correct.
Southerland-Hodgeman algorithm (Sutherland-Hodgman) — polygon clipping algorithm that clips arbitrary concave or convex polygons against clipping boundaries, not a line-clipping algorithm.
Cohen-Sutherland algorithm — line clipping algorithm utilizing outcodes for 2D clipping windows.
Liang-Barsky algorithm — line clipping algorithm based on parametric line equations.
Nicholl-Lee-Nicholl algorithm — line clipping algorithm dividing clipping regions into specialized zones to minimize intersection calculations.
Which of the following statements are true regarding C++?
A. Overloading gives the capability to an existing operator to operate on other data types.
B. Inheritance in object oriented programming provides support to reusability.
C. When object of a derived class is defined, first the constructor of derived class is executed then constructor of a base class is executed.
D. Overloading is a type of polymorphism.
Choose the correct option from the options:
AA and B only
BA, B and C only
CA, B and D only
DB, C and D only
Answer:(C) A, B and D only
Explanation
Evaluating C++ object-oriented principles:
A — true. Operator overloading allows existing C++ operators to be given user-defined meanings on class types.
B — true. Inheritance allows derived classes to absorb fields and methods from base classes, promoting code reusability.
C — false. In C++, base class constructors execute first to initialize base components before derived class constructor bodies run.
D — true. Function and operator overloading provide compile-time (static) polymorphism.
Which of the following are legal statements in C programming language?
(a) int *P = &44;
(b) int *P = &r;
(c) int P = &a;
(d) int P = a;
Choose the correct option:
A(a) and (b)
B(b) and (c)
C(b) and (d)
D(a) and (d)
Answer:(C) (b) and (d)
Explanation
In C programming, the address-of operator & requires an lvalue operand that designates a mutable memory location. Applying & to a numeric literal such as &44 is illegal because literals are rvalues without an addressable memory location. Initializing an integer directly with a pointer value as in int P = &a violates type safety without an explicit cast. Conversely, int *P = &r correctly binds an integer pointer to the address of variable r, and int P = a assigns the integer value of a to the integer variable P. Therefore, only statements (b) and (d) are legal.
A rectangle is bound by the lines x = 0; y = 0; x = 5 and y = 3. The line segment joining (-1, 0) and (4, 5), if clipped against this window will connect the points __________.
A(0, 1) and (3, 3)
B(0, 1) and (2, 3)
C(0, 1) and (4, 5)
D(0, 1) and (3, 5)
Answer:(B) (0, 1) and (2, 3)
Explanation
The clipping window spans the domain 0 <= x <= 5 and 0 <= y <= 3.
The slope of the line passing through (-1, 0) and (4, 5) is:
m = (5 - 0) / (4 - (-1)) = 5 / 5 = 1
The equation of the line is:
y - 0 = 1 * (x - (-1)) => y = x + 1
Finding intersections with the clipping boundaries:
At the left boundary x = 0:
y = 0 + 1 = 1
Since 1 is in [0, 3], the point (0, 1) lies on the boundary.
At the top boundary y = 3:
3 = x + 1 => x = 2
Since 2 is in [0, 5], the point (2, 3) lies on the boundary.
Thus, the clipped line segment inside the window connects (0, 1) and (2, 3).
Which tag is used to enclose any number of javascript statements in HTML document?
A<code>
B<script>
C<title>
D<body>
Answer:(B) <script>
Explanation
The <script> tag is the standard HTML element used to embed or reference executable client-side JavaScript code. The <code> tag displays code snippets as styled text. The <title> tag defines the browser window title, and the <body> tag contains the main visible markup.
If we want to resize a 1024 × 768 pixels image to one that is 640 pixels wide with the same aspect ratio, what would be the height of the resized image?
A420 Pixels
B460 Pixels
C480 Pixels
D540 Pixels
Answer:(C) 480 Pixels
Explanation
The aspect ratio of the original image is preserved when resizing.
P: An XML document with correct syntax as specified by W3C is called "Well Formed".
Q: An XML documented validated against a DTD is both "Well formed" and "Valid".
R: <?xml version="1.0" encoding="UTF-8"> is syntactly correct declaration for the version of an XML document.
Select the correct answer from the options given below:
AP and Q only
BP and R only
CQ and R only
DAll of P, Q and R
Answer:(A) P and Q only
Explanation
Evaluating the statements regarding XML specifications:
P is true because any XML document adhering to fundamental W3C syntax rules (proper nesting, matching tags, unique root element) is classified as well-formed.
Q is true because an XML document validated against a Document Type Definition (DTD) must be well-formed before it can satisfy validity constraints.
R is false because an XML declaration is a processing instruction that must terminate with ?> rather than just >. The valid syntax requires <?xml version="1.0" encoding="UTF-8"?>.
Consider the following C-code fragment running on a 32-bit x86 machine:
typedef struct {
union {
unsigned char a;
unsigned short b;
} U;
unsigned char c;
} S;
S B[10];
S *p = &B[4];
S *q = &B[5];
p -> U.b = 0x1234; /* structure S takes 32-bits */
If M is the value of q - p and N is the value of ((int) &(p -> c)) - ((int)p), then (M, N) is
A(1, 1)
B(3, 2)
C(1, 2)
D(4, 4)
Answer:(C) (1, 2)
Explanation
Analyzing both values based on C pointer arithmetic and memory layout:
Pointer subtraction (q - p) computes the difference in array index units between pointers of the same type:
Index(B[5]) - Index(B[4]) = 5 - 4 = 1.
Therefore, M = 1.
Struct S takes 32 bits (4 bytes). Inside S, union U contains a 2-byte unsigned short and a 1-byte char, requiring 2-byte alignment and occupying bytes 0 and 1.
Member c is placed at byte offset 2.
Subtracting byte addresses ((int)&(p->c) - (int)p) yields the byte offset 2.
Therefore, N = 2.
Consider the following statements regarding 2D transforms in computer graphics:
S1: [1 0; 0 -1] is a 2×2 matrix that reflects (mirrors) any 2D point about the X-axis.
S2: A 2×2 matrix which mirrors any 2D point about the X-axis, is a rotation matrix.
What can you say about the statements S1 and S2?
ABoth S1 and S2 are true
BOnly S1 is true
COnly S2 is true
DBoth S1 and S2 are false
Answer:(B) Only S1 is true
Explanation
Analyzing geometric transformation matrices:
S1 is true because reflection across the X-axis leaves x unchanged (x' = x) and inverts y (y' = -y), which corresponds precisely to the transformation matrix [1 0 — 0 -1].
S2 is false because a pure 2D rotation matrix has determinant +1 and preserves coordinate orientation. The reflection matrix has determinant (1)(-1) - (0)(0) = -1, representing an orientation-reversing reflection that cannot be produced by any rotation.
P: In a scripting language like JavaScript, types are typically associated with values, not variables.
Q: It is not possible to show images on a web page without the <img> tag of HTML.
Select the correct answer from the options given below:
AP only
BQ only
CBoth P and Q
DNeither P nor Q
Answer:(A) P only
Explanation
Evaluating programming language and web presentation principles:
P is true because JavaScript is dynamically typed. Variables hold references to values of any type, and type definitions attach dynamically to the runtime values themselves.
Q is false because images can be displayed without <img> tags through CSS background-image properties, SVG graphics, HTML5 <canvas>, <picture>, or embedded data URIs.
Using the phong reflectance model, the strength of the specular highlight is determined by the angle between
Athe view vector and the normal vector
Bthe light vector and the normal vector
Cthe light vector and the reflected vector
Dthe reflected vector and the view vector
Answer:(D) the reflected vector and the view vector
Explanation
The Phong illumination model calculates specular reflection using the cosine of the angle between the viewer's line of sight and the ideal reflection path:
I_spec = I_s * k_s * (R · V)^n
Here, R is the unit vector along the direction of ideal mirror reflection of the incident light, and V is the unit vector pointing toward the observer viewpoint.
The highlight intensity depends directly on the angle between the reflected vector and the view vector.
public class Good {
private int m;
public Good(int m) { this.m = m; }
public Boolean equals(Good n) { return n.m == m; }
public static void main (String args []){
Good m₁ = new Good(22);
Good m₂ = new Good(22);
Object s₁ = new Good(22);
Object s₂ = new Good(22);
System.out.println(m₁.equals(m₂));
System.out.println(s₁.equals(s₂));
System.out.println(m₁.equals(s₂));
System.out.println(s₁.equals(m₁));
}
}
ATrue, True, False, False
BTrue, False, True, False
CTrue, True, False, True
DTrue, False, False, False
Answer:(D) True, False, False, False
Explanation
Tracing method overloading versus overriding in Java:
Class Good defines public Boolean equals(Good n), which overloads rather than overrides Object.equals(Object).
m₁.equals(m₂) — static types are both Good, so compiler selects Good.equals(Good). Comparing 22 == 22 evaluates to True.
s₁.equals(s₂) — static type of s1 is Object. Compiler invokes Object.equals(Object), which checks reference equality. Since s1 and s2 are separate instances, this evaluates to False.
m₁.equals(s₂) — argument s2 has static type Object. The compiler cannot bind to equals(Good), resolving to inherited Object.equals(Object). Different references yield False.
s₁.equals(m₁) — static type of s1 is Object. Invokes Object.equals(Object). Different references yield False.
In the context of 3D computer graphics, which of the following statements is/are true?
P: Orthographic transformations keep parallel lines parallel.
Q: Orthographic transformations are affine transformations.
Select the correct answer from the options given below:
ABoth P and Q
BNeither P nor Q
COnly P
DOnly Q
Answer:(A) Both P and Q
Explanation
Evaluating orthographic projection characteristics in 3D computer graphics:
P is true because orthographic projections project along parallel lines onto the viewing plane, preserving parallelism so that parallel lines remain parallel.
Q is true because orthographic projections are linear transformations (followed by translation if needed), satisfying the definition of affine transformations that preserve lines and parallelism.
In 3D Graphics, which of the following statements about perspective and parallel projection is/are true ?
P : In a perspective projection, the farthest an object is from the centre of projection, the smaller it appears.
Q : Parallel projection is equivalent to a perspective projection where the viewer is standing infinitely far away.
R : Perspective projections do not preserve straight lines.
Choose the correct answer from the code given below :
Code :
AP and Q only
BP and R only
CQ and R only
DP, Q and R
Answer:(A) P and Q only
Explanation
Statements P and Q are standard mathematical properties of geometric projections in 3D computer graphics.
Statement P is true because perspective foreshortening scales object dimensions inversely with distance from the center of projection.
Statement Q is true because moving the center of projection to infinity causes projectors to become parallel, making parallel projection a limiting case of perspective projection.
Statement R is false because perspective projection transforms straight lines in 3D space into straight lines on the projection plane.
Consider the following recursive Java function if that takes two long arguments and returns a float value :
public static float f(long m, long n)
{
float result = (float) m / (float) n;
if (m < 0 || n < 0)
return 0·0f;
else
result += f(m*2, n*3);
return result;
}
Which of the following integers best approximates the value of f(2, 3) ?
A1
B0
C3
D2
Answer:(D) 2
Explanation
The recursive calls compute the sum of an infinite geometric progression with first term a = 2/3 and common ratio r = 2/3.
Evaluating the series term by term:
Call 0: (2 / 3)^1
Call 1: (4 / 9) = (2 / 3)^2
Call 2: (8 / 27) = (2 / 3)^3
In Java, long values will eventually overflow to negative values, terminating the recursion with base case 0.0f.
The mathematical sum of this infinite series is:
Sum = a / (1 - r) = (2 / 3) / (1 - 2 / 3) = (2 / 3) / (1 / 3) = 2.
The integer that best approximates this sum is 2 (Option D).
Options A, B, and C differ substantially from the series limit.
If the frame buffer has 10-bits per pixel and 8-bits are allocated for each of the R, G, and B components, then what would be the size of the color lookup table (LUT) ?
A(2¹⁰ + 2²⁴) bytes
B(2¹⁰ + 2¹¹) bytes
C(2⁸ + 2⁹) bytes
D(2¹⁰ + 2⁸) bytes
Answer:(B) (2¹⁰ + 2¹¹) bytes
Explanation
The size of a color lookup table equals the number of table entries multiplied by the storage required per entry.
Number of entries = 2^(bits per pixel) = 2^10 entries
Bits per entry = 8 bits (R) + 8 bits (G) + 8 bits (B) = 24 bits = 3 bytes per entry
In 3D Graphics, which of the following statements is/are true ?
P : Back-face culling is an example of an image-precision visible-surface determination procedure.
Q : Z-buffer is a 16-bit, 32-bit, or 64-bit field associated with each pixel in a frame buffer that can be used to determine the visible surfaces at each pixel.
Choose the correct answer from the code given below :
Code :
AQ only
BP and Q
CNeither P nor Q
DP only
Answer:(A) Q only
Explanation
Visible-surface determination methods are classified into object-space precision and image-space precision.
Statement P is false because back-face culling operates in object space by calculating polygon surface normals and dot products, making it an object-precision procedure.
Statement Q is true because the Z-buffer algorithm stores depth values (typically 16, 24, 32, or 64 bits) per pixel in image space to resolve surface visibility.
What does the following Java function perform ? (Assume int occupies four bytes of storage)
public static int f(int a)
{ // Pre-conditions : a > 0 and no overflow/underflow occurs
int b = 0;
for (int i = 0; i < 32; i++)
{
b = b << 1;
b = b | (a & 1);
a = a >>> 1; // This is a logical shift
}
return b;
}
AReturn the int that represents the number of 0’s in the binary representation of integer a.
BReturn the int that represents the number of 1’s in the binary representation of integer a.
CReturn the int that has the reversed binary representation of integer a.
DReturns the int that has the binary representation of integer a.
Answer:(C) Return the int that has the reversed binary representation of integer a.
Explanation
The loop shifts the least significant bits of a into the accumulator b from right to left, reversing the bit sequence.
In each iteration, b = b << 1 shifts existing bits in b leftward by 1 position.
b = b | (a & 1) extracts the current least significant bit of a and places it in the least significant position of b.
a = a >>> 1 logically shifts a rightward by 1 position with zero fill.
Over 32 iterations for a 32-bit integer, bit 0 of a moves to bit 31 of b, and bit 31 of a moves to bit 0 of b.
Thus, the method returns the integer whose 32-bit binary representation is the exact bit-reversal of a (Option C).
void f(char w[])
{
int x = strlen(w); //length of a string
char c;
for (int i = 0; i < x; i++)
{
c = w[i];
w[i] = w[x–i–1];
w[x–i–1] = c;
}
}
Which of the following is the purpose of f( ) ?
AIt outputs the contents of the array in the original order
BIt outputs the contents of the array with the characters shifted over by one position
CIt outputs the contents of the array with the characters rearranged so they are no longer recognized as the words in the original phrase.
DIt outputs the contents of the array in reverse order.
Answer:(A) It outputs the contents of the array in the original order
Explanation
Because the loop iterates over the entire string length x rather than terminating at x / 2, every pair of symmetric characters is swapped twice.
In the first half of the loop (from i = 0 to i < x / 2), each character at index i is swapped with its symmetric counterpart at index x - i - 1, reversing the string.
In the second half of the loop (from i = x / 2 to i < x), the exact same pairs are swapped again in reverse direction, restoring every character to its initial position.
Consequently, the array retains its exact initial contents in the original order (Option A).
Reversing the string (Option D) would require looping only up to x / 2.
Consider the midpoint (or Bresenham) algorithm for rasterizing lines given below :
(1) Input (x1, y1) and (x2, y2)
(2) y = y1
(3) d = f(x1 + 1, y1 + 1/2) //f is the implicit form of a line
(4) for x = x1 to x2
(5) do
(6) plot(x, y)
(7) if(d < 0)
(8) then
(9) y = y + 1
(10) d = d + (y1 – y2) + (x2 – x1)
(11) else
(12) d = d + (y1 – y2)
(13) end
(14) end
Which statements are true?
P : For a line with slope m > 1, we should change the outer loop in line (4) to be over y.
Q : Lines (10) and (12) update the decision variable d through an incremental evaluation of the line equation f.
R : The algorithm fails if d is ever 0.
Choose the correct answer from the code given below :
Code :
AQ and R only
BP and Q only
CP, Q and R
DP only
Answer:(B) P and Q only
Explanation
Statements P and Q are true principles of Bresenham's rasterization algorithm, while statement R is false.
Statement P is true because stepping along x for steep lines (slope m > 1) produces discontinuous pixels, requiring the roles of x and y to swap so the loop iterates along y.
Statement Q is true because Bresenham's method evaluates decision variable d incrementally using finite differences of the implicit line equation rather than floating-point recalculation.
Statement R is false because when d = 0, the midpoint lies directly on the line equation, and the algorithm safely defaults to selecting either candidate pixel without failure.
Therefore, statements P and Q only are true (Option B).
Consider the following two C++ programs P1 and P2 and two statements S1 and S2 about these programs :
P1:
void f (int a, int * b, int & c)
{ a = 1; *b = 2; c = 3; }
int main()
{ int i = 0; f(i, &i, i); cout << i; }
P2:
double a = 1, b = 2;
double & f(double & d)
{ d = 4; return b; }
int main()
{ f(a) = 5; cout << a << " : " << b; }
S1 : P1 prints out 3
S2 : P2 prints out 4 : 2
What can you say about the statements S1 and S2 ?
AOnly S1 is true
BBoth S1 and S2 are true
COnly S2 is true
DNeither S1 nor S2 is true
Answer:(A) Only S1 is true
Explanation
Evaluating parameter bindings and reference assignment in C++ proves that S1 is true and S2 is false.
In program P1:
Variable i is passed by value to a, by pointer to b, and by reference to c.
Inside f, a = 1 affects only the local parameter.
*b = 2 writes 2 into variable i.
c = 3 subsequently overwrites variable i with 3.
Therefore, main prints 3, making statement S1 true.
In program P2:
Global variables are a = 1 and b = 2.
Calling f(a) binds reference d to variable a. Inside f, d = 4 assigns 4 to a.
f returns a reference to global variable b (double &).
The assignment f(a) = 5 writes 5 into variable b.
Therefore, main prints 4 : 5, not 4 : 2.
Statement S2 is false, so only S1 is true (Option A).
Sign in to read the full explanation
Frequently asked questions
How many Programming Languages and Computer Graphics questions have been asked in UGC NET Computer Science?
141 Programming Languages and Computer Graphics questions appear in the UGC NET Computer Science papers held between 2018–2026, and all of them are on this page with their answer key.
Are the answers on this page free?
Yes. Every question, its options, and the correct answer are free to read with no account. Signing in additionally unlocks the detailed explanation under each question.
Is Programming Languages and Computer Graphics an important topic for UGC NET Computer Science?
Programming Languages and Computer Graphics appears in every recent UGC NET Computer Science paper, across all 14 sittings covered here. Its share of the paper makes it worth revising thoroughly rather than sampling.
How should I practise Programming Languages and Computer Graphics after reading these questions?
Attempt the Programming Languages and Computer Graphics topic-wise sets, which put the same questions into a timed interface with instant scoring and weak-area analysis afterwards.