Posts

Showing posts with the label Interview Important questions

Java Interview question 5

Q: When a thread is created and started, what is its initial state? A: A thread is in the ready state after it has been created and started. Q: What is the purpose of finalization? A: The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected. Q: What is the Locale class? A: The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region. Q: What is the difference between a while statement and a do statement? A: A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once. Q: What is the difference between static and non-static variables? A: A static variable is associated with the class as a whole rather than with specific

Java Interview Question 4

Q: What is the difference between declaring a variable and defining a variable? A: In declaration we just mention the type of the variable and it's name. We do not initialize it. But defining means declaration + initialization. e.g String s; is just a declaration while String s = new String ("abcd"); Or String s = "abcd"; are both definitions. Q:What is the default value of an object reference declared as an instance variable? A: null unless we define it explicitly. Q: Can a top level class be private or protected? A: No. A top level class can not be private or protected. It can have either "public" or no modifier. If it does not have a modifier it is supposed to have a default access.If a top level class is declared as private the compiler will complain that the "modifier private is not allowed here". This means that a top level class can not be private. Same is the case with protected. Q: What type of parameter passing d

Java Interview questions-5

Question: What are the static fields & static Methods ? Answer: If a field or method defined as a static, there is only one copy for entire class, rather than one copy for each instance of class. static method cannot accecss non-static field or call non-static method Example static int counter = 0; A public static field or method can be accessed from outside the class using either the usual notation: Java-class-object.field-or-method-name or using the class name instead of the name of the class object: Java- class-name.field-or-method-name Question: What are the Final fields & Final Methods ? Answer: Fields and methods can also be declared final. A final method cannot be overridden in a subclass. A final field is like a constant: once it has been given a value, it cannot be assigned to again. Java Code private static final int MAXATTEMPTS = 10; Question: Describe the wrapper classes in Java ? Answer: Wrapper class is wrapper around a primitive data type .

Java Interview question -3

Question: How can i tell what state a thread is in ? Answer: Prior to java 5, isAlive() was commonly used to test a threads state. If isAlive() returned false the thread was either new or terminated but there was simply no way to differentiate between the two. Starting with the release of Tiger (Java 5) you can now get what state a thread is in by using the getState() method which returns an Enum of Thread.States. A thread can only be in one of the following states at a given point in time. NEW A Fresh thread that has not yet started to execute. RUNNABLE A thread that is executing in the Java virtual machine. BLOCKED A thread that is blocked waiting for a monitor lock. WAITING A thread that is wating to be notified by another thread. TIMED_WAITING A thread that is wating to be notified by another thread for a specific amount of time TERMINATED A thread whos run method

Java Interview questions-2

Ques: Which Container method is used to cause a container to be laid out and redisplayed? Ans: validate() Ques: How many times may an object's finalize() method be invoked by the garbage collector? Ans: An object's finalize() method may only be invoked once by the garbage collector. Q: What is an Iterator? A: Some of the collection classes provide traversal of their contents via a java.util.Iterator interface. This interface allows you to walk through a collection of objects, operating on each object in turn. Remember when using Iterators that they contain a snapshot of the collection at the time the Iterator was obtained; generally it is not advisable to modify the collection itself while traversing an Iterator. Q: 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. A: public : Public class is visible in other pack

Java Interview Questions -1

Q: What invokes a thread's run() method? Ans: After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed. Q: What is the purpose of garbage collection in Java, and when is it used? A: The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used. Question: What is the difference between the Boolean & operator and the && operator? Answer: If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second oper

Normalization

Image
If you've been working with databases for a while, chances are you've heard the term normalization. Perhaps someone's asked you "Is that database normalized?" or "Is that in BCNF?" All too often, the reply is "Uh, yeah." Normalization is often brushed aside as a luxury that only academics have time for. However, knowing the principles of normalization and applying them to your daily database design tasks really isn't all that complicated and it could drastically improve the performance of your DBMS. In this article, we'll introduce the concept of normalization and take a brief look at the most common normal forms. Future articles will provide in-depth explorations of the normalization process. What is Normalization? Normalization is the process of efficiently organizing data in a database. There are two goals of the normalization process: eliminating redundant data (for example, storing the same data in more than one

12 Codd's Rules

Codd has given 12 rules , which every database has to follow to become a relational dtabase. Rule 0: The system must qualify as relational , as a database , and as a management system . For a system to qualify as a relational database management system (RDBMS), it system must use its relational facilities (exclusively) to manage the database . Rule 1: The information rule : All information in the database is to be represented in one and only one way, namely by values in column positions within rows of tables. Rule 2: The guaranteed access rule : All data must be accessible. This rule is essentially a restatement of the fundamental requirement for primary keys. It says that every individual scalar value in the database must be logically addressable by specifying the name of the containing table, the name of the containing column and the primary key value of the containing row. Rule 3: Systematic treatment of null values : The DBMS must allow each field to remain null (or