Java Drill – 1

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

No comments:

Post a Comment