Most Important Linux Device Drivers Interview Questions
Q – 1 The major number identifies the _____ associated with the device.
a) driver
b) protocol
c) port
d) none of the mentioned
Ans- a) driver
Q – 2 The kernel identifies the driver with its:
a) module
b) major number
c) device file
d) none of the mentioned
Ans- b) major number
Q – 3 In linux kernel 2.4, we can have:
a) 256 character drivers only
b) 256 block drivers only
c) 256 character drivers and 256 block drivers at the same time
d) none of the mentioned
Ans- c) 256 character drivers and 256 block drivers at the same time
Q – 4 The connection between the device file and device driver is based on the:
a) name of device file
b) number of device file
c) both (a) and (b)
d) none of the mentioned
Ans- b) number of device file
Q – 5 Do you know what is the output of this program?
#include
#include
#include
int main()
{
char *ptr;
memcpy(ptr,”google”,11);
printf(“%sn”,ptr);
return 0;
}
a) google
b) segmentation fault
c) syntax error
d) none of the mentioned
Ans- b) segmentation fault
Q – 6 This program will allocate the memory of ___ bytes for pointer “ptr”.
#include
#include
int main()
{
int *ptr;
ptr = realloc(0,sizeof(int)*10);
return 0;
}
a) 0
b) 10
c) 40
d) none of the mentioned
Ans- c) 40
Q – 7 What is the output of this program?
#include
#include
int main()
{
char *ptr;
free(ptr);
return 0
}
a) this program will print nothing after execution
b) segmentation fault
c) Aborted (core dumped)
d) none of the mentioned
Ans- c) Aborted (core dumped)
Q – 8 Tell me what is the output of this program?
#include
#include
#include
int main()
{
char *ptr;
memcpy(ptr,”google”,11);
printf(“%sn”,ptr);
return 0;
}
a) google
b) segmentation fault
c) syntax error
d) none of the mentioned
Ans- b) segmentation fault
Q – 9 What is the output of this program?
#include
#include
#include
int main()
{
char *ptr;
ptr = (char*)malloc(sizeof(char)*11);
strcpy(ptr,”google”);
printf(“%dn”,*ptr);
return 0;
}
a) s
b) google
c) 115
d) segmentation fault
Ans- c) 115
Q – 10 Which one of the following in true about this program?
#include
#include
#include
int main()
{
char *ptr;
printf(“%pn”,ptr);
ptr = (char *)malloc(sizeof(char));
printf(“%pn”,ptr);
return 0;
}
a) this program will give segmentation fault
b) this program will print two same values
c) this program has some syntax error
d) none of the mentioned
Ans- d) none of the mentioned
Q – 11 In this program the two printed memory locations has the difference of ___ bytes.
#include
#include
int main()
{
int *ptr;
ptr = (int*)malloc(sizeof(int)*2);
printf(“%pn”,ptr);
printf(“%pn”,ptr+1);
return 0;
}
a) 1
b) 4
c) can not be determined
d) none of the mentioned
Ans- b) 4
Q – 12 What is the output of this program?
#include
#inlcude
int main()
{
int *ptr;
double *ptr;
printf(“%dn”,sizeof(ptr));
return 0;
}
a) 4
b) 8
c) the compiler will give the error
d) segmentaion fault
Ans- c) the compiler will give the error
Q – 13 What is the output of this program?
#include
#include
#include
int main()
{
int ptr;
ptr = (int)malloc(sizeof(int)*10);
return 0;
}
a) syntax error
b) segmentaion fault
c) run time error
d) none of the mentioned
Ans- d) none of the mentioned
Q – 14 Which one of the following is not true?
a) dynamic allocation of major numbers is not possible
b) major number can not be shared among drivers
c) both (a) and (b)
d) none of the mentioned
Ans- c) both (a) and (b)
Q – 15 The minor number range should be:
a) 0 to 15
b) 0 to 63
c) 0 to 255
d) none of the mentioned
Ans- c) 0 to 255
Q – 16 In we use a driver for N number of files, then we have to create ____ device files.
a) N
b) 1
c) N-1
d) none of the mentioned
Ans- a) N
Q – 17 In linux, a device driver can work without the:
a) major number
b) minor number
c) device file name
d) none of the mentioned
Ans- d) none of the mentioned
Q – 18 In linux kernel 2.1, the minor numbers were used to:
a) represent the sub-functionalitites of the driver
b) identify the driver
c) represent the device files
d) none of the mentioned
Ans- a) represnt the sub-functionalitites of the driver
Q – 19 If we use a driver for various device files, then:
a) minor number will be different for every device file
b) minor number will be same for every device file
c) minor number can not be allocated for any device file
d) none of the mentioned
Ans- a) minor number will be different for every device file