C++ Interview Questions
Class Questions
- What is the syntax to inherit from a class in C#?
Place a colon and then the name of the base class.
Example: class MyNewClass : MyBaseClass - Can you prevent your class from being inherited by another class?
Yes. The keyword “sealed” will prevent the class from being inherited. - Can you allow a class to be inherited, but prevent the method from being over-ridden?
Yes. Just leave the class public and make the method sealed. - What’s an abstract class?
A class that cannot be instantiated. An abstract class is a class that must be inherited and have the methods overridden. An abstract class is essentially a blueprint for a class without any implementation.
Hardware Architecture Interview Questions
- Are you familiar with the term MESI?
- Are you familiar with the term snooping?
- Describe a finite state machine that will detect three consecutive coin tosses (of one coin) that results in heads.
- In what cases do you need to double clock a signal before presenting it to a synchronous state machine?
- You have a driver that drives a long signal & connects to an input device. At the input device there is either overshoot, undershoot or signal threshold violations, what can be done to correct this problem?
Tricky C Questions
- How do you write a program which produces its own source code as its output?
- How can I find the day of the week given the date?
- Why doesn’t C have nested functions?
- What is the most efficient way to count the number of bits which are set in a value?
- How can I convert integers to binary or hexadecimal?
- How can I call a function, given its name as a string?
- How do I access command-line arguments?
- How can I return multiple values from a function?
C++ Developers Questions
- Will the following program execute?
void main()
{
void *vptr = (void *) malloc(sizeof(void));
vptr++;
} - How about this one?
void main()Will it execute or not?
{
char *cptr = 0?2000;
long *lptr = 0?2000;
cptr++;
lptr++;
printf(” %x %x”, cptr, lptr);
} - When the processor wakes up after power on, it goes to a particular memory location. What is that memory location called?
- What is the difference between Mutex and Binary semaphore?
- Write a program to set 2nd bit in a 32 bit register with memory location 0×2000?
C Questions for Hardware Engineer
- What are the total number of lines written in C/C++? What is the most complicated/valuable program written in C/C++?
- What compiler was used?
- Have you studied buses? What types?
- Have you studied pipelining? List the 5 stages of a 5 stage pipeline. Assuming 1 clock per stage, what is the latency of an instruction in a 5 stage machine? What is the throughput of this machine ?
- How many bit combinations are there in a byte?
- What is the difference between = and == in C?
- Are you familiar with VHDL and/or Verilog?