Weekly Technical Skill Test (12/09/25)
(C, C++, Java)
[B.Tech, BCA, MCA]
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
SHOBHIT UNIVERSITY GANGOH
Time: 1 Hour
……………………………………………………………………………………………………………………………………
Student Name Roll NO
Course Name Year/Semester
/
Instructions:
1. Attempt all questions
2. Multiple Tick will not be considered
3. The use of Mobile phone, smart watch, and any electronic gadget is strictly prohibited
4. Final decision will be made by the committee
……………………………………………………………………………………………………………………………………
1. What are the elements present in the array of the the following C code? 2. Consider the following declaration:
int array[5] = {5}; int a, *b=&a, **c=&b;
a) 5, 5, 5, 5, 5 The following program fragment
b) 5, 0, 0, 0, 0 a=4;
c) 5, (garbage), (garbage), (garbage), (garbage) **c=5;
d) (garbage), (garbage), (garbage), (garbage), 5 a) does not change the value of a
b) assigns address of c to a
c) assigns the value of b to a
d) assigns 5 to a
3. Which of the following c statement will calculate the correct size of an 4. What is the data type of the array passed from the command line into
array of 10 integers? the main() function in C?
(Assuming the declaration as int a[10];) a) char arr[];
a) sizeof(a[10]); b) char *arr[];
b) sizeof(*a); c) char **arr[];
c) sizeof(a); d) char arr[][];
d) sizeof(&a);
5. What will be the output produced by the following C code: 6. What should be the output of below C++ program?
int main() #include<iostream>
{ int main()
int array[5][5]; {
printf("%d",( (array == *array) && (*array == array[0]) )); int a=10;
return 0; std::cout<<a++;
} return 0;
a) 1 }
b) 0 a) 11
c) 2 b) 10
d) -1 c) Error
d) 0
7. Consider the following function implemented in C: 8. Consider the following C code
void printxy(int x, int y) int main()
{ {
int *ptr; int a = 300;
x = 0; char *b = (char *)&a;
ptr = &x; *++b = 2;
y = *ptr; printf("%d ",a);
*ptr = 1; return 0;
printf("%d,%d", x, y); }
} A) 556
The output of the printxy(1,1) is B) 300
a) 0,0 C) Runtime Error
b) 0,1 Compile Time Error
c) 1,0
d) 1,1
9. What is the output of this C code? 10. Which of the following is true with respect to Reference?
#include #include <stdio.h>
void main() #define VAL 3 * (2 + 6)
{ void solve() {
int k=5; int a = 10 + VAL;
int *p=&k; printf("%d", a);}
int **m=&p; int main() {
printf("%d %d %d",k,*p,**m); solve();
} return 0;}
a) 5 5 5 a) A reference can never be NULL
b) 5 5 junk b) A reference needs an explicit dereferencing mechanism
c) 5 junk junk c) A reference can be reassigned after it is established
d) Compile time error d) A reference and pointer are synonymous
11. The value printed by the following program is 12. Pick the best statement for the following program snippet:
void f(int* p, int m) #include <stdio.h>
{ int main()
m = m + 5; {
*p = *p + m; int var; /*Suppose address of var is 2000 */
return; void *ptr = &var;
} *ptr = 5;
void main() printf("var=%d and *ptr=%d",var,*ptr);
{ return 0;
int i=5, j=10; }
f(&i, j); a) It will print “var=5 and *ptr=2000”
printf("%d", i+j); b) It will print “var=5 and *ptr=5”
} c) It will print “var=5 and *ptr=XYZ” where XYZ is some random
a) 10 address
b) 20 d) Compile error
c) 30
d) 40
15. The following statement in ‘C’ 16. Which of the following operators can be applied on structure
int (*f())[ ]; variables?
declares a) Equality comparison ( == )
a) a function returning a pointer to an array of integers. b) Assignment ( = )
b) a function returning an array of pointers to integers. c) Both of the above
c) array of functions returning pointers to integers. d) None of the above
d) an illegal statement.
17. Consider the following C declaration 18. What will be the output of the following code snipt
struct { #include <stdio.h>
short s[5]; int main() {
union { int x = 5;
float y; printf("%d %d %d", x, x<<1, x>>1);
long z; return 0;
}u; }
} t; a) 5 10 2
b) 5 5 5
a) 22 bytes c) 5 2 10
b) 14 bytes d) Error
c) 18 bytes
d) 10 bytes
19. Consider the following declaration : 20. Assume that size of an integer is 32 bit. What is the output of
struct addr { following program?
char city[10]; #include<stdio.h>
char street[30]; struct st
int pin ; {
}; int x;
struct { static int y;
char name[30]; };
int gender; int main()
struct addr locate; {
} person , *kd = &person ; printf("%d", sizeof(struct st));
person.name +2 return 0;
a) kd -> (name +2 ) }
b) *((*kd).name + 2 ) a) 4
c) either (A) or (B), but not (C) b) 8
c) Compiler Error
d) Runtime Error
21. What is an object in object-oriented programming? 22. Which of the following is a feature of procedure-oriented
a) A code snippet programming?
b) Compile error as ++a is not valid identifier a) Class-based
c) A variable b) Focus on functions
d) A function c) Inheritance
d) Polymorphism
23. In OOP, what does encapsulation refer to? 24. Encapsulation in OOP is the combining of data and methods into a
a) Storing data in arrays single unit called class, for the purpose of data hiding.
b) The process of inheritance a) Inheritance
c) Combining data and methods b) Polymorphism
d) A type of loop c) Abstraction
d) Encapsulation
25. Which concept in OOP allows for the same function to be used in 26. Consider the following code snippet:
different ways based on the object it is associated with? class Animal { public: void eat() { cout << "Eating..."; } };
a) Encapsulation What is demonstrated in this code?
b) Abstraction a) Inheritance
c) Inheritanced b) Encapsulation
d) Polymorphism c) Class definition
d) Polymorphism
27. How many loops are there in C++ 98? 28. What following operator is called
a) 2 ?: in C++?
b) 3 a) Scope Resolution Operator
c) 4 b) Conditional Operator
d) 1 c) Ternary Operator
d) if else o/p
29. Faster access to non-local variables is achieved using an array of 30. Can we typecast void * into int * in C++?
pointers to activation records, called a44.5000 a) Yes
a) stack b) No
b) heap c) Undefined
c) display d) Depends on Compiler
activation tree
31. Can we overload functions in C++? How to access and edit data in data file handling using structures?
a) Yes a) read()
b) No b) write()
c) Compilation Error c) both A and B
d) Runtime Error d) without read()32.
33. What is output of below C++ program? 34. What will be the output of the following C++ program?
#include<iostream> #include<iostream>
using namespace std;
int main() int main(){
{ int a = 5;
const int a=10; auto check = [=]() {
a++; a = 10;};
std::cout<<a; check();
return 0; cout<<"Value of a: "<<a<<endl;
} return 0;}
a) 10 a) Segmentation fault
b) 11 b) Value of a: 5
c) Compilation Error c) Value of a: 10
d) Linking Error d) Error
35. Which of the following is true about inline functions in C++? 36. Which of the following is used to define a constant in C++ that
a) They reduce function call overhead cannot be changed?
b) They increase code size a) #define
c) They are only suggestions to the compiler b) const
d) All of the above c) static
d) fixed
37. What will be the output of the following C++ program? 38. What will be the output of the following C++ code?
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main() int main (){
{ int a, b, c;
int n = 5; a = 2;
void *p = &n; b = 7;
int *pi = static_cast<int*>(p); c = (a > b) ? a : b;
cout << *pi << endl; cout << c;
return 0; } return 0; }
a) 5 a) 12
b) 6 b) 14
c) compile time error c) 6
d) runtime error d) 7
39. What will be the output of the following C++ code snippet? 40. What will be the output of the following C++ program?
#include <stdio.h> #include <iostream>
#include<iostream> #include <string>
using namespace std; using namespace std;
int main () { int main ()
int array[] = {0, 2, 4, 6, 7, 5, 3}; {
int n, result = 0; string str ("Sanfoundry");
for (n = 0; n < 8; n++) for (size_t i = 0; i < str.length();)
{ {
result += array[n]; cout << str.at(i-1);
} }
cout << result; return 0;
return 0;} }
a) 21 a) runtime error
b) 27 b) Sanfo
c) 26 c) S
d) 25 d) Sanfoundry
41. Identify the output of the following program. 42. Identify the output of the following program.
String str = “Hellow”; String str = “abcde”;
System.out.println(str.indexOf(‘t)); System.out.println(str.substring(1, 3));
A) 0 A) abc
B) 1 B) bc
C) True C) bcd
D) -1 D) cd
43. Identify what can directly access and change the value of the variable 44. What is the output of the following code snippet?
res. #include <stdio.h>
package com.mypackage; int main() {
public class Solution{ int a = 10, b = 20, c;
private int res = 100; c = a > b? a : b;
} printf(“%d”, c);
A) Any class return 0;}
B) Only solution class A) 10
C) Any class that extends solution B) 20
D) none C) 30
D) Error
45. Find the output of the following program. 46. Identify the output of the following program.
public class Solution{ Public class Test{
public static void main(String[] args){ Public static void main(String argos[]){
int[] x = {120, 200, 016}; String str1 = “one”;
for(int i = 0; i < x.length; i++){ String str2 = “two”;
System.out.print(x[i] + “ “); System.out.println(str1.concat(str2));
} }}
}} A) one
A) 120 200 016 B) two
B) 120 200 14 C) onetwo
C) 120 200 16 D) twoone
D) None
47. What will be the output of the following Java code? 48. Find the output of the following code.
class increment { Public class Solution{
public static void main(String args[]) Public static void main(String args[]){
{ Int i;
int g = 3; for(i = 1; i < 6; i++){
System.out.print(++g * 8); if(i > 3) continue; }
}} System.out.println(i); }}
a) 32 A) 3
b) 33 B) 4
c) 24 C) 5
d) 25 D) 6
49. Find the output of the following code. 50. How many times will “Interviewbit” be printed.
Public class Solution{ Int count = 0;
Public static void main(String… argos){ do{
Int x = 5; System.out.println(“Interviewbit”);
x * = (3 + 7); count++;
System.out.println(x);}} } while(count < 10);
A) 50 A) 8
B) 22 B) 9
C) 10 C) 10
D) None D) 11
51. What is Runnable? 52. Exception created by try block is caught in which block
A) Abstract class A) catch
B) Interface B) throw
C) Class C) final
D) Method D) None
53. What is default session time of HttpSession? 54. Which code from the following will only retrieve the session?
(a) 30 seconds (a)HttpSession hs=request.getSession()
(b) 30 milliseconds (b)HttpSession hs=request.getSession(false)
(c) 30 minutes (c)HttpSession hs=request.getSession(true)
(d) there is no default session time (d)All of these
55. Which method is used to send the same request and response objects 56. Which class can handle any type of request so that it is protocol-
to another servlet ? independent?
(a) forward() (a)HttpServlet
(b) next() (b)Request
(c)sendForward() (c)Http
(d)sendRedirect() (d)GenericServlet
57. What is it called if an object has its own lifecycle and there is no 58. What is it called where child object gets killed if parent object is
dependency? killed?
a) Aggregation a) Aggregation
b) Composition b) Composition
c) Encapsulation c) Encapsulation
d) Association d) Association
59. Deployment Descriptor(DD) is a . 60. Which class provide implementation for service() method ?
(a) Servlet used to maintain other servlet. (a)GenericServlet
(b) Text document (b)HttpServlet
(c) XML document that is used by Web Container to run servlets and (c)Servlet
JSPs. (d)none of the above
(d) Library file.
Q.No Ans Q.No Ans Q.No Ans Q.No Ans
1 B 16 B 31 A 46 C
2 D 17 A 32 C 47 A
3 C 18 A 33 C 48 B
4 B 19 C 34 B 49 A
5 A 20 C 35 D 50 C
6 B 21 C 36 B 51 B
7 A 22 B 37 A 52 A
8 A 23 C 38 D 53 C
9 A 24 D 39 B 54 B
10 A 25 C 40 A 55 A
11 B 26 C 41 A 56 D
12 D 27 B 42 B 57 D
13 28 C 43 B 58 B
14 29 C 44 B 59 C
15 A 30 A 45 B 60 A