Wednesday 30 November 2011

How do you do object pooling in .NET ?

COM+ reduces overhead by creating object from scratch. So in COM+ when object is activated its activated from pool and when its deactivated it’s pushed back to the pool. Object pooling is configures by using the “ObjectPoolingAttribute” to the class.

Note:- When a class is marked with objectpooling attribute it can not be inherited.


ObjectPooling(MinPoolSize := 2, MaxPoolSize := 5, CreationTimeout := 20000)> _
Public Class testingclass

Tuesday 29 November 2011

Predict the output or error(s) for the following:

main()

{

char *p="hai friends",*p1;


p1=p;


while(*p!='\0') ++*p++;


printf("%s   %s",p,p1);


}

Answer:

ibj!gsjfoet


Explanation:

What is a Bus?


  • A communication pathway connecting two or more devices

  • Often grouped


---- A number of channels in one bus


---- e.g. 32 bit data bus is 32 separate single bit channels


Data Bus :

  • Carries data


---- Remember that there is no difference between “data” and “instruction” at this level.




  • Width is a key determinant of performance


---- 8, 16, 32, 64 bit



Address bus :



  • Identify the source or destination of data


e.g. CPU needs to read an instruction (data) from a given

Monday 28 November 2011

Operators and assignments

Using operators - 2


Increment and decrement operators


Two shortcut arithmetic operators are ++, which increments its operand by 1, and --, which decrements its operand by 1.

  • ++ increment operator (increments value by 1)

  • -- decrement operator (decrements value by 1)


These operators can appear before the operand (prefix) or after the operand (postfix). In the case of the prefix style, the value of the operand is evaluated after the increment/decrement operation. For postfix, the value of the operand is evaluated before the

Operators and assignments

Using operators - 1


Assignment operators


You can assign a primitive variable using a literal or the result of an expression. The result of an expression involving integers (int, short, and byte) is always at least of type int. Narrowing conversions are not allowed, as they would result in the loss of precision. For instance:

byte b = 5;
byte c = 4;
byte d = b + c;               // does not compile because int cannot fit in a byte


float f = (float)35.67;   // implicitly double, so casting to float
float f = 35.67F;


A boolean cannot be assigned any type other than boolean.

If we assign an existing object reference to a reference variable, both reference variables refer to the same object. It is legal to assign

Sunday 27 November 2011

What is operator promotion?

If an operation is specified with operands of two different types, they are converted to the smallest type that can hold both values. The result has the same type as the two operands wind up having. To interpret the rules, read the following table from the top down, and stop at the first rule that applies.

The following example code illustrates some cases of operator

Are there any problems with performing mathematical operations on different variable types?

C has three categories of built-in data types: pointer types, integral types, and floating-point types.

Pointer types are the most restrictive in terms of the operations that can be performed on them. They are limited to

" -  " subtraction of two pointers, valid only when both pointers point to elements in the same array. The result is the same as subtracting the integer subscripts corresponding to the two pointers.

" + " addition of a pointer and an integral type. The result is a

Saturday 26 November 2011

How many types of Transactions are there in COM + .NET ?

There are 5 transactions types that can be used with COM+. Whenever an object is registered with COM+ it has to abide either to these 5 transaction types.

Disabled: - There is no transaction. COM+ does not provide transaction support for this component.

Not Supported: - Component does not support transactions. Hence even if the calling component in the hierarchy is transaction

How to implement DTC in .NET ?

DTC is implemented using COM+.

Following are the steps to implement COM + in .NET :-

  • “EnterpriseService” namespace has all the classes by which we can implement DTC in .NET. You have to add reference “EnterpriseService” namespace.


Add reference to EnterpriseServices.




  • Your class must derive from “Serviced Component” object.

  • Then you have to define your class with the transaction attribute (For all transaction attribute look the down

Friday 25 November 2011

What will be the result of compiling and running the following program

public class Test
{

static int i;
static public void main(String[] args)
{


do
{


System.out.println(args[++i]);


} while (i < args.length);


}


}

Choices:
A. Prints "hello"
B. Prints "Test"
C. Code does not compile
D. Throws an ArrayIndexOutOfBoundsException

Correct choice:

  • D


Explanation:

Interrupts

Mechanism by which other modules (e.g. I/O) may interrupt normal sequence of processing

  • Program


e.g. overflow, division by zero

  • Timer :Generated by internal processor timer


Used in pre-emptive multi-tasking I/O from I/O controller

  • Hardware failure


e.g. memory parity error

Interrupt Cycle :



  • Added to instruction cycle

  • Processor checks for interrupt


          ---Indicated by an interrupt signal




  • If no interrupt, fetch next instruction

  • If interrupt pending:


         ---Suspend execution of current program

Thursday 24 November 2011

Can you explain what is DCOM ?

DCOM differs from COM in that it allows for creating objects distributed across a network, a protocol for invoking that object’s methods, and secures access to the object. DCOM provides a wrapper around COM, hence it is a backwards compatible extension. DCOM uses Remote Procedural Calls (RPC) using Open Software Foundation’s Distributed Computing Environment.

These RPC are implemented over TCP/IP and named pipes. The protocol which is actually being used is registered just prior to use, as opposed to being registered at initialization time. The reason for

What is Reference counting in COM ?

Reference counting is a memory management technique used to count how many times an object has a pointer referring to it. The first time it is created, the reference count is set to one. When the last reference to the object is nulled, the reference count is set to zero and the object is deleted. Care must be exercised to prevent a context switch from changing the reference count at the time of deletion. In the methods that follow, the syntax is shortened to keep

Wednesday 23 November 2011

Literals in Java

Integer literals can be decimal, octal, or hexadecimal.

Octal literals begin with zero and only digits 0 through 7 are allowed. For instance:

011


Hexadecimal literals begin with 0x or oX, the digits allowed are 0 through 9 and a through f (or A through F). For instance:

0x0001;


All integer literals are of type int by default. To define them as long, we can place a suffix of L or l after the number.

For char literals, a single character is enclosed in single quotes. You can also use the prefix \u followed by four hexadecimal digits

Java keywords and identifiers

Keywords are reserved words that are predefined in the language; see the table below. All the keywords are in lowercase.

Note: assert is a new keyword since J2SE 1.4

An identifier is composed of a sequence of characters where each

How can you determine the maximum value that a numeric variable can hold?

The easiest way to find out how large or small a number that a particular type can hold is to use the values defined in the ANSI standard header file limits.h. This file contains many useful constants defining the values that can be held by various types, including these:

For integral types, on a machine that uses two’s complement

How reliable are floating-point comparisons?

Floating-point numbers are the “black art” of computer programming. One reason why this is so is that there is no optimal way to represent an arbitrary number. The Institute of Electrical and Electronic Engineers (IEEE) has developed a standard for the representation of floating-point numbers, but you cannot guarantee that every machine you use will conform to the standard.

Even if your machine does conform to the standard, there are deeper issues. It can be shown mathematically that there are an infinite number of “real” numbers between any two numbers. For the computer to distinguish between two numbers, the bits that

Tuesday 22 November 2011

Computer Components:

Top Level View



Instruction Cycle :

The IAS computer operated by a repetitively performing an instruction cycle .Each instruction cycle consists of two sub cycles.

  1. Fetch Cycle

  2. Execute Cycle


Basic Instruction cycle:

Fetch Cycle :

During the Fetch cycle, the opcode of the next instruction is loaded

What is COM ?

Microsoft’s COM is a technology for component software development. It is a binary standard which is language independent. DCOM is a distributed extension of COM.

When we use windows API in .NET is it managed or unmanaged code?

Windows API in .NET is unmanaged code.

Note:- Even though VB6 and V C++ has gone off still many people do ask these old questions again and again. Still there are decent old application which are working with COM very much fine. So interviewer still asks you these questions so that those application’s can be ported to .NET. So let’s play some old music...

How can we make Windows API calls in .NET?

Windows API calls are not COM based and they are invoked through Platform Invoke Services.

Declare StringConversionType (Function | Sub) MethodName Lib "DllName" ([Args]) As Type

  • StringConversionType is for what type of conversion should take place. Either we can specify Unicode to convert all strings to Unicode values, or Auto to convert strings according to the .NET runtime rules.

  • MethodName is the name of the API to call.

  • DllName is the name of the DLL.

  • Args are any arguments to the API call.

  • Type is the return type of the API call.


Below is a sample code for VB.NET which uses Sleep windows API

Sunday 20 November 2011

Saving a file for older versions of Microsoft Office

If you need to share files with people using older versions of Microsoft Office, you need to save your files in a different file format known as 97-2003, such as Word 97-2003 Document or PowerPoint 97-2003 Presentation.

This special 97-2003 file format saves Office 2007 files so that previous versions of Microsoft Office 97/2000/XP/2003 can open and edit your files.

When you save files in the 97-2003 format, Microsoft Office 2007 saves your files with a three-letter file extension, like .doc or .xls. When you save files in the Office 2007 format, Microsoft Office

Saturday 19 November 2011

Sun Certified Java Programmer (SCJP)

Interfaces


An interface is like a public class that has only abstract and public methods. The variables declared in an interface are implicitly public, static, and final. For instance:

interface MyInterface
{


void f();


}


class MyClass implements MyInterface
{


public void f() {}


}


A concrete class implementing an interface has to implement all the methods declared in it.

Interface methods are implicitly public and cannot be declared

Sun Certified Java Programmer (SCJP)

Language fundamentals


Package and class declarations


A package represents a group of classes. A package statement should be the first valid statement in the source file. If there is no package statement, the classes in the source file belong to the default unnamed package, or else they belong to the named package. Only one package statement is allowed in a source file.

In a source file, there can be only one public class, and the name of the file should match that of the class. An import statement allows

Friday 18 November 2011

Classify the Hashing Functions based on the various methods by which the key value is found.


  • Direct method,

  • Subtraction method,

  • Modulo-Division method,

  • Digit-Extraction method,

  • Mid-Square method,

  • Folding method,

  • Pseudo-random method.

Sort the given values using Quick Sort :

Sorting takes place from the pivot value, which is the first value of the given elements, this is marked bold. The values at the left pointer and right pointer are indicated using L and R respectively.

Since pivot is not yet changed the same process is continued after

Predict the output or error(s) for the following:

const int size = 5;

void print(int *ptr)

{

cout<<ptr[0];


}

void print(int ptr[size])

{

cout<<ptr[0];


}

void main()

{

int a[size] = {1,2,3,4,5};


int *b = new int(size);


print(a);


print(b);


}

Answer:

Compiler Error : function 'void print(int *)' already has a body

Explanation:

Predict the output or error(s) for the following:

void main()

{

int a, *pa, &ra;


pa = &a;


ra = a;


cout <<"a="<<a <<"*pa="<<*pa <<"ra"<<ra ;


}

Answer :

Compiler Error: 'ra',reference must be initialized


Explanation :

Thursday 17 November 2011

When should the const modifier be used?

There are several reasons to use const pointers. First, it allows the compiler to catch errors in which code accidentally changes the value of a variable, as in

while (*str = 0) /* programmer meant to write *str != 0 */
{


/* some code here */
str++;


}


in which the = sign is a typographical error. Without the const in the declaration of str, the program would compile but not run properly.

Another reason is efficiency. The compiler might be able to make

Once I have developed the COM wrapper do I have to still register the COM in registry?

Yes.

How can we use .NET components in COM?

What is CCW (COM callable wrapper) ?


How do we ensure that .NET components is compatible with COM ?


.NET components can not be used in straight forward way with COM. You will need to create CCW in order that COM components communicate with .NET assemblies. Following are the different approaches to implement it :-

Wednesday 16 November 2011

Predict the output or error(s) for the following:

 #include<stdio.h>

main()

{

struct xx


{


int x;


struct yy


{


char s;


 struct xx *p;


};


struct yy *q;


};


}

Answer:

Compiler Error


Explanation:

How can we use COM Components in .NET?

.NET components communicate with COM using RCW (Runtime Callable Wrapper). Following are the ways with which you can generate RCW :-

  • Adding reference in Visual Studio.net. See figure below. Wrapper class is generated and placed in the “BIN” directory.


Adding Reference using VS.NET




  • Using Type library import tool. Tlbimp.exe yourname.dll.

  • Using interopservices.System.runtime.Interopservices

Monday 14 November 2011

How Gateway is different from Routers?

A gateway operates at the upper levels of the OSI model and translates information between two completely different network architectures or data formats.

A router is a device in computer networking that forwards data packets to their destinations, based on their addresses.

What is passive topology?

When the computers on the network simply listen and receive the signal, they are referred to as passive because they don’t amplify the signal in any way. Example for passive topology - linear bus.

Predict the output or error(s) for the following:

class base

{

        public:


            virtual void baseFun(){ cout<<"from base"<<endl;}


        };

class deri:public base

{

        public:


            void baseFun(){ cout<< "from derived"<<endl;}


        };

void SomeFunc(base *baseObj)

{

        baseObj->baseFun();


}

int main()

{

base baseObject;


SomeFunc(&baseObject);


deri deriObject;


SomeFunc(&deriObject);


}

Answer:

            from base


            from derived


Explanation:

Predict the output or error(s) for the following:

class base

{

public:


void baseFun(){ cout<<"from base"<<endl;}


};

class deri:public base

{

public:


void baseFun(){ cout<< "from derived"<<endl;}


};

void SomeFunc(base *baseObj)

{

baseObj->baseFun();


}

int main()

{

base baseObject;


SomeFunc(&baseObject);


deri deriObject;


SomeFunc(&deriObject);


}

Answer:

from base


from base


Explanation:

Sunday 13 November 2011

Sun Certified Java Programmer (SCJP)

How many objects will be eligible for garbage collection after line 7?


public class TutorialGC
{


public static void main(String [] args)
{


Object a = new Integer(100);   // Line1
Object b = new Long(100);       // Line2
Object c = new String("100");  // Line3
a = null;                                        // Line4
a = c;                                             // Line5
c = b;                                             // Line6
b = a;                                             // Line7
// Rest of the code here


}


}



Choices:



  • A. 0

  • B. 1

  • C. 2

  • D. 3

  • E. Code does not compile


Correct choice:



  • B


Explanation:

Sun Certified Java Programmer (SCJP)

Garbage collection


Finalization


Java technology allows you to use the finalize() method to do the necessary cleanup before the garbage collector removes the object from memory. This method is called by the garbage collector on an object when garbage collection determines that there are no more references to the object. It is defined in the Object class, thus it is inherited by all classes. A subclass overrides the finalize() method to

Sun Certified Java Programmer (SCJP)

Garbage collection


Eligibility for garbage collection


An object is eligible for garbage collection when no live thread can access it.

An object can become eligible for garbage collection in different ways:

  • If the reference variable that refers to the object is set to null, the object becomes eligible for garbage collection, provided that no other reference is referring to it.

  •  If the reference variable that refers to the object is made to refer to some other object, the object becomes eligible

Sun Certified Java Programmer (SCJP)-10

Garbage collection


Behavior of the garbage collector


A Java programmer does not have to worry about memory management, because it is automatically taken care of by the garbage collector. The Java virtual machine (JVM) decides when to run the garbage collector. The garbage collector is a low priority thread that runs periodically, releasing memory used by objects that are not needed anymore.

The garbage collection (GC) algorithm varies from one JVM to another. There are different algorithms being used, like reference

Friday 11 November 2011

Predict the output or error(s) for the following:

#include<stdio.h>

main()

{

struct xx


{


      int x=3;


      char name[]="hello";


 };


struct xx *s;


printf("%d",s->x);


printf("%s",s->name);


}

Answer:

Compiler Error


Explanation:

Predict the output or error(s) for the following:

#include<stdio.h>

main()

{

int a[2][2][2] = { {10,2,3,4}, {5,6,7,8}  };


int *p,*q;


p=&a[2][2][2];


*q=***a;


printf("%d----%d",*p,*q);


}

Answer:

SomeGarbageValue---1

Explanation:

Tuesday 8 November 2011

Write a program to print Pascal triangle

Algorithm:

 Step1:         start

Step2:         initialize binom =1, f=0

Step3:         check the condition f<p

Step4:         for r=40-3*f;r>0; --r

Step5:         print" "

Step6:         for x=0; x<f; ++x

Step7:         if x == 0 or f==0

          Binom = 1


Step8:         else

          Binom=(bimom*(f-x+1)/x


          Printf binom


Step9:         stop

 

Program:

Write a Program to find Armstrong number

Algorithm:

Step1:         start

Step2:         read the number

Step3:         while n!=0 calculate sum+pow(n%10,3);

          Else


          Goto 5


Step4:         n=n/10 goto 3

Step5:         if sum==n print the no is armstrong else goto 6

Step6:         print the no is not prime

Step7:         stop

 

Program:

Can a variable be both const and volatile?

Yes. The const modifier means that this code cannot change the value of the variable, but that does not mean that the value cannot be changed by means outside this code. For instance, in the above example, the timer structure was accessed through a volatile const pointer. The function itself did not change the value of the timer, so it

When should the volatile modifier be used?

The volatile modifier is a directive to the compiler’s optimizer that operations involving this variable should not be optimized in certain ways. There are two special cases in which use of the volatile modifier is desirable. The first case involves memory-mapped hardware (a device such as a graphics adaptor that appears to the computer’s hardware as if it were part of the computer’s memory), and the second involves shared memory (memory used by two or more programs running simultaneously).

Most computers have a set of registers that can be accessed faster than the computer’s main memory. A good compiler will perform a

Monday 7 November 2011

What is CodeDom?

“CodeDom” is an object model which represents actually a source code. It is designed to be language independent - once you create a “CodeDom” hierarchy for a program we can then generate the source code in any .NET compliant language. So let’s try to do something real practical and simple to just get a feel of how powerful “CodeDom” is.

Note :- You can get the source code in CD in “CodeDom” folder.


We will try to generate the following code below. The below code

If we have two version of same assembly in GAC how do we make a choice ?

OK first let’s try to understand what the interviewer is talking about. Let’s say you have made an application and its using a DLL which is present in GAC. Now for some reason you make second version of the same DLL and put it in GAC. Now which DLL does the application refer? Ok by default it always uses the version by which you have compiled you application in IDE. But you want that it should actually use the older version.

So first we answer in short. You need to specify “bindingRedirect” in your config file. For instance in the below case “ClassLibraryVersion” has two versions “1.1.1830.10493” and “1.0.1830.10461” from

Sunday 6 November 2011

Saturday 5 November 2011

Sun Certified Java Programmer (SCJP)-9

What will be printed out if you attempt to compile and run the following code?

int i = 3;
switch (i)
{


default:


System.out.println("default");


case 0:


System.out.println("zero");


case 1:


System.out.println("one");
break;


case 2:


System.out.println("two");


}


Choices:

  • A. default

  • B. default, zero, one

  • C. Compiler error

  • D. No output displayed


Correct choice:  B

Explanation:

Sun Certified Java Programmer (SCJP)-8

Exception handling


Exceptions are Java objects; exception classes are derived from java.lang.Throwable.

An exception is thrown to denote an abnormal occurrence like accessing an array index that exceeds the size of the array. Exceptions can be checked or unchecked. Subclasses of RuntimeException and Error are called unchecked exceptions. All other classes, which inherit from Exception, are checked exceptions. Any method that might throw a checked exception must either

Sun Certified Java Programmer (SCJP)-7

Assertions


An assertion is a statement containing a boolean expression that is assumed to be true when the statement is executed. The system reports an AssertionError if the expression evaluates to false. It is used for debugging purposes:

assert(a > 0); // throws an AssertionError if a <= 0



Assertions can be in two forms:


assert Expression1 ;
assert Expression1 : Expression2 ;


Expression1 should always result in a boolean value.

Expression2 can be anything that results in a value. The value is

When should the register modifier be used? Does it really help?

The register modifier hints to the compiler that the variable will be heavily used and should be kept in the CPU’s registers, if possible, so that it can be accessed faster. There are several restrictions on the use of the register modifier.

First, the variable must be of a type that can be held in the CPU’s register. This usually means a single value of a size less than or equal to the size of an integer. Some machines have registers that can hold floating-point numbers as well.

Second, because the variable might not be stored in memory, its

What is a const pointer?

The access modifier keyword const is a promise the programmer makes to the compiler that the value of a variable will not be changed after it is initialized. The compiler will enforce that promise as best it can by not enabling the programmer to write code which modifies a variable that has been declared const.

A “const pointer,” or more correctly, a “pointer to const,” is a pointer which points to data that is const (constant, or unchanging). A pointer to const is declared by putting the word const at the

What is page thrashing?

Some operating systems (such as UNIX or Windows in enhanced mode) use virtual memory. Virtual memory is a technique for making a machine behave as if it had more memory than it really has, by using disk space to simulate RAM (random-access memory). In the 80386 and higher Intel CPU chips, and in most other modern microprocessors (such as the Motorola 68030, Sparc, and Power PC), exists a piece of hardware called the Memory Management Unit, or MMU.

The MMU treats memory as if it were composed of a series of “pages.” A page of memory is a block of contiguous bytes of a certain

Do variables need to be initialized?

No. All variables should be given a value before they are used, and a good compiler will help you find variables that are used before they are set to a value. Variables need not be initialized, however. Variables defined outside a function or defined inside a function with the static keyword are already initialized to 0 for you if you do not explicitly initialize them.

Automatic variables are variables defined inside a function or block

Program Using Switch Case

A Maruthi car dealer maintains a record of sales of various vehicles in the following form:

Vehicle type             Month of sales           Price(Rs)

Maruthi-800                 02/87                      75,000

Maruthi-van                 07/87                       95,000

Maruthi-DX                  04/88                      1,10,000

Gypsy                             08/88                      85,000

Write a c program to read this data in to a table of strings and o/p the details of particular  vehicle sold during a specified period the program should request the user to input the  vehicle type and the period.(starting month and ending month)

Algorithm:

Step 1: Start

Step 2: Enter your choice

Step 3: Read ch value

Step 4: if ch =1 then

4.1 printf "Month of sales is : 02/87”


4.2 printf "Price is : 75,000"


Step 5: if ch =2 then

5.1 print "Month of sales is : 07/87 "


5.2 print "Price is  : 95,000”


step 6: if ch=3 then

6.1 print "Month of sales is  : 04/88 "


6.2 print " Price is  : 1,10,000"


Step 7:

7.1 print "Month of sales is : 08/88 "

7.2 print " Price is  : 85,000"


Step 8 : end

Program:

Write a program to read x and to compute y=1 for x>0,y=0 for x=0 and y=-1 for x

Algorithm:

 Step1:         Start


Step2:         Read the value of x.


Step3:         if (x>0) y-1 else if (x=0) y=0 else x<0) y=-1


Step4:         Print y


Step5:         Stop.



Program:

evaluate the expression 2.5 log(x) +cos(a)+|x2-y2|+2(xy)1/2

Algorithm:

Step1:         Start


Step2:         Read the values of x,y and a.


Step3:         p=2.5*log(x)+ cos(a*3.14/180)+sqrt(2*x*y)+(x*x-y*y)


Step4:         Print p


Step5:         Stop.


 

 

Program:

Friday 4 November 2011

What is Native Image Generator (Ngen.exe)?

The Native Image Generator utility (Ngen.exe) allows you to run the JIT compiler on your assembly's MSIL and generate native machine code which is cached to disk. After the image is created .NET runtime will use the image to run the code rather than from the hard disk. Running Ngen.exe on an assembly potentially allows the assembly to load and execute faster, because it restores code and data structures from the native image cache rather than generating them dynamically.

Below are some points to be remembered for Native Image Generator:-

What is the difference between Convert.ToString and .ToString() method ?

Just to give an understanding of what the above question means seethe below code.

int i =0;
MessageBox.Show(i.ToString());
MessageBox.Show(Convert.ToString(i));


We can convert the integer “i” using “i.ToString()” or “Convert.ToString” so what’s the difference.

The basic difference between them is “Convert” function handles

How to prevent my .NET DLL to be decompiled?

By design .NET embeds rich Meta data inside the executable code using MSIL. Any one can easily decompile your DLL back using tools like ILDASM (owned by Microsoft) or Reflector for .NET which is a third party. Secondly there are many third party tools which make this decompiling process a click away. So any one can easily look in to

Thursday 3 November 2011

Predict the output or error(s) for the following:

class base

{

        public:


        int bval;


        base(){ bval=0;}


        };

 

class deri:public base

{

        public:


        int dval;


        deri(){ dval=1;}


        };

void SomeFunc(base *arr,int size)

{

for(int i=0; i<size; i++,arr++)


        cout<<arr->bval;

cout<<endl;


}

 

int main()

{

base BaseArr[5];


SomeFunc(BaseArr,5);


deri DeriArr[5];


SomeFunc(DeriArr,5);


}

Answer:

 00000


 01010


Explanation:  

Predict the output or error(s) for the following:

class Sample

{

public:

int *ptr;

Sample(int i)

{


        ptr = new int(i);


        }

~Sample()

{


        delete ptr;


        }

void PrintVal()

{


        cout << "The value is " << *ptr;


        }

};

void SomeFunc(Sample x)

{

cout << "Say i am in someFunc " << endl;


}

int main()

{

Sample s1= 10;


SomeFunc(s1);


s1.PrintVal();


}

Answer:

Say i am in someFunc


Null pointer assignment(Run-time error)


Explanation:

Wednesday 2 November 2011

Sun Certified Java Programmer (SCJP)-6

Flow control statements


The flow control statements allow you to conditionally execute statements, to repeatedly execute a block of statements, or to just change the sequential flow of control.

if/else statement


The if/else statement is used for decision-making -- that is, it decides which course of action needs to be taken. The syntax is:

if(boolean expression)
{

Tuesday 1 November 2011

What is CODE Access security?

CAS is part of .NET security model that determines whether or not a piece of code is allowed to run and what resources it can use while running. Example CAS will allow an application to read but not to write and delete a file or a resource from a folder.

What is the difference between System exceptions and Application exceptions?

All exception derives from Exception Base class. Exceptions can be generated programmatically or can be generated by system. Application Exception serves as the base class for all applicationspecific exception classes. It derives from Exception but does not provide any extended functionality. You should derive your

What is the difference between VB.NET and C# ?

Well this is the most debatable issue in .NET community and people treat there languages like religion. Its a subjective matter which language is best. Some like VB.NET’s natural style and some like professional and terse C# syntaxes. Both use the same framework and speed is also very much equivalents. But still let’s list down some major differences between them :-

Advantages of VB.NET :-

  • Has support for optional parameters which makes COM

What is concept of Boxing and Unboxing ?

Boxing permits any value type to be implicitly converted to type object or to any interface type implemented by value type. Boxing is a process in which object instances are created and copy values into that instance.

Unboxing is vice versa of boxing operation where the value is copied

What are Value types and Reference types ?

Value types directly contain their data which are either allocated on the stack or allocated in-line in a structure.

Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types.

Variables that are value types each have their own copy of the data,