0% found this document useful (0 votes)
44 views8 pages

Sample Papers - Career Aces

The document provides sample questions and answers for C, C++, SQL, and OS topics. For C questions, examples are provided for operator precedence, pointer operations, and structure padding. C++ questions cover topics like unnamed namespaces, incomplete types, constructors, and operator overloading. SQL questions define terms like a raw in a database table and provide examples of queries. OS questions define starvation and differentiate between soft and hard real-time operating systems.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views8 pages

Sample Papers - Career Aces

The document provides sample questions and answers for C, C++, SQL, and OS topics. For C questions, examples are provided for operator precedence, pointer operations, and structure padding. C++ questions cover topics like unnamed namespaces, incomplete types, constructors, and operator overloading. SQL questions define terms like a raw in a database table and provide examples of queries. OS questions define starvation and differentiate between soft and hard real-time operating systems.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Sample papers with answer

Contents
C Questions ..................................................................................................................................... 3
CPP Questions ................................................................................................................................ 4
SQL Questions ................................................................................................................................ 7
OS Questions .................................................................................................................................. 8
C Questions
 Can we apply ++ or – for a bool?
Applying ++ to a bool value is allowed for backward compatibility, with old code that uses some typedef for
bool. Incrementing bool will always yield true regardless of the initial value. However –- is illegal.
int _tmain(int argc, _TCHAR* argv[])
{
bool a = true;
a++; //This is legal
a--; //This is illegal
return 0;
}
 What does the following expression evaluate to? 6 + 5 * 4 % 3
Because * and % have higher precedence than +, the + will evaluate last. We can rewrite our expression as 6 +
(5 * 4 % 3). * and % have the same precedence, so we have to look at the associatively to resolve them. The
associativity for * and % is left to right, so we resolve the left operator first. We can rewrite our expression like
this:
6 + ((5 * 4) % 3).
6 + ((5 * 4) % 3) = 6 + (20 % 3) = 6 + 2 = 8
 What is the output of the following program?
main()
{
char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);
printf(“%s”,p2);
}
Empty string.
 What will be printed as the result of the operation below:
main()
{
int x=5;
printf(“%d,%d,%d”,x,x<<2,x>>2);
}
5,20,1
 The following global variable is available in file1.c, who can access it?:
static int average;
All the functions in the file1.c can access the variable.
 How can I turn off structure padding?
To turn off padding or alignment use #pragma pack [n], where n can equal 1, 2, 4, 8, or 16 and indicates, in
bytes, the maximum alignment of class fields having non-class types. If n is not specified, maximum alignment
is set to the default value.
The following example illustrates the pack pragma and shows that it has no effect on class fields unless the class
itself was defined under the pragma.
Example 1:

struct S1 {
char c1; // Offset 0, 3 bytes padding
int i; // Offset 4, no padding
char c2; // Offset 8, 3 bytes padding
};// sizeof(S1)==12, alignment 4

#pragma pack 1

struct S2 {
char c1; // Offset 0, no padding
int i; // Offset 1, no padding
char c2; // Offset 5, no padding
};// sizeof(S2)==6, alignment
 How do you print the word "hello world" without using "printf" statement?
puts("Hello World\n");
fputs("Hello World\n", stdout);
 What's the difference between
const MAXSIZE = 100;
and
#define MAXSIZE 100
A preprocessor #define gives you a true compile-time constant.
In C, const gives you a run-time object which you're not supposed to try to modify; „const‟ really means „read
only‟.
 Which of these statements is false w.r.t File Functions?
i)fputs()
ii)fdopen()
iii)fgetpos()
iv)ferror()
A)ii
B)i,ii
C)iii
D)iv
ferror - is the odd one, it tests for error in a stream.
 What's wrong with the call "fopen("c:\newdir\file.dat", "r")"?
It is completely correct. Only thing that can be wrong is that we do not have; at the end, and \ has to be \\

CPP Questions
 What is unnamed namespace?
A namespace with no identifier before an opening brace produces an unnamed namespace. An unnamed
namespace is used for internal linking, instead of static keyword.
#include <iostream>
using namespace std;
namespace {
const int i = 4;
int variable;
}
int main()
{
cout << i << endl;
variable = 100;
return 0;
}
 What is an incomplete type, give an example.
An incomplete type refers to pointers in which there is non availability of the implementation of the referenced
location or it points to some location whose value is not available for modification.
int *i=0x400 // i points to address 400
*i=0; //set the value of memory location pointed by i.
Incomplete types are otherwise called uninitialized pointers.
 Anything wrong with this code?
T *p = new T[10];
delete p;
Everything is correct, only the first element of the array will be deleted, because only the first element
destructor will be called. Correct implementation is delete [] p;
 String::~String()
{
cout << " String() " << endl;
}
Assuming that all the necessary using-directives have been made, in the sample code above, which one
of the following statements pertaining to the destructor is TRUE?
1) The destructor should be ~String::String().
2) The destructor is incorrect because it is declared outside the class definition.
3) The destructor has been defined correctly.
4) The destructor is incorrect because of the scope resolution operator ::
5) The destructor has been defined incorrectly since it contains code.
Ans is 3
 int count=0;
class object
{
public: object (){
count++;
}
~ object () {
count--;
}
};
main()
{
object AaTemp, BbTemp, CcTemp, DdTemp;
return 0 ;
}
What is the value of "count" immediately before the return statement above is executed?
1) 0
2) 1
3) 2
4) 3
5) 4
Ans is 5)
 Your project manager suddenly calls you one day and asks you to integrate ongoing existing project
with an external timer. He clarifies you the requirement and tells to include adding a global variable
whose contents can be only read by the software but whose value will be continuously updated by the
hardware clock. Referring to the above scenario, which one of the following variable declarations will
satisfy his requirements?
1) volatile clock;
2) const volatile long clock;
3) long clock;
4) const mutable long clock;
5) mutable long clock;
Ans is 2)
 class Dadda
{
};
class Ma : virtual public Dadda
{
};
class Baba : virtual public Dadda
{
};
class CareerACE : public Ma, public Baba, virtual public Dadda
{
};
Each object of type CareerACE will contain how many sub-objects of type Dadda?
1) 1
2) 2
3) 3
4) 4
5) 5
Ans is 1)
 What is the name of the constructor, that will be invoked when we instantiate the object of the
class as below?
class Bong
{
public:
Bong ( int i );
};
Bong BongObject = 10 ; // assigning int 10 Bong object
Ans conversion constructor
 Name the operators that cannot be overloaded?
sizeof, ., .*, .->, ::, ?:
 What is the size of class DATA on 32 bit processor?
class DATA
{
char c1;
char c2;
int i1;
int i2;
char *ptr;
static int mem;
};
Ans 16

SQL Questions
 What is a raw in database table called?
Tuple or Record.
 What is difference between extension and intension?
Extension – It is the number of tuples present in a table at any instance. This is time dependent.
Intension – It is a constant value that gives the name, structure of table and the constraints laid on it.
 What is normalization?
Normalization is an attempt to eliminate\minimize the problems occurring due to data redundancy over the
lifetime of a database.
 What's the difference between a primary key and a unique key?
Both Primary key and unique enforce uniqueness of the column on which they are defined. But by default
Primary key creates a clustered index on the column, where as unique key creates a non-clustered index by
default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL
only.
 Consider the below DBMS table called "CareerACEFounder":
Id LastName FirstName Address City
1 das Srikanta Gachibowli Hyderabad
2 Chanda Subhash C.V. Raman Nagar Bangalore
3 Pettersen Sauvik Gachibowli Hyderabad
4 Bhasker Vijay Kukatpally Hyderabad
5 chandan Subhash Kukatpally Hyderabad
Find the people whose FirstName starts with s
1. SELECT * FROM CareerACEFounder WHERE FirstName LIKE 's%'
2. SELECT * FROM CareerACEFounder WHERE FirstName ='Srikanta'
3. SELECT * FROM CareerACEFounder WHERE FirstName ='%'
4. SELECT * FROM CareerACEFounder WHERE FirstName ='-'
Ans 1)
Find the people whose LastName starts with „C‟, followed by any character, followed by „and‟ followed by
any characters.
1. SELECT * FROM CareerACEFounder WHERE FirstName LIKE 'C_and_'
2. SELECT * FROM CareerACEFounder WHERE FirstName LIKE 'C%and%'
3. SELECT * FROM CareerACEFounder WHERE FirstName LIKE 'Chanda'
4. SELECT * FROM CareerACEFounder WHERE FirstName LIKE 'Chandan'
Ans is 2)

OS Questions
 What is starvation?
Starvation is caused when a process is ready to be executed but is not being processed because it is still waiting
for the CPU time slice.
 What is Soft and Hard real time OS?
A hard real-time system guarantees that a critical task completes within a bounded time frame. This goal
requires that, all delays in the system be bounded from the retrieval of the stored data, to the time that it takes
the operating system to finish any request made for it. To make it a bit simple, a hard real time system requires
the response time to be very small or bounded. E.g. in a navigation device of a passenger aircraft, it is critical
that the flight should be on the correct path and this requires a Hard real time software for real time response.
A soft real time system is more involved with the Quality of the service and will slow down their response
time if the load is very high and wherein a critical real-time task gets priority over other tasks and retains that
priority until it completes. To make it simple, it is involved with the quality of the service rather than the
response time. E.g. of this is an entertainment system in an aircraft.
 What is an iNode?
An inode is a data structure on a traditional Unix-style file system such as UFS or EXT3. An inode stores basic
information about a regular file, directory, or other file system object. Each object in the file system is
represented by an inode.
 What is an interpreter?
It is a program that executes instructions written in a high-level language. An interpreter translates high-level
instructions into an intermediate form, which it then executes. An interpreter executes a program line by line.
Compiled programs generally run faster than interpreted programs. The advantage of an interpreter, however,
is that it does not need to go through the compilation stage during which machine instructions are generated.
This process can be time-consuming if the program is long. The interpreter can immediately execute high-level
programs. For this reason, interpreters are sometimes used during the development of a program, when a
programmer wants to add small sections at a time and test them quickly. In addition, interpreters are often
used in education because they allow students to program interactively.
 What is a Bootstrap loader?
Bootstrap loader is a small piece of code which locates the kernel, loads it into memory, and starts it. Sometimes
this is a two-step process where boot block at fixed location loads bootstrap loader. When we power on a
system, execution starts at a fixed memory location. Generally a firmware is used to hold initial boot code.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy