“Infosys” Interview Questions

“Infosys” Interview Questions

1.Which of the following ways to create an object of the Sample class given below will work correctly?

 

class Sample

{

int i;

Single j;

double k;

public Sample (int ii, Single jj, double kk)

{

i = ii;

j = jj;

k = kk;

}

}

(A) Sample s3 = new Sample(10, 1.2f, 2.4); (B) Sample s2 = new Sample(10, 1.2f); (C)  Sample s1 = new Sample(, , 2.5); (D) Sample s1 = new Sample(10);

->The answer is (A) Sample s3 = new Sample(10, 1.2f, 2.4);

 

2.What is scope of a protected member variable of a C# class?

->Protected access specifier allows a child class to access the member variables and member functions of its base class. This way it helps in implementing inheritance.

 

3.What are nullable types in C#?

C# provides a special data types, the nullable types, to which you can assign normal range of values as well as null values.

 

4.Which class acts as a base class for all arrays in C#?

->The Array class is the base class for all the arrays in C#. It is defined in the System namespace. The Array class provides various properties and methods to work with arrays.

 

5.What are virtual functions in C#?

->When you have a function defined in a class that you want to be implemented in an inherited classes, you use virtual functions. The virtual functions could be implemented differently in different inherited class and the call to these functions will be decided at runtime.

 

  1. void PrintTree (Tree T)

Ans:{

if (T != NULL)

{

PrintTree (T-> Left);

PrintElement (T-> Element);

PrintTree (T->Right);

}

}

The above method ‘PrintTree’ results in which of the following traversal

a Inorder

  1. Preorder
  2. Postorder
  3. None of the above

Solution: a. Inorder

Inorder:

void PrintTree (Tree T)

{

if (T != NULL)

{

PrintTree (T-> Left);

PrintElement (T-> Element);

PrintTree (T->Right);

}

}

For preorder use this order

PrintElement (T-> Element);

PrintTree (T-> Left);

PrintTree (T->Right);

For postorder use this order

PrintTree (T-> Left);

PrintTree (T->Right);

PrintElement (T-> Element);

 

7.Write an Advantage of Dubly linked list

Ans:Both way trevarsel can be possiable through Nodes and its address.

The time requered to search an element in a linked list of length n is

Ans:o(n)

 

8.How do you construct an increment statement or decrement statement in C?

->It can be done in two ways- a)Using increment or deccrement operator. For example- if ‘x’ is an integer variable,x++ means the value of x will be incremented by 1. if x=1, x++ means the value of x is 2. In case of decrement operator,if x=5,x– means the value of x is 4. b)Another way to increment or decrement is simply adding or subtracting integer value to a variable. For example if x=5, we can increment it like x=x+1 or decrement it like x=x-1, so the value of x will be 6 and 4 respectively.

 

  1. In C programming, how do you insert quote characters (‘ and “) into the output screen?

->In C programming every symbol have their unique identity and ASCII value. As ‘ and ” are a special character, before using these you have to be carefull. If you want these to be printed like a siple charater in a statement then just use format specifiers before these to indicate as a simple printable charcter. Example- \’ will print single quote and \” will print double quote.

 

10.Write a loop statement that will show the following output:

1

12

123

1234

12345

Answer:The logic to print this pattern in C will be-

 

for (a=1; a<=5; i++) {

for (b=1; b<=a; b++)

printf(“%d”,b);

printf(“\n”);

}

 

10.What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

->This kind of problem occurs when you do not mention the header properly. You should check if the ‘#include’ is properly maintained in the program or not.

 

11.What does the format %10.2 mean when included in a printf statement?

->It indicates the decimal number with 2 decimal places after the deccimal point and 10 decimal places before the the decimal point to represent the actual value.If the decimal number has less than the number of the decimal digits, it will be filled with 0 upto 10 where 0 will not be printed.

 

12.What is Object Oriented model?

Ans:an objects ghas its own programs like value,size ,color etc taht value are stored in it’s instance variables,it has it’s own code which can operate with the object.

those bodies are basically called mathod.basically Object Oriented model is an approach to modeling an application that is used at the beginning of the Sdlc(software devolopment life cycel).

 

13.what is data abstraction?

Ans:sometime developer hide the complexcity from user.The need for efficiency has lead desingers to use complex data structure to represent data in database.that process is callede data abstraction.

 

14.What is view serializable?

Ans:in a database is shedule is to be said  serializable when its view serializable is equvalent to the other serial schedule.I.E. the view will be samae as

schedule serial.

 

15.What is a foreign key?

Ans:In the term of relational database a foreign key is an anothe type pf primary key that is the unic key or uniquely identifies a row of another table or same

Table.

 

16.How do you set security in applets?

Ans:Using of the manage method it can set security for an applet.

 

17.What is synchronization?

Ans:It is a technique which execute that if there is running more or one thread .if it happen then it allow one thred to use a perticular Resource.

 

18.What is deadlock?

Ans: Dead locak is a state where one process is holding a resource and theat ressource is importent for the other process that time they can’t run a singel process that is called deadlock.

 

19.What is an applet?

Ans:to display java code in an webpage there are use some dynamic programs that are called Applet.

 

20.what is need of init() method in applet ?

Ans: init() method is called when a applet first call.

 

21.what is need of start() method  in applet ?

Ans:start() method  it is the  second method when applet is being in run.

 

22.What is the Java API?

Ans:It is basically collection of software component That allow capbility for graphical user interface(GUI).

 

23.What is the use of bin and lib in JDK?

Ans:There is two file structure a BIN and another is library.BIN contain tools and lib contain all API packages.

 

24.What is this()?

Ans:To invoke a constructer for the same class this method is used.

 

25.what do you mean by super()?

Ans:It is a method basically used to invoke a constructor. of a super class.