Friday 17 June 2011

C++ interview questions and answers

  1. What is the most efficient way to reverse a linklist?
  2. How to sort & search a single linklist?
  3. Which is more convenient - single or double-linked linklist? Discuss the trade-offs? What about XOR-linked linklist?
  4. How does indexing work?
  5. char s[10];
    s=”Hello”;
    printf(s);

    What will be the output? Is there any error with this code?
  6. What is the difference between
    char s[]=”Hello”;
    char *s=”Hello”;

    Please give a clear idea on this?
  7. Why do we pass a reference for copy constructors? If it does shallow copy for pass by value (user defined object), how will it do the deep copy?
  8. What is the difference between shallow copy & deep copy?
  9. What is the difference between strcpy and memcpy? What rule should we follow when choosing between these two?
  10. If we declare two variable and two applications are using the same variable, then what will its value be, will it be the same?

Thursday 16 June 2011

Technical Interview "Java" Questions

If a variable is declared as private, where may the variable be accessed?
http://materialsforjob.blogspot.com
It may be accessed in any of the methods defined in that class. Generally for the security of the variables we declare them as private and using the public methods in the class we use them. Making sure that variables are accessible only in that class.
What is the difference between Abstract class and Interface?
An abstract class can contain non-abstract methods which do not have to be overridden in the subclass.
There is no difference between a fully abstract class (all methods declared as abstract and all fields are public static final) and an interface.
How to create a Tabbed Pane in JSP page?
//declare
private JTabbedPane pane ;
//initialise
pane = new JTabbedPane();
//add GUI components to the TABPANE
pane.addTab(nameoftab, component);

Why getInstance() method is used along with class declaration in Java?
This method is used to tracing the instance in your application. Which instance is running of the class.

What is the immediate superclass of the Dialog class?
System.Windows.Forms.CommonDialog
What is the difference between string and string buffer?
String objects are constants & immutable string Buffer objects are not constants & growable
What is the return type of a program's main() method?
A program's main() method has a void return type.

What is the default size of Vector, Arraylist, Hashtable, Hashmap, Hashset in Java?
A vector has its default capacity which is 10 elements, here size is different from capacity, after 10 element if we enter one element the capacity of vector changes to 20 were as size is 11 only, for example if you have entered 21 elements in a vector, then if you print v.size it results 21 but v.capacity it results 30 If you have any further queries please let me know

What is the difference between a Window and a Frame?
The Frame class extends Window to define a main application window that can have a menu bar.
What is the difference between static variable and instance variable?
Static variable the field is allocated when the class is created. It belongs to the class and not any object of the class. It is class variable

Instance variable the field is allocated when the class is instantiated to the class is called instance variable or non-static variable
What modifiers may be used with a top-level class?
The modifiers a top-level class can have are public and either abstract or final.
A nested class is any class whose declaration occurs within the body of another class or interface. A top level class is a class that is not a nested class. In other words, a top level class is any class that is not declared within another class or interface.
The modifiers private and protected can only be used with member classes, a top level class is not a member class, it can never be a member class, because if it were a member class it would by definition be a nested class and by definition would not be a top level class.

Monday 13 June 2011

PHP Interview Questions and answers 3


Strings and regular expressions

What will be the answer of the following code snippet?
1echo 'Testing ' . 1 + 2 . '45';
Simply you will give the answer as : Testing 345
But the answer is : 245
That is because you can not sum a number with a string. The first part, before the plus mark is a string though there is 1 there.
So engine will simply get it as 0 and the latter part as 245. so answer will be 245.


variable interpolation

Using variable interpolation how we can print the following String?

“I am visiting the php interview questions website”.
The word “question” is inside a variable,
$a = ‘question’;
Answer is just,
echo “I am visiting the php interview {$a}s website”;


function return value

What will be the out put of the following code snippet?
if(!r())
echo ‘aaa’;
else
echo ‘err’;

function r(){
//return 1;
}

Here you will not get a chance to execute and see what is the out put.  So you have to know exactly what will happen here. Probably even if you are a php pro, sometimes you might get confused here.
It will print “aaa”, even though the function do not return anything.


POST and GET Methods

Which will execute faster POST or GET?
GET transfer data to the server using URL whereas POST transfer data using form collection which is added to the request by the browser. We can send at most 1024 bytes using URL hence there is upper limit for GET method POST method can transfer large amount of data where upper limit is imposed by web server which is about 2MB data is shown to the user in GET method.
Get is faster but not safe.

 

 


 


 


 

Friday 10 June 2011

C++ interview questions

  1. What is a void return type?
  2. How is it possible for two String objects with identical values not to be equal under the == operator?
  3. What is the difference between a while statement and a do statement?
  4. Can a for statement loop indefinitely?
  5. How do you link a C++ program to C functions?
  6. How can you tell what shell you are running on UNIX system?
  7. How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
  8. How do you write a function that can reverse a linked-list?
  9. Can a copy constructor accept an object of the same class as parameter, instead of reference of the object?
  10. What is a local class?
  11. What is a nested class?
  12. What are the access privileges in C++? What is the default access level?
  13. What is multiple inheritance(virtual inheritance)? What are its advantages and disadvantages?
  14. How do you access the static member of a class?
  15. What does extern int func(int *, Foo) accomplish?

Tuesday 7 June 2011

C and C++ questions for the interview

  1. What is the output of printf(”%d”)
  2. What will happen if I say delete this
  3. Difference between “C structure” and “C++ structure”.
  4. Diffrence between a “assignment operator” and a “copy constructor”
  5. What is the difference between “overloading” and “overridding”?
  6. Explain the need for “Virtual Destructor”.
  7. Can we have “Virtual Constructors”?
  8. What are the different types of polymorphism?
  9. What are Virtual Functions? How to implement virtual functions in “C”
  10. What are the different types of Storage classes?
  11. What is Namespace?
  12. What are the types of STL containers?.
  13. Difference between “vector” and “array”?
  14. How to write a program such that it will delete itself after exectution?
  15. Can we generate a C++ source code from the binary file?
  16. What are inline functions?
  17. What is “strstream” ?
  18. Explain “passing by value”, “passing by pointer” and “passing by reference”
  19. Have you heard of “mutable” keyword?
  20. What is a “RTTI”?
  21. Is there something that I can do in C and not in C++?
  22. What is the difference between “calloc” and “malloc”?
  23. What will happen if I allocate memory using “new” and free it using “free” or allocate sing “calloc” and free it using “delete”?
  24. Difference between “printf” and “sprintf”.
  25. What is “map” in STL?
  26. When shall I use Multiple Inheritance?
  27. Explain working of printf.
  28. Talk sometiming about profiling?
  29. How many lines of code you have written for a single program?
  30. How to write Multithreaded applications using C++?
  31. Write any small program that will compile in “C” but not in “C++”
  32. What is Memory Alignment?
  33. Why preincrement operator is faster than postincrement?
  34. What are the techniques you use for debugging?
  35. How to reduce a final size of executable?
  36. Give 2 examples of a code optimization.

Search here for "Freshers Jobs"