HCL Technical MCQ - 239 Questions

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 66

HCL – TECHNICAL MCQ

1. Which of the following about the following two declaration is true


i ) int *F()
ii) int (*F)()
(a) Both are identical
(b) The first is a correct declaration and the second is wrong
(c) The first declaraion is a function returning a pointer to an integer and the second is a pointer to
function returning int
(d) Both are different ways of declarion pointer to a function    
Ans: [c]
2. What are the values printed by the following program?
#define dprint(expr) printf(#expr "=%d\n",expr)
main()
{
int x=7;
int y=3;
dprintf(x/y);
}
(a) #2 = 2 (b) expr=2 (c) x/y=2 (d) None of these
Ans: [c]
3. Which of the following is true of the following program
main()
{
char *c;
int *p;
c =(char *)malloc(100);
ip=(int *)c;
free(ip);
}
Ans: The code functions properly releasing all the memory allocated
4. Output of the following.
main()
{
int i;
char *p;
i=0X89;
p=(char *)i;
p++;
printf("%x\n",p);

Page 1 of 66
HCL – TECHNICAL MCQ

}
Ans: 0X8A
5. Which of the following is not a ANSI C language keyword?
Ans: Function.
6. When an array is passed as parameter to a function, which of the following statement is correct
choice:
(a) The function can change values in the original array
(b) In C parameters are passed by value. The function cannot change the original value in the array 
(c) It results in compilation error when the function tries to access the elements in the array
(d) Results in a run time error when the function tries to access the elements in the array
Ans: [a]
7. The type of the controlling expression of a switch statement cannot be of the type 
(a) int (b) char (c) short
(d) float (e) None of these
Ans: [d]
8. What is the value of the expression (36) + (aa)?
(a) 3 (b) 5 (c) 6
(d) a + 18 (e) None of these
Ans: [e]
9. What is the value assigned to the variable X if b is 7?
X = b>8 ? b <<3 : b>4 ? b>>1:b;
(a) 7 (b) 28 (c) 3
(d) 14 (e) None of these
Ans: [c]
10. Which is the output produced by the following program
main()
{
int n=2;
printf("%d %d\n", ++n, n*n);
}
(a) 3, 6 (b) 3, 4
(c) 2, 4 (d) cannot determine
Ans: [b]
11. What is the output of the following program?                                                             
int x= 0x65;
main()
{
char x;

Page 2 of 66
HCL – TECHNICAL MCQ

printf("%d\n",x)
}
(a) compilation error     b) 'A'      c) 65       d)
unidentified

12. What is the output of the following program


         main()
             {
              int a=10;
              int b=6;
              if(a=3)
              b++;
              printf("%d %d\n",a,b++);
              }
(a) 10,6 b)10,7 c) 3,6 d) 3,7
e) none
          
Answer : (a) 10,6

13. What can be said of the following program?


          main()
             {
                enum Months {JAN =1,FEB,MAR,APR};
                Months X = JAN;
                if(X==1)
                   {
                     printf("Jan is the first month");                                                             
                  }
             }
          (a) Does not print anything
          b) Prints : Jan is the first month
          c) Generates compilation error
          d) Results in runtime error
Answer: b) Prints : Jan..

14. What is the output of the following program?


main()
{
char *src = "Hello World";

Page 3 of 66
HCL – TECHNICAL MCQ

char dst[100];
strcpy(src,dst);
printf("%s",dst);
}strcpy(char *dst,char *src)
{while(*src) *dst++ = *src++;
}
) "Hello World" b)"Hello" c)"World" d) NULL e) unidentified
 Ans: d) NULL

15. What is the output of the following program?


main()
{
int l=6;
switch(l)
{ default : l+=2;
case 4: l=4;
case 5: l++;
break;
}
printf("%d",l);
}
(a)8                 b)6                   c)5                 d)4               e)none
Ans : a) 8

16. What is the output of the following program?


main()
{
int x=20;
int y=10;
swap(x,y);
printf("%d %d",y,x+2);
}
swap(int x,int y)
{
int temp;
temp =x;
x=y;
y=temp;

Page 4 of 66
HCL – TECHNICAL MCQ

}
(a)10,20             b) 20,12               c) 22,10             d)10,22               e)none
Ans:b

17. What is the output of the following problem ?


            #define INC(X) X++
             main()
               {
                int X=4;
                printf("%d",INC(X++));
               }
(a)4 b)5 c)6
d)compilation error e) runtime error
Answer : d) compilation error

18. what can be said of the following


            struct Node
{
            char *word;
             int count;
             struct Node left;
             struct Node right;
               }
                 (a) Incorrect definition
                 b) structures cannot refer to other structure
                 c) Structures can refer to themselves. Hence the statement is  OK
                 d) Structures can refer to maximum of one other structure
Answer :c)

19. What is the size of the following union. Assume that the size of int =2, size of float =4 and size of
       char =1.
       Union Tag{
         int a;
         flaot b;
        char c;
           };
        (a)2 b)4 c)1
d) 7   
20.  What is the output of the following program? (. has been used to indicate  a space)

Page 5 of 66
HCL – TECHNICAL MCQ

            main()
             {
              char s[]="Hello,.world";
             printf(%15.10s",s);
           }
           a )Hello,.World...
           b)....Hello,.Wor
           c)Hello,.Wor....
           d)None of the above

21.. Which of the following involves context switch,


(a) system call
(b) priviliged instruction
(c) floating poitnt exception
(d) all the above
(e) none of the above
Ans: (a)

22. In OST, terminal emulation is done in


(a) sessions layer
(b) application layer
(c) presentation layer
(d) transport layer
Ans: (b)

 23. For a 25MHz processor , what is the time taken by the instruction which needs 3 clock cycles,
(a)120 nano secs
(b)120 micro secs
(c)75 nano secs
(d)75 micro secs

 24. For 1 MB memory, the number of address lines required,


(a)11
(b)16
(c)22
(d) 24
Ans. (b)

Page 6 of 66
HCL – TECHNICAL MCQ

25. Semaphore is used for


(a) synchronization
(b) dead-lock avoidence
(c) box
(d) none
Ans. (a)

 26. Which holds true for the following statement class c: public A, public B
a) 2 member in class A, B should not have same name
b) 2 member in class A, C should not have same name
c) both
d) none
Ans. (a)

27. OLE is used in


a) inter connection in unix
b) interconnection in WINDOWS
c) interconnection in WINDOWS NT

 28. Macros and function are related in what aspect?


(a)recursion
(b)varying no of arguments
(c)hypochecking
(d)type declaration

 29.Preproconia.. does not do which one of the following


(a) macro
(b) conditional compliclation
(c) in type checking
(d) including load file
Ans. (c)

 30.Piggy backing is a technique for


a) Flow control
b) Sequence
c) Acknowledgement
d) retransmition
Ans. (c)

Page 7 of 66
HCL – TECHNICAL MCQ

31.In signed magnitude notation what is the minimum value that can be represented with 8 bits
(a) -128
(b) -255
(c) -127
(d) 0
 32.There is an employer table with key fields as employer number data in every n'th row are needed for a
simple following queries will get required results.
(a) select A employee number from employee A , where exists from employee B where A employee no. >= B
employee having (count(*) mod n)=0
(b) select employee number from employe A, employe B where A employe number>=B employ number
group by employee number having(count(*) mod n=0 )
(c) both (a) & (b)
(d) none of the above
 
33.Type duplicates of a row in a table customer with non uniform key field customer number you can see
a) delete from costomer where customer number exists( select distinct customer number from customer
having count )
b) delete customer a where customer number in b rowid
c) delete customer a where custermor number in( select customer number from customer a, customer b
d) none of the above
 
34. How many segment registers are there in the 8086 processor?
a) 4
b) 6
c) 8
d) none
Ans: a
35. Data recovery is done in which layer?
a) physical
b) datalink
c) network
d) transport

36. Given the following statement enum day = { jan = 1 ,feb=4, april, may}What is the value of may?
(a) 4
(b) 5
(c) 6
(d) 11

Page 8 of 66
HCL – TECHNICAL MCQ

(e) None of the above

37. Find the output for the following C program


main()
{int x,j,k;
j=k=6;x=2;
x=j*k;
printf("%d", x);

38. Find the output for the following C program fn f(x)


{
if(x<=0)
return;
else f(x-1)+x;
}

39 Find the output for the following C program


i=20,k=0;
for(j=1;j<i;j=1+4*(i/j))
{k+=j<10?4:3;
}
printf("%d", k);
Ans. k=4

40. Find the output for the following C program


int i =10
main()
{
int i =20,n;
for(n=0;n<=i;)
{
int i=10;
i++;
}
printf("%d", i);
Ans. i=20

41. Find the output for the following C program

Page 9 of 66
HCL – TECHNICAL MCQ

Y=10;
if( Y++>9 && Y++!=10 && Y++>10)
{printf("%d", Y);
else
printf("%d", Y);
}
Ans. 13

42. What is the sizeof(long int)


(a) 4 bytes
(b) 2 bytes
(c) compiler dependent
(d) 8 bytes
43.Which of the function operator cannot be over loaded
(a) <=
(b) ?:
(c) =
(d) *
44. Find the output for the following C program
main()
{intx=2,y=6,z=6;
x=y==z;
printf(%d",x)
}
 
45 .find the output
 main()
{
printf("%d%d"size of ("Hcl
technologies"),strlen("HCL Technologies"));
}
a)16 16
b)16 17
c)17 17
d)17 16

46. find the output


 main()

Page 10 of 66
HCL – TECHNICAL MCQ

{ char arr[]={ '


a','b','\n',....}
some more instructions;
}
ANS:77
 
47) find the output
 main()
{ int arr[]={0,1,2,3,4)
int *a={arr, arr+1,arr+2,...}
int **p=a;
p++;
some instructions:
}
 
48. find the output
 void main()
{
int i=5;
printf("%d",i++ + ++i);
}
a) 11
b) 12
c) 10
d) output cant be predicted
Ans: d

49. find the output


main( )
{
int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1);
}
a) 100, 100, 100, 2
b) 101,101,101,2
c) 114,104,102,3
d) none
 

Page 11 of 66
HCL – TECHNICAL MCQ

50. find the output


 main( )
{
static int a[ ] = {0,1,2,3,4};
int *p[ ] = {a,a+1,a+2,a+3,a+4};
int **ptr = p;
ptr++;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
*ptr++;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
*++ptr;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
++*ptr;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
}
Ans :     
111
222
333
344

 51. Answer the questions based on the following program


STRUCT DOUBLELIST
{
 DOUBLE CLINKED
INT DET; LIST VOID
STRUCT PREVIOUS; (BE GIVEN AND A PROCEDURE TO DELETE)
STRUCT NEW; (AN ELEMENT WILL BE GIVEN)
}
DELETE(STRUCT NODE)
{NODE-PREV-NEXT NODE-NEXT;
NODE-NEXT-PREV NODE-PREV;
IF(NODE==HEAD)
NODE
}

52. In what case the prev was


(a) All cases

Page 12 of 66
HCL – TECHNICAL MCQ

(b) It does not work for the last element


(c) It does not for the first element
(d) None of these
 
53.Answer the questions based on the following program
VOID FUNCTION(INT KK)
{KK+=20;
}
VOID FUNCTION (INT K)
INT MM,N=&M
KN = K
KN+-=10;
}
 
 54. What is the output of the following program
main()
{ int var=25,varp;
varp=&var;
varp p = 10;
fnc(varp)
printf("%d%d,var,varp);
}
(a) 20,55
(b) 35,35
(c) 25,25
(d)55,55
 
 
 
55. Here is the structure declaration of a doubly linked list
struct dlink
{
int nodeid;
struct dlink *next;
struct dlink *prev;
}dlink_t;
56. A pointer of the head of the linked list is maintained as a global variable, whose definition is
dlink_t *head; The funt remove_element(dlink_t *rp),needs to remove the node pointed to the

Page 13 of 66
HCL – TECHNICAL MCQ

rp and adjust the head. The first node's prev and the last node's next are NULL.
remove_element(dlink_t *rp)
{
rp->prev->next = rp->next;
rp->next->prev = rp->prev;
if( head == rp)
head = rp->next;
}

57. Which of the following statement is true about the fution remove_element
a) It work when head is the same as rp
b) It does not work when rp is the last element on the list
c) It sets the head of the list correctly
d) It works in all cases
Answer :B

 58. Consider the following function written in c:


#define NULL 0
char *
index(sp,c)
register char *sp,c;
{
do
{
if(*sp == c)
return (sp);
}while (*sp++);
return NULL;
}

59. The first argument sp, is a pointer to a C string. The second argument, c, is a character. This
function scarches for the character c, in the string. If it is found a pointer to that location is
returned else NULL is returned. This function works
a) Always
b) Always, but fails when the first byte contais the character c
c) works when c is a non NULL character only
d) Works only when the character c is found in the string
ans: a

Page 14 of 66
HCL – TECHNICAL MCQ

 
60. What is printed when this program is executed
main()
{
printf ("%d\n",f(7));
}
f(X)
{
if ( <= 4)
return x;
return f(--x);
}
a) 4      b) 5     c) 6     d) 7
ans: a

61. On a machine where pointers are 4 bytes long, what happens when the following code is executed.
main()
{
int x=0,*p=0;
x++; p++;
printf ("%d and %d\n",x,p);
}
a) 1 and 1 is printed
b) 1 and 4 is printed
c) 4 and 4 is printed
d) causes an exception

62. Which of the following is the correct code for strcpy, that is used to copy the contents from src to dest?
a) strcpy (char *dst,char *src)
{
while (*src)
*dst++ = *src++;
}
 
b) strcpy (char *dst,char *src)
{
while(*dst++ = *src++ )
}

Page 15 of 66
HCL – TECHNICAL MCQ

 
c) strcpy (char *dst,char *src)
{
while(*src)
{
*dst = *src;
dst++; src++;
}
}
 
d) strcpy(char *dst, char *src)
{
while(*++dst = *++src);
}
ans:b

63. Consider the following program


main()
{
int i=20,*j=&i;
*j+=10;
f1(j);

f2(j);
printf("%d and %d",i,*j);
}
f1(k)
int *k;
{
*k +=15;
}
f2(x)
int *x;
{
int m=*x,*n=&m;
*n += 10;
}
64. The values printed by the program will be

Page 16 of 66
HCL – TECHNICAL MCQ

a) 20 and 55
b) 20 and 45
c) 45 and 45
d) 45 and 55
e) 35 and 35

65. what is printed when the following program is compiled and executed?
int
func (int x)
{
if (x<=0)
return(1);
return func(x -1) +x;
}
main()
{
printf("%d\n",func(5));
}
a) 12    b) 16  c) 15 d) 11
 
66. Consider the following of c code in two files which will be linked together and executed .
a.c: int i;
main()
{
i = 30;
f1();
printf("%d\n",i)
}
b.c: static int f1()
{
i+=10;
}
 which of the following is true ?
a) a.c will fail in compilation phase because f1() is not declared
b) b.c will fail in compilation because the variable i is not declared
c) will print 30
d) will print 40
e) a & b

Page 17 of 66
HCL – TECHNICAL MCQ

67. What details should never be found in the top level of a top-down design?
(a) Details
(b) Coding
(c) Decisions
(d) None of the above
Ans. (c)
 
68. In an absolute loading scheme, which loader function is accomplished by assembler
(a) Reallocation
(b) Allocation
(c) Linking
(d) Both (a) and (b)
Ans. (d)
 
69. Banker's algorithm for resource allocation deals with
(a) Deadlock prevention
(b) Deadlock avoidance
(c) Deadlock recovery
(d) None of these
Ans. (b)
 
 
70. Thrashing can be avoided if
(a) The pages, belonging to the working set of the programs, are in main memory
(b) The speed of CPU is increased
(c) The speed of I/O processor are increased
(d) All of the above
Ans. (a)
 
71. Which of the following communications lines is best suited to interactive processing applications?
(a) Narrowband channels
(b) Simplex channels
 (c) Full-duplex channels
(d) Mixed band channels
Ans. (b)
 
72. A feasibility document should contain all of the following except

Page 18 of 66
HCL – TECHNICAL MCQ

(a) Project name


(b) Problem descriptions
(c) Feasible alternative
(d) Data flow diagrams
Ans. (d)
 
73. What is the main function of a data link content monitor?
(a) To detect problems in protocols
(b) To determine the type of transmission used in a data link
(c) To determine the type of switching used in a data link
(d) To determine the flow of data
Ans. (a)
 
74. Which of the following is a broadband communications channel?
(a) Coaxial cable
(b) Fiber optic cable
(c) Microwave circuits
(d) All of the above
Ans. (d)
 
75. Which of the following memories has the shortest access time?
(a) Cache memory
(b) Magnetic bubble memory
(c) Magnetic core memory
(d) RAM
Ans. (a)
 
76. A shift register can be used for
(a) Parallel to serial conversion
(b) Serial to parallel conversion
(c) Digital delay line
(d) All the above
Ans. (d)
 
77. In which of the following page replacement policies, Balady's anomaly occurs?
(a) FIFO
(b) LRU
(c) LFU

Page 19 of 66
HCL – TECHNICAL MCQ

(d) NRU
Ans. (a)
 
78. Subschema can be used to
(a) Create very different, personalised views of the same data
(b) Present information in different formats
(c) Hide sensitive information by omitting fields from the sub-schema's description
(d) All of the above
Ans. (d)
 
79. A 12 address lines maps to the memory of
a. 1k bytes
b. 0.5k bytes
c. 2k bytes
d. none
Ans: b
 
80. In a processor these are 120 instructions . Bits needed to implement this instructions
[a] 6
[b] 7
[c] 10
[d] none
Ans: b
 
81. In a compiler there is 36 bit for a word and to store a character 8bits are needed. IN this to store a
character two words are appended .Then for storing a K characters string, How many words are
needed.
[a] 2k/9
[b] (2k+8/9
[c] (k+8/9
[d] 2*(k+8/9
[e] none
Ans: a
 
C LANGUAGE
 
82. Identify which of the following are declarations
1 : extern int x;
2 : float square ( float x ){... }

Page 20 of 66
HCL – TECHNICAL MCQ

3 : double pow(double, double);


A. 1    
B. 2
C. 1 and 3      
D. 3
 
83.  What will be the output of the program If the integer is 4bytes long?
#include<stdio.h>
int main()
{
    int ***r, **q, *p, i=8;
    p = &i;
    q = &p;
    r = &q;
    printf("%d, %d, %d\n", *p, **q, ***r);
    return 0;
}
 
A. 8, 8, 8        
B. 4000, 4002, 4004
C. 4000, 4004, 4008  
D. 4000, 4008, 40163.
 
84. What function should be used to free the memory allocated by calloc() ?
A. dealloc();   
B. malloc(variable_name, 0)
C. free();         
D. memalloc(variable_name, 0)
 
85. Point out the error in the program
#include<stdio.h>
int main()
{
    int a=10;
    void f();
    a = f();
    printf("%d\n", a);
    return 0;

Page 21 of 66
HCL – TECHNICAL MCQ

}
void f()
{
    printf("Hi");
}
 
A. Error: Not allowed assignment
B. Error: Doesn't print anything
C. No error
D. None of above
 
86. What does the following declaration mean?
int (*ptr)[10];
A. ptr is array of pointers to 10 integers
B. ptr is a pointer to an array of 10 integers
C. ptr is an array of 10 integers
D. ptr is an pointer to array
 
87.  Point out the error in the program?
typedef struct data mystruct;
struct data
{
    int x;
    mystruct *b;
};
 
A. Error: in structure declaration
B. Linker Error
C. No Error
D. None of above
 
88. In the following code what is 'P'?
typedef char *charp;
const charp P;
 
A. P is a constant       
B. P is a character constant
C. P is character type 

Page 22 of 66
HCL – TECHNICAL MCQ

D. None of above
Ans: A

 
89. Which of the following is the correct usage of conditional operators used in C?
A. a>b ? c=30 : c=40;
B. a>b ? c=30;
C. max = a>b ? a>c?a:c:b>c?b:c        
D. return (a>b)?(a:b)
Ans: C

 
90. What will be the output of the program ?
#include<stdio.h>
int main()
{
    char p[] = "%d\n";
    p[1] = 'c';
    printf(p, 65);
    return 0;
}
 
A. A   
B.a
C. c     
D. 65
 
91. What will be the output of the program (myprog.c) given below if it is executed from the command line?
cmd> myprog one two three
 
/* myprog.c */
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char **argv)
{
    printf("%s\n", *++argv);
    return 0;
}

Page 23 of 66
HCL – TECHNICAL MCQ

 
A. myprog      
B. one
C. two
D. three
Ans-B

 
92.  The comma operator (,) is primarily used in conjunction with
A. 'for' statement
B. 'if-else' statement
C. 'do-while' statement
D.All of the above
E. None of the above
 
93.  To execute a C++ program, you first need to translate the source code into object code. This process is
called
A. coding       
B. compiling
C. sourcing     
D. translating
 
94.  The rules of a programming language are called its _____
A. code          
B. guidelines
C. procedures 
D. regulations
E. syntax
 
95.  An array element is accessed using
A. a first-in-first-out approach
B. the dot operator
C. a member name
D. an index number
 
96.  The program can access the private members of a class
A. directly
B. only through other private members of the class

Page 24 of 66
HCL – TECHNICAL MCQ

C. only through other public members of the class


D. None of the above - the program cannot access the private members of a class in any way
 
 
 
 
STRUCTURES IN C  & JAVA
 
97.         class A
{
    A( ){}
}
 
class B extends A
{}
Which statement is true?
A. Class B'S constructor is public.
B. Class B'S constructor has no arguments.
C. Class B'S constructor includes a call to this( ).
D. None of these.
Answer:  B
 
98.         interface DoMath
{
 double getArea(int rad);
}
interface MathPlus
{
    double getVol(int b, int h);
}
/* Missing Statements ? */
which two code fragments inserted at end of the program, will allow to compile?
   1. class AllMath extends DoMath { double getArea(int r); }
   2. interface AllMath implements MathPlus { double getVol(int x, int y); }
   3. interface AllMath extends DoMath { float getAvg(int h, int l); }
   4. class AllMath implements MathPlus { double getArea(int rad); }
   5. abstract class AllMath implements DoMath, MathPlus { public double getArea(int rad){return rad * rad
* 3.14; }}

Page 25 of 66
HCL – TECHNICAL MCQ

A. 1 only        
B. 2 only
C. 3 and 5      
D. 1 and 4
Answer: C
 
99.  Which two statements are true for any concrete class implementing the java.lang.Runnable interface?
   1. You can extend the Runnable interface as long as you override the public run() method.
   2. The class must contain a method called run() from which all code for that thread will be initiated.
   3. The class must contain an empty public void method named run().
   4. The class must contain a public void method named runnable().
   5. The class definition must include the words implements Threads and contain a method called run().
   6. The mandatory method must be public, with a return type of void, must be called run(),and cannot take
any arguments.
A. 1 and 3      
B. 2 and 4
C. 1 and 5      
D. 2 and 6
Answer:  D
 
 
100.         /* Missing statements ? */
public class NewTreeSet extends java.util.TreeSet
{
    public static void main(String [] args)
    {
        java.util.TreeSet t = new java.util.TreeSet();
        t.clear();
    }
    public void clear()
    {
        TreeMap m = new TreeMap();
        m.clear();
    }
}
which two statements, added independently at beginning of the program, allow the code to compile?
    1. No statement is required
   2. import java.util.*;

Page 26 of 66
HCL – TECHNICAL MCQ

   3. import.java.util.Tree*;
   4. import java.util.TreeSet;
   5. import java.util.TreeMap;
A. 1 only        
B. 2 and 5
C. 3 and 4      
D. 3 and 4
Answer:  B
 
101.  Which three statements are true?
   1. The default constructor initialises method variables.
   2. The default constructor has the same access as its class.
   3. The default constructor invokes the no-arg constructor of the superclass.
   4. If a class lacks a no-arg constructor, the compiler always creates a default constructor.
   5. The compiler creates a default constructor only when there are no other constructors for the class.
A. 1, 2 and 4  
B. 2, 3 and 5
C. 3, 4 and 5  
D. 1, 2 and 3
Answer:  B
 
102.  What will be the output of the program?
public class Foo

    public static void main(String[] args)
    {
        try
        {
            return;
        }
        finally
        { The default constructor invokes the no-arg constructor of the superclass.
        }
    }
}
A. Finally
B. Compilation fails.
C. The code runs with no output.

Page 27 of 66
HCL – TECHNICAL MCQ

D. An exception is thrown at runtime.


Answer:  A
 
103.  What will be the output of the program?
try
{
    int x = 0;
    int y = 5 / x;
}
catch (Exception e)
{
    System.out.println("Exception");
}
catch (ArithmeticException ae)
{
    System.out.println(" Arithmetic Exception");
}
System.out.println("finished");
A. finished     
B. Exception
C. Compilation fails.  
D. Arithmetic Exception
Answer:  C
 
104.  What will be the output of the program?
public class X

    public static void main(String [] args)
    {
        try
        {
            badMethod(); 
            System.out.print("A");
        } 
        catch (Exception ex)
        {
            System.out.print("B"); 
        }

Page 28 of 66
HCL – TECHNICAL MCQ

        finally
        {
            System.out.print("C");
        }
        System.out.print("D");
    } 
    public static void badMethod()
    {
        throw new Error(); /* Line 22 */
    }
}
A. ABCD
B. Compilation fails.
C. C is printed before exiting with an error message.
D. BC is printed before exiting with an error message.
Answer: C
 
105.  What will be the output of the program?
public class X

    public static void main(String [] args)
    {
        try
        {
            badMethod(); 
            System.out.print("A"); 
        }
        catch (RuntimeException ex) /* Line 10 */
        {
            System.out.print("B");
        }
        catch (Exception ex1)
        {
            System.out.print("C");
        }
        finally
        {
            System.out.print("D");

Page 29 of 66
HCL – TECHNICAL MCQ

        }
        System.out.print("E");
    }
    public static void badMethod()
    {
        throw new RuntimeException();
    }
}
A. BD
B. BCD
C. BDE          
D. BCDE
Answer:  C
 
106.  What will be the output of the program?
public class RTExcept
{
    public static void throwit ()
    {
        System.out.print("throwit ");
        throw new RuntimeException();
    }
    public static void main(String [] args)
    {
        try
        {
            System.out.print("hello ");
            throwit();
        }
        catch (Exception re )
        {
            System.out.print("caught ");
        }
        finally
        {
            System.out.print("finally ");
        }
        System.out.println("after ");

Page 30 of 66
HCL – TECHNICAL MCQ

    }
}
A. hello throwit caught
B. Compilation fails
C. hello throwit Runtime Exception caught after
D. hello throwit caught finally after
Answer:  D
 

107.         8. Surgeons can perform delicate operations by manipulating devices through computers instead
of manually. This technology is known as:
A. robotics.
B. computer forensics.
C. simulation.
D. forecasting.
Answer: A
 
108.         Technology no longer protected by copyright, available to everyone, is considered to be:
A. proprietary.
B. open.
C. experimental.
D. in the public domain.
Answer: A
 
109.         ____________ is the study of molecules and structures whose size ranges from 1 to 100 nanometers.
A. Nanoscience
B. Microelectrodes
C. Computer forensics
D. Artificial intelligence
Answer: A
 
110.         ____________ is the science that attempts to produce machines that display the same type of
intelligence that humans do.
A. Nanoscience
B. Nanotechnology
C. Simulation
D. Artificial intelligence (AI)
Answer: D
 

Page 31 of 66
HCL – TECHNICAL MCQ

111.         ____________ is data that has been organized or presented in a meaningful fashion.
A. A process
B. Software
C. Storage
D. Information
Answer: D
 
112.         The name for the way that computers manipulate data into information is called:
A. programming.
B. processing.
C. storing.
D. organizing.
Answer: B
 
113.         Computers gather data, which means that they allow users to ____________ data.
A. present
B. input
C. output
D. store
Answer: B
 
114.         After a picture has been taken with a digital camera and processed appropriately, the actual print
of the picture is considered:
A. data.
B. output.
C. input.
D. the process.
Answer: B
 
115.         Computers use the ____________ language to process data.
A. processing
B. kilobyte
C. binary
D. representational
Answer: C
 
116.       Computers process data into information by working exclusively with:
A. multimedia.

Page 32 of 66
HCL – TECHNICAL MCQ

B. words.
C. characters.
D. numbers.
Answer: D
 
117.       In the binary language each letter of the alphabet, each number and each special character is made
up of a unique combination of:
A. eight bytes.
B. eight kilobytes.
C. eight characters.
D. eight bits.
Answer: D
 
118.       The term bit is short for:
A. megabyte.
B. binary language.
C. binary digit.
D. binary number.
Answer: C
 
119.       A string of eight 0s and 1s is called a:
A. megabyte.
B. byte.
C. kilobyte.
D. gigabyte.
Answer: B
 
120.       A ____________ is approximately one billion bytes.
A. kilobyte
B. bit
C. gigabyte
D. megabyte
Answer: C
 
121.       A ____________ is approximately a million bytes.
A. gigabyte
B. kilobyte
C. megabyte

Page 33 of 66
HCL – TECHNICAL MCQ

D. terabyte
Answer: C
 
Section#2
(A correct answer carries 1 mark  1/4 marks will be deducted for a wrong answer.)
 
122.         Is there any difference between following declarations?
1 : extern int fun();
2 : int fun();
A. Both are identical
B. No difference, except extern int fun(); is probably in another file
C. int fun(); is overrided with extern int fun();
D. None of these
 
123.         Which of the following special symbol allowed in a variable name?
A. * (asterisk) 
B. | (pipeline)
C. - (hyphen)  
D. _ (underscore)
Ans-D

 
124.         Point out the error in the following program.
#include<stdio.h>
struct emp
{
   char name[20];
    int age;
};
int main()
{
    emp int xx;
    int a;
    printf("%d\n", &a);
    return 0;
}
 
A. Error: in printf       

Page 34 of 66
HCL – TECHNICAL MCQ

B. Error: in emp int xx;


C. No error.    
D. None of these.
 
125.We want to round off x, a float, to an int value, The correct way to do is
A. y = (int)(x + 0.5)   
B. y = int(x + 0.5)
C. y = (int)x + 0.5      
D. y = (int)((int)x + 0.5)
 
126.         The binary equivalent of 5.375 is
A. 101.101110111     
B. 101.011
C. 101011      
D. None of above
 
127.         A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then
when this float is stored in memory in which of the following order do these bytes gets stored?
A. ABCD
B. DCBA
C. 0xABCD
D. Depends on big endian or little endian architecture
 
128.         How many times the program will print "FRESHERSWORLD" ?
#include<stdio.h>
int main()
{
    printf("FRESHERSWORLD");
    main();
    return 0;
}
 
A. Infinite times         
B. 32767 times
C. 65535 times           
D. Till stack doesn't overflow
 
129.         In which stage the following code

Page 35 of 66
HCL – TECHNICAL MCQ

#include<stdio.h>
gets replaced by the contents of the file stdio.h
A. During editing       
B. During linking
C. During execution   
D. During pre-processing
Ans-D
 
130.         If the file to be included doesn't exist, the preprocessor flashes an error message.
A. True            B. False
 
 
131.       Specify the 2 library functions to dynamically allocate memory?
A. malloc() and memalloc()
B. alloc() and memalloc()
C. malloc() and calloc()
D. memalloc() and faralloc()
 
132.       The keyword used to transfer control from a function back to the calling function is
A. switch        
B. goto
C. go back      
D. return         
 
133.       In a file contains the line "I am a boy\r\n" then on reading this line into the array str using fgets().
What will str contain?
A. "I am a boy\r\n\0"  
B. "I am a boy\r\0"
C. "I am a boy\n\0"    
D. "I am a boy"
 
134.       Which of the following operations can be performed on the file "NOTES.TXT" using the below code?
FILE *fp;
fp = fopen("NOTES.TXT", "r+");
 
A. Reading     
B. Writing
C. Appending

Page 36 of 66
HCL – TECHNICAL MCQ

D. Read and Write


 
135.       What is the purpose of "rb" in fopen() function used below in the code?
FILE *fp;
fp = fopen("source.txt", "rb");
 
A. open "source.txt" in binary mode for reading
B. open "source.txt" in binary mode for reading and writing
C. Create a new file "source.txt" for reading and writing
D. None of above
 
Section#3
(A correct answer carries 2 marks  1 mark will be deducted for a wrong answer.)
 
136.         Can you combine the following two statements into one?
 
char *p;
p = (char*) malloc(100);
 
A. char p = *malloc(100);
B. char *p = (char) malloc(100);
C. char *p = (char*)malloc(100);
D. char *p = (char *)(malloc*)(100);
 
137.         What will be the output of the program ?
 
#include<stdio.h>
int main()
{
    int i=3, *j, k;
    j = &i;
    printf("%d\n", i**j*i+*j);
    return 0;
}
 
A. 30  
B. 27
C. 9    

Page 37 of 66
HCL – TECHNICAL MCQ

D. 3
 
138.         Point out the compile time error in the program given below.
 
#include<stdio.h>
 
int main()
{
    int *x;
    *x=100;
    return 0;
}
 
A. Error: invalid assignment for x
B. Error: suspicious pointer conversion
C. No error
D. None of above
Ans: C

 
139.         Which of the following statements correct about k used in the below statement?
char ****k;
A. k is a pointer to a pointer to a pointer to a char
B. k is a pointer to a pointer to a pointer to a pointer to a char
C. k is a pointer to a char pointer
D. k is a pointer to a pointer to a char
 
140.         What is the similarity between a structure, union and enumeration?
A. All of them let you define new values
B. All of them let you define new data types
C. All of them let you define new pointers
D. All of them let you define new structures
Ans: B

 
141.         What will be the output of the program ?
 
#include<stdio.h>

Page 38 of 66
HCL – TECHNICAL MCQ

int main()
{
    enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
    printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT);
    return 0;
}
 
A. -1, 0, 1, 2, 3, 4       
B. -1, 2, 6, 3, 4, 5
C. -1, 0, 6, 2, 3, 4       
D. -1, 0, 6, 7, 8, 9
Ans-D

 
142.         Which of the following code fragments inserted, will allow to compile?
 
A. new Inner(); //At line 5
B. new Inner(); //At line 10
C. new ot.Inner(); //At line 10
D. new Outer.Inner(); //At line 10ct data
 
143.         Which of the following statements correct about the below code?
maruti.engine.bolts=25;
A. Structure bolts is nested within structure engine.
B. Structure engine is nested within structure maruti.
C. Structure maruti is nested within structure engine.
D. Structure maruti is nested within structure bolts.
 
144.         public void test(int x)
{
    int odd = 1;
    if(odd) /* Line 4 */
    {
        System.out.println("odd");
    }
    else
    {
        System.out.println("even");

Page 39 of 66
HCL – TECHNICAL MCQ

    }
}
 
Which statement is true?
 
A. Compilation fails.
B. "odd" will always be output.
C. "even" will always be output.
D. "odd" will be output for odd values of x, and "even" for even values
 
145.       public class Outer
{
    public void someOuterMethod()
    {
        //Line 5
    }
    public class Inner { }
    public static void main(String[] argv)
    {
        Outer ot = new Outer();
        //Line 10
    }
}
 
Which of the following code fragments inserted, will allow to compile?
 
A. new Inner(); //At line 5
B. new Inner(); //At line 10
C. new ot.Inner(); //At line 10
D. new Outer.Inner(); //At line 10
 

 
 
146. You want to find out the value of the last element of an array. You write the following code. What will
happen when you compile and run it.?
public class MyAr{
public static void main(String argv[]){

Page 40 of 66
HCL – TECHNICAL MCQ

int[] i = new int[5];


System.out.println(i[5]);
}
}
A. An error at compile time
B. An error at run time
C. The value 0 will be output
D. The string "null" will be output.
 
147. What do the following declaration signify?
int *ptr[30];
A.        ptr is a pointer to an array of 30 integer pointers.
B.        ptr is a array of 30 pointers to integers.
C.        ptr is a array of 30 integer pointers.
D.        ptr is a array 30 pointers.
Ans-B
 
148. What is the hidden bug with the following  statement?
                        assert(val++ != 0);
 
149. Is the following code legal?
void main()
{
typedef struct a aType;
aType someVariable;
struct a
{
int x;
      aType *b;
              };
}
Ans-no
 
150. Find the output.
            main()
       {         
       char a[4]="HELL";
       printf("%s",a);

Page 41 of 66
HCL – TECHNICAL MCQ

       }
Ans- HELL%@!~@!@???@~~!
 
151. What is the difference between a string copy (strcpy) and a memory copy (memcpy)?
 
152. What is a pointer value and address?
 
153. What are the advantages of inheritance?
 
154. What are the advantages of using array of pointers to string instead of an array of strings?
 
155. What is pointer to a pointer?
 
156. What are built in functions?
 
157. What are the pointer declarations used in C?
 
158. What will be the output of the program?
#include<stdio.h>
typedef void v;
typedef int i;
 
int main()
{
    v fun(i, i);
    fun(2, 3);
    return 0;
}
v fun(i a, i b)
{
    i s=2;
    float i;
    printf("%d,", sizeof(i));
    printf(" %d", a*b*s);
}
A.   2, 8          
B.   4, 8
C.   2, 4          

Page 42 of 66
HCL – TECHNICAL MCQ

D.   4, 12
Ans-D
 
159. What will be the output of the program?
#include<stdio.h>
int main()
{
    const int x=5;
    const int *ptrx;
    ptrx = &x;
    *ptrx = 10;
    printf("%d\n", x);
    return 0;
}
A.   5  
B.   10
C.   Error        
D.   Garbage value
Ans-C
 
160. The maximum combined length of the command-line arguments including the spaces between
adjacent arguments is
A.   128 characters
B.   256 characters
C.   67 characters
D.   It may vary from one operating system to another
Ans-D
 
 
161. What will be the output of the program
#include<stdio.h>
void fun(int);
int main(int argc)
{
    printf("%d\n", argc);
    fun(argc);
    return 0;
}

Page 43 of 66
HCL – TECHNICAL MCQ

void fun(int i)
{
    if(i!=4)
        main(++i);
}
A.        1 2 3   
B.        1 2 3 4
C.        2 3 4   
D.        1
Ans-B
 
162. Which of the following function is correct that finds the length of a string?
 
A.
int xstrlen(char *s)
{
    int length=0;
    while(*s!='\0')
    {    length++; s++; }
    return (length);
}
 
B.
int xstrlen(char s)
{
    int length=0;
    while(*s!='\0')
        length++; s++;
    return (length);
}
 
C.
int xstrlen(char *s)
{
    int length=0;
    while(*s!='\0')
        length++;
    return (length);

Page 44 of 66
HCL – TECHNICAL MCQ

}
 
D.
int xstrlen(char *s)
{
    int length=0;
    while(*s!='\0')
        s++;
    return (length);
}
 
Ans-A
 
163. Which of the following function is more appropriate for reading in a multi-word string?
A.        printf();           
B.        scanf();
C.        gets(); 
D.        puts();
Ans-C
 
164. What is the notation for following functions?
1.  int f(int a, float b)
    {
        /* Some code */
    }
 
2.  int f(a, b)
    int a; float b;
    {
        /* Some code */
    }
A.        1. KR Notation
            2. ANSI Notation      
B.        1. Pre ANSI C Notation
            2. KR Notation
C.        1. ANSI Notation
            2. KR Notation          
D.        1. ANSI Notation

Page 45 of 66
HCL – TECHNICAL MCQ

            2. Pre ANSI Notation


Ans-C
 
165. Which bitwise operator is suitable for turning on a particular bit in a number?
A.        && operator   
B.        & operator
C.        || operator       
D.        | operator
Ans-D
 
166. Assuming a integer 2-bytes, What will be the output of the program?
#include<stdio.h>
int main()
{
    printf("%x\n", -1<<3);
    return 0;
}
Ans-B

167.A decorator bought a bolt of d m number of red chips in any one stack ?
(A) 7                      (B) 6            (C) 5                  (D) 4                    (E) 3
Ans :C

 
168.
main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above
Ans: b

169.
main()
{

Page 46 of 66
HCL – TECHNICAL MCQ

int i;
float *pf;
pf = (float *)&i;
*pf = 100.00;
printf("\n %d", i);
}
a. Runtime error.
b. 100
c. Some Integer not 100
d. None of the above
 
Ans: d
 

170.The binary equivalent of the Hexadecimal number 7BD is


A. 11110111101
B. 111010111101
C. 101110111101
D. All of the above
E. None of the above
Answer: A
 
171.  Which of the following is non-impact printer?
A. Drum printer
B. Line printer
C. Chain printer
D. Laser printer
E. None of the above
Answer: D
 
172.  In which year was the PC voted 'The Machine of the Year's by the American Time magazine?
A. 1970
B. 1975
C. 1983
D. 1987
E. None of the above
Answer: C
 

Page 47 of 66
HCL – TECHNICAL MCQ

173.  When used with I/O devices, the term intelligent implies
A. a color output capability
B. speech processing capability
C. high speed printing capability
D. feature to support offline and online tasks
E. None of the above
Answer: D
 
174.  A prefix for billion which is equal to _____ is called as billi.
A. 100
B. 10000
C. 1000
D. 10
E. None of the above
Answer: D
 
175. The operation of a digital computer is based on _____ principle.
A. counting
B. measuring
C. electronic
D. logical
E. None of the above
Answer: A
 
176.  Which of the following Indian companies designs and manufactures super- computers?
A. C-DOT
B. C-DAC
C. CMC
D. All of the above
E. None of the above
Answer: B
 
177.  Which of the following memories needs refresh?
A. SRAM
B. DRAM
C. ROM
D. All of the above
E. None of the above

Page 48 of 66
HCL – TECHNICAL MCQ

Answer:  B
 
178.  Which of the following is not a sequence storage device?
A. Magnetic disk
B. Magnetic tape
C. Paper tape
D. All of the above
E. None of the above
Answer: A
 
179.  The computers that we use are digital whereas we live in an analog world which means that we have
to translate analog data into digital data. What is the name of the circuit which helps us in this
conversion?
A. D/A converter
B. A/D converter
C. Voice recognition
D. Adapter
E. None of the above
Answer: B
           
 
180. Which of the following statements best describes the batch method of input?
A. Data is processed as soon as it is input
B. Data is input at the time it is collected
C. Data is collected in the form of source documents, placed into groups, and then input to the computer
D. Source documents aren't used
E. None of the above
Answer: C
 
181.  What is the name of the memory card which is conceptually related to the smart card but is similar to
the video disk?
A. Laser card
B. Master card
C. Visa
D. Optical card
E. None of the above
Answer: A
 

Page 49 of 66
HCL – TECHNICAL MCQ

182.  In 1830, Charles Babbage disigned a machine called the Analytical Engine which he showed at the
Paris Exhibition. In which year was it exhibited?
A. 1820
B. 1860
C. . 1855
D. 1870
E. None of the above
Answer: C
 
183.  Which of the following is used to check for errors in RAM chips?
A. ROM chip
B. Microprocessor chip
C. Parity chip
D. EPROM chip
E. None of the above
Answer: C
 
184.  Which of the following is not an alternative name for primary memory?
A. Main memory
B. Primary storage
C. Internal storage
D. Mass storage
E. None of the above
Answer: D
 
SECTION#2
 
 
 
185. Which of the following statement obtains the remainder on dividing 5.5 by 1.3 ?
A. rem = (5.5 % 1.3)  
B. rem = modf(5.5, 1.3)
C. rem = fmod(5.5, 1.3)         
D. Error: we can't divide
Ans: C
 
186. What will be the output of the program?
#include<stdio.h>

Page 50 of 66
HCL – TECHNICAL MCQ

int main()
{
    char c=48;
    int i, mask=01;
    for(i=1; i<=5; i++)
    {
        printf("%c", c|mask);
        mask = mask<<1;
    }
    return 0;
}
A. 12400        
B. 12480
C. 12500        
D. 12556
Ans: B
 
187. Point out the error in the following program.
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *a[3];
    a = (int*) malloc(sizeof(int)*3);
    free(a);
    return 0;
}
 
A. Error: unable to allocate memory
B. Error: We cannot store address of allocated memory in a
C. Error: unable to free memory
D. No error
Ans: B
 
188. What is the purpose of fflush() function.
A. flushes all streams and specified streams.
B. flushes only specified stream.
C. flushes input/output buffer.

Page 51 of 66
HCL – TECHNICAL MCQ

D. flushes file buffer.


Ans; A
 
189. Point out the error, if any in the program.
#include<stdio.h>
int main()
{
    int a = 10;
    switch(a)
    {
    }
    printf("This is c program.");
    return 0;
}
 
A. Error: No case statement specified
B. Error: No default specified
C. No Error
D. Error: infinite loop occurs
Ans: C
 
190.  What will be the output of the program?
#include<stdio.h>
int addmult(int ii, int jj)
{
    int kk, ll;
    kk = ii + jj;
    ll = ii * jj;
    return (kk, ll);
}
 
int main()
{
    int i=3, j=4, k, l;
    k = addmult(i, j);
    l = addmult(i, j);
    printf("%d, %d\n", k, l);
    return 0;

Page 52 of 66
HCL – TECHNICAL MCQ

}
 
A. 12, 12        
B. 7, 7
C. 7, 12          
D. 12, 7
Ans: A
 
191. In C, if you pass an array as an argument to a function, what actually gets passed?
A. Value of elements in array
B. First element of the array
C. Base address of the array
D. Address of the last element of array
Ans: C
 
192. Out of fgets() and gets() which function is safe to use?
A. gets()         
B. fgets()
Ans: B
 
 
193. What is x in the following program?
#include<stdio.h>
 
int main()
{
    typedef char (*(*arrfptr[3])())[10];
    arrfptr x;
    return 0;
}
A. x is a pointer
B. x is an array of three pointer
C. x is an array of three function pointers
D. Error in x declaration
Ans : C
 
 

Page 53 of 66
HCL – TECHNICAL MCQ

194. What will the SWAP macro in the following program be expanded to on preprocessing? will the code
compile?
#include<stdio.h>
#define SWAP(a, b, c)(c t; t=a, a=b, b=t)
int main()
{
    int x=10, y=20;
    SWAP(x, y, int);
    printf("%d %d\n", x, y);
    return 0;
}
A. It compiles
B. Compiles with an warning
C. Not compile
D. Compiles and print nothing
Ans: C
 
 
195. Point out the error in the program (in Turbo-C).
#include<stdio.h>
#define MAX 128
int main()
{
    const int max=128;
    char array[max];
    char string[MAX];
    array[0] = string[0] = 'A';
    printf("%c %c\n", array[0], string[0]);
    return 0;
}
 
A. Error: unknown max in declaration/Constant expression required
B. Error: invalid array string
C. None of above
D. No error. It prints A A
Ans: A
 
SECTION#2

Page 54 of 66
HCL – TECHNICAL MCQ

 
196. A pointer is
A. A keyword used to create variables
B. A variable that stores address of an instruction
C. A variable that stores address of other variable
D. All of the above
Ans: C
 
197. What will be the output of the program assuming that the array begins at the location 1002 and size of
an integer is 4 bytes?
#include<stdio.h>
int main()
{
    int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
    printf("%u, %u, %u\n", a[0]+1, *(a[0]+1),*(*(a+0)+1));
    return 0;
}
 
A. 448, 4, 4    
B. 520, 2, 2
C. 1006, 2, 2  
D. Error
Ans; C
 
198. Which of the statements is correct about the program?
#include<stdio.h>
int main()
{
    int arr[3][3] = {1, 2, 3, 4};
    printf("%d\n", *(*(*(arr))));
    return 0;
}
 
A. Output: Garbage value      
B. Output: 1
C. Output: 3   
D. Error: Invalid indirection
Ans : D

Page 55 of 66
HCL – TECHNICAL MCQ

 
 
199. What will be the output of the program ?
#include<stdio.h>
int main()
{
    enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
    printf("%d, %d, %d, %d, %d, %d\n", ++MON, TUE, WED, THU, FRI, SAT);
    return 0;
}
 
A. -1, 0, 1, 2, 3, 4       
B. Error
C. 0, 1, 6, 3, 4, 5        
D. 0, 0, 6, 7, 8, 9
Ans: B
 
200. Point out the error in the program?
#include<stdio.h>
int main()
{
    struct bits
    {
        int i:40;
    }bit;
 
    printf("%d\n", sizeof(bit));
    return 0;
}
 
A.4
B. 2
C. Error: Bit field too large
D. Error: Invalid member access in structure
Ans: C
 
201. Which of the following statements correct about the below program?
#include<stdio.h>

Page 56 of 66
HCL – TECHNICAL MCQ

int main()
{
    union a
    {
        int i;
        char ch[2];
    };
    union a u1 = {512};
    union a u2 = {0, 2};
    return 0;
}
 
1: u2 CANNOT be initialized as shown.
2: u1 can be initialized as shown.
3: To initialize char ch[] of u2 '.' operator should be used.
4: The code causes an error 'Declaration syntax error'
 
A. 1, 2
B. 2, 3
C. 1, 2, 3        
D. 1, 3, 4
Ans : C
 
202. What will be the output of the program?
public class X
{
    public static void main(String [] args)
    {
        try
        {
            badMethod(); 
            System.out.print("A");
        } 
        catch (Exception ex)
        {
            System.out.print("B");
        } 
        finally

Page 57 of 66
HCL – TECHNICAL MCQ

        {
            System.out.print("C");
        } 
        System.out.print("D");
    } 
    public static void badMethod() {}
}
 
A. AC
B. BC
C. ACD          
D. ABCD
Ans : C
 
203 .      switch(x)
{
    default: 
        System.out.println("Hello");
}
Which two are acceptable types for x?
   1. byte
   2. long
   3. char
   4. float
   5. Short
   6. Long
 
A. 1 and 3      
B. 2 and 4
C. 3 and 5      
D. 4 and 6
Ans : A
 

204. What will be the output of the program?


#include<stdio.h>
int main()
{

Page 58 of 66
HCL – TECHNICAL MCQ

    char huge *near *far *ptr1;


    char near *far *huge *ptr2;
    char far *huge *near *ptr3;
    printf("%d, %d, %d\n", sizeof(**ptr1),sizeof(ptr2),sizeof(*ptr3));
    return 0;
}
A.        4, 4, 4 
B.        2, 2, 2
C.        2, 8, 4 
D.        2, 4, 8
Ans-A
 
205. What will be the output of the program?
 
#include<stdio.h>
#include<stdlib.h>
union employee
{
    char name[15];
    int age;
    float salary;
};
const union employee e1;
 
int main()
{
    strcpy(e1.name, "K");
    printf("%s %d %f", e1.name, e1.age, e1.salary);
    return 0;
}
A.        Error: RValue required
B.        Error: cannot convert from 'const int *' to 'int *const'
C.        Error: LValue required in strcpy
D.        No error
Ans-D
 
 

Page 59 of 66
HCL – TECHNICAL MCQ

206. What will be the output of the program (sample.c) given below if it is executed from the command
line?
cmd> sample 1 2 3
cmd> sample 2 2 3
cmd> sample 3 2 3
 
/* sample.c */
#include<stdio.h>
 
int main(int argc, char *argv[])
{
    printf("%s\n", argv[0]);
    return 0;
}
A.        sample 3 2 3   
B.        sample 1 2 3
C.        sample
D.        Error
Ans-C
 
207. How will you print \n on the screen?
A.        printf("\n");     
B.        echo "\n";
C.        printf('\n');      
D.        printf("\n");
Ans-D
 
 
208. What will be the output of the program?
#include<stdio.h>
#define SQUARE(x) x*x
int main()
{
    float s=10, u=30, t=2, a;
    a = 2*(s-u*t)/SQUARE(t);
    printf("Result = %f", a);
    return 0;
}

Page 60 of 66
HCL – TECHNICAL MCQ

A.        Result = -100.000000


B.        Result = -25.000000
C.        Result = 0.000000      
D.        Result = 100.000000
Ans-A
 
 
209. What will be the output of the program?
#include<stdio.h>
int main()
{
    int i=-3, j=2, k=0, m;
    m = ++i && ++j || ++k;
    printf("%d, %d, %d, %d\n", i, j, k, m);
    return 0;
}
A.        1, 2, 0, 1         
B.        -3, 2, 0, 1
C.        -2, 3, 0, 1        
D.        2, 3, 1, 1
Ans-C
 
210. Which of the following is the correct order if calling functions in the below code?
a = f1(23, 14) * f2(12/4) + f3();
A.        f1, f2, f3
B.        f3, f2, f1
C.        Order may vary from compiler to compiler
D.        None of above
Ans-C
 
211.  What are the types of C instructions?
 
212.  What is message passing?
 
213. What is the difference between class and structure?
 
214.  What is the term Polymorphism?
 

Page 61 of 66
HCL – TECHNICAL MCQ

215. What is friend function?


 
216. what is the difference between c & c++?
 
217. What are macros? What are its advantages and disadvantages?
 
218. What is a huge pointer?
 
219. What is the difference between linker and linkage?
 
220.  What are the advantages of using array of pointers to string instead of an array of strings?
 
 
221. If the binary equivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000,
what will be the output of the program (on Intel machine)?
#include<stdio.h>
#include<math.h>
int main()
{
    float a=5.375;
    char *p;
    int i;
    p = (char*)&a;
    for(i=0; i<=3; i++)
        printf("%02x\n", (unsigned char)p[i]);
    return 0;
}
A.        40 AC 00 00  
B.        04 CA 00 00
C.        00 00 AC 40  
D.        00 00 CA 04
Ans-C
 
222. In C, if you pass an array as an argument to a function, what actually gets passed?
A.        Value of elements in array
B.        First element of the array
C.        Base address of the array
D.        Address of the last element of array

Page 62 of 66
HCL – TECHNICAL MCQ

Ans-C
 
 
223. Point out the correct statement which correctly allocates memory dynamically for 2D array following
program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *p, i, j;
    /* Add statement here */
    for(i=0; i<3; i++)
    {
        for(j=0; j<4; j++)
        {
            p[i*4+j] = i;
            printf("%d", p[i*4+j]);
        }
    }
    return 0;
}
A.        p = (int*) malloc(3, 4);
B.        p = (int*) malloc(3*sizeof(int));
C.        p = malloc(3*4*sizeof(int));
D.        p = (int*) malloc(3*4*sizeof(int));
Ans-D

224. Find the output for the following C program


i=20,k=0;
for(j=1;j9 && Y++!=10 && Y++>10)
{printf("%d", Y);
else
printf("%d", Y);
}
 
Ans. 13
 
225. Find the output for the following C program

Page 63 of 66
HCL – TECHNICAL MCQ

f=(x>y)?x:y
a) f points to max of x and y
b) f points to min of x and y
c) Error
Ans. (a)
 

Page 64 of 66
HCL – TECHNICAL MCQ

226. What is the difference between die and exit statement.


227. How to create a os
228. Which of the following services use TCP?

1.DHCP
2.SMTP
3.HTTP
4.TFTP
5.FTP
options
A. 1 and 2
B. 2, 3 and 5
C. 1, 2 and 4
D. 1, 3 and 4
229. Which of the following options is responsible for taking files and objects from different locations and
combining them for execution?
(a)Linker (b) Loader (c) Interconnecting compiler (d) Interpreter
230. Neha wants to write a program that converts a decimal number into a binary number. Which of the
following data structures should she use to implement the same?
(a) Queue (b)Stack (c)Array
(d)Linked List
231. Which of the following options describes a tree
(a) An unconnected graph (b) A connected graph (c) A connected acyclic graph
(d)A complete graph
232. How can a call to an overloaded function be ambiguous?
(a) By misspelling the name
(b) There might be two or more functions with the same name
(c) There might be two or more functions with equally appropriate signatures
(d) None of these
234. The company wants to---cost-cutting measures before it starts to incur losses.
A. reduce
B. modify
C. moderate
D. intiate
235.............return a value, but .............never return value.
1)Function,sub routine
2)sub routine,Function
3)Procedure, Function
4)Function,Procedure

Page 65 of 66
HCL – TECHNICAL MCQ

236. In complete tree with 5 level, each node have 4 child or no child ,how many node in the tree,
A.321 B.256 C.1024 D. none
of these .

237. Write a program in JAVA which print 0 if 1 is provided as input and print 1 if 0 is provided.
Condition apply :
(i.) you can't use predefined function(like logical not).
(ii.) You can't use if-else condition.

238. Which of the following options describes a tree


(a)An unconnected graph (b) A connected graph
(c) A connected acyclic graph (d)A complete graph

239.
main()
{
int i;
clrscr();
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error.
b. Runtime error. Access violation.
c. Compile error. Illegal syntax
d. None of the above
Ans: d,

Page 66 of 66

You might also like