Wednesday 16 January 2013

print the alternate charecters in the original string using pointers

// output: w l o e t mt
#include
void alternater(char*,char*);
void main()
{
char str[20]="welcome t kmit";
char res[10];
alternater(str,res);
printf("%s",res);
}
void alternater(char *org,char *astr){
int i,j,n;
n=strlen(org);
for(i=0,j=0;j {
astr[i]=org[j];
}
astr[i]='\0';
}

Example on Nested Structure in c

#include
struct Addr
{
int streetno;
char city[10];
char state[20];
int zipcode;
};
struct Student
{ int rno;
char sname[20];
int smarks;
int age;
struct Addr a;
};
struct Student carr[]={{1,"Fasi",100,50,
{10,"Hyderabad,"Telengana",500027}}};
void main()
{
struct Student *sptr;
struct Addr b={15,"Vizag","Andhra",500058};
sptr=carr;
sptr->a=b;
printf("%s",sptr->a.state);
}

Thursday 3 January 2013

interview questions in java

1. What is the difference between an Interface and an Abstract class?
2. What is the purpose of garbage collection in Java, and when is it used?
3. Describe synchronization in respect to multithreading.
4. Explain different way of using thread?
5. What are pass by reference and passby value?
6. What is HashMap and Map?
7. Difference between HashMap and HashTable?
8. Difference between Vector and ArrayList?
9. What is the difference between a constructor and a method?
10. What is an Iterator?
11. State the significance of public, private, protected, default modifiers
both singly and in combination and state the effect of package
relationships on declared items qualified by these modifiers.
12. What is an abstract class?
13. What is static in java?
14. What is final?
15. What if the main method is declared as private?
16. What if the static modifier is removed from the signature of the main method?
17. What if I write static public void instead of public static void?
18. What if I do not provide the String array as the argument to the method?
19. What is the first argument of the String array in main method?
20. If I do not provide any arguments on the command line, then the String
array of Main method will be empty or null?
21. How can one prove that the array is not null but empty using one line
of code?
22. What environment variables do I need to set on my machine in order to
be able to run Java programs?
23. Can an application have multiple classes having main method?
24. Can I have multiple main methods in the same class?
25. Do I need to import java.lang package any time? Why ?
26. Can I import same package/class twice? Will the JVM load the package
twice at runtime?
27. What are Checked and UnChecked Exception?
28. What is Overriding?
29. What are different types of inner classes?
30. Are the imports checked for validity at compile time? e.g. will the
code containing an import such as java.lang.ABCD compile?
31. Does importing a package imports the subpackages as well?
e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*?
32. What is the difference between declaring a variable and defining a variable?
33. What is the default value of an object reference declared as an
instance variable?
34. Can a top level class be private or protected?
35. What type of parameter passing does Java support?
36. Primitive data types are passed by reference or pass by value?
37. Objects are passed by value or by reference?
38. What is serialization?
39. How do I serialize an object to a file?
40. Which methods of Serializable interface should I implement?
41. How can I customize the seralization process? i.e. how can one
have a control over the serialization process?
42. What is the common usage of serialization?
43. What is Externalizable interface?
44. When you serialize an object, what happens to the object references
included in the object?
45. What one should take care of while serializing the object?
46. What happens to the static fields of a class during serialization?
47. Does Java provide any construct to find out the size of an object?
48. Give a simplest way to find out the time a method takes for
execution without using any profiling tool?
49. What are wrapper classes?
50. Why do we need wrapper classes?
51. What are checked exceptions?
52. What are runtime exceptions?
53. What is the difference between error and an exception?
54. If my class already extends from some other class what should
I do if I want an instance of my class to be thrown as an exception object?
55. How does an exception permeate through the code?
56. What are the different ways to handle exceptions?
57. What is the basic difference between the 2 approaches to exception handling.
1> try catch block and
2> specifying the candidate exceptions in the throws clause?
When should you use which approach?
58. Is it necessary that each try block must be followed by a catch block?
59. If I write return at the end of the try block, will the finally block
still execute?
60. If I write System.exit (0); at the end of the try block, will the finally
block still execute?
61. How are Observer and Observable used?
62. What is synchronization and why is it important?
63. How does Java handle integer overflows and underflows?
64. Does garbage collection guarantee that a program will not run out of memory?
65. What is the difference between preemptive scheduling and time slicing?
66. When a thread is created and started, what is its initial state?
67. What is the purpose of finalization?
68. What is the Locale class?
69. What is the difference between static and non-static variables?
70. How are this() and super() used with constructors?
71. What are synchronized methods and synchronized statements?
72. What is daemon thread and which method is used to create the daemon thread?
73. What are the steps in the JDBC connection?
74. How does a try statement determine which catch clause should be used
to handle an exception?
75. Can an unreachable object become reachable again?
76. What method must be implemented by all threads?
77. What are synchronized methods and synchronized statements?
78. What is Externalizable?
79. What modifiers are allowed for methods in an Interface?
80. What are some alternatives to inheritance?
81. What does it mean that a method or field is "static"?
82. What is the catch or declare rule for method declarations?
83. Is Empty .java file a valid source file?
84. Can a .java file contain more than one java classes?
85. Is String a primitive data type in Java?
86. Is main a keyword in Java?
87. Is next a keyword in Java?
88. Is delete a keyword in Java?
89. Is exit a keyword in Java?
90. What happens if you dont initialize an instance variable of
any of the primitive types in Java?
91. What will be the initial value of an object reference which is
defined as an instance variable?
92. What are the different scopes for Java variables?
93. What is the default value of the local variables?
94. How many objects are created in the following piece of code?
MyClass c1, c2, c3;
c1 = new MyClass ();
c3 = new MyClass ();
95. Can a public class MyClass be defined in a source file named YourClass.java?
96. Can main method be declared final?
97. What will be the output of the following statement?
System.out.println ("1" + 3);
98. What will be the default values of all the elements of an array
defined as an instance variable?

Important questions in pointers

1. What does static variable mean?
2. What are the differences between malloc() and calloc()?
3. What is the difference between strings and character arrays?
4. Difference between const char* p and char const* p?
5. Can static variables be declared in a header file?
6. How can you determine the size of an allocated portion of memory?
7. When does the compiler not implicitly generate the address of the
first element of an array?
8. What is a null pointer?
9. What is static memory allocation and dynamic memory allocation?
10. How are pointer variables initialized?
11. Difference between arrays and pointers?
12. Is using exit() the same as using return?
13. What is indirection?
14. What is modular programming?
15. What is the difference between declaring a variable and defining a variable?
16. What is an lvalue?
17. Differentiate between an internal static and external static variable?
18. What is the difference between a string and an array?
19. What is an argument? Differentiate between formal arguments
and actual arguments?
20. What are advantages and disadvantages of external storage class?
21. What is a void pointer?
22. When should a type cast not be used?
23. When is a switch statement better than multiple if statements?
24. What is a static function?
25. What is a pointer value and address?
26. What is a modulus operator? What are the restrictions of a modulus operator?
27. Differentiate between a linker and linkage?
28. What is a function and built-in function?
29. Why should I prototype a function?
30. What do you mean by normalisation of pointers?