HCL Technical MCQ - 239 Questions
HCL Technical MCQ - 239 Questions
HCL Technical MCQ - 239 Questions
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
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
Page 4 of 66
HCL – TECHNICAL MCQ
}
(a)10,20 b) 20,12 c) 22,10 d)10,22 e)none
Ans:b
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
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
Page 6 of 66
HCL – TECHNICAL MCQ
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)
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
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
Page 10 of 66
HCL – TECHNICAL MCQ
Page 11 of 66
HCL – TECHNICAL MCQ
Page 12 of 66
HCL – TECHNICAL MCQ
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
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
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
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
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
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
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
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
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
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
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
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
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
Page 58 of 66
HCL – TECHNICAL MCQ
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
Page 61 of 66
HCL – TECHNICAL MCQ
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
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
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.
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