Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

search topic

Showing posts with label Java Latest Interview Questions 2008. Show all posts
Showing posts with label Java Latest Interview Questions 2008. Show all posts

Monday, August 11, 2008

Java Latest Interview Questions and Answers 1 IMP interview questions

Basic Java interview questions

1. Why do you prefer Java?

Answer: write once ,run anywhere.

2. Name some of the classes which provide the functionality of collation?

Answer: collator, rulebased collator, collationkey, collationelement iterator.

3. Awt stands for? and what is it?

Answer: AWT stands for Abstract window tool kit. It is a is a package that provides an integrated set of classes to manage user interface components.

4. why a java program can not directly communicate with an ODBC driver?

Answer: Since ODBC API is written in C language and makes use of pointers which Java can not support.

5. Are servlets platform independent? If so Why? Also what is the most common application of servlets?

Answer: Yes, Because they are written in Java. The most common application of servlet is to access database and dynamically construct HTTP response

6.What is a Servlet?

Answer: Servlets are modules of Java code that run in a server application (hence the name "Servlets", similar to "Applets" on the client side) to answer client requests.

7.What advantages does CMOS have over TTL(transitor transitor logic)? (ALCATEL)

Answer:

*

low power dissipation
*

pulls up to rail
*

easy to interface

8.How is Java unlike C++? (Asked by Sun)

Some language features of C++ have been removed. String manipulations in Java do not allow for buffer overflows and other typical attacks. OS-specific calls are not advised, but you can still call native methods. Everything is a class in Java. Everything is compiled to Java bytecode, not executable (although that is possible with compiler tools).

9.What is HTML (Hypertext Markup Language)?

HTML (HyperText Markup Language) is the set of "markup" symbols or tags inserted in a file intended for display on a World Wide Web browser. The markup tells the Web browser how to display a Web page’s words and images for the user.

10.Define class.

Answer: A class describes a set of properties (primitives and objects) and behaviors (methods)

Java Latest Advanced Technical Questions - 2 IMP interview questions

Advanced Java interview questions

1.In Java, what is the difference between an Interface and an Abstract class?

A: An Abstract class declares have at least one instance method that is declared abstract which will be implemented by the subclasses. An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior.

2. Can you have virtual functions in Java? Yes or No. If yes, then what are virtual functions?

A: Yes, Java class functions are virtual by default. Virtual functions are functions of subclasses that can be invoked from a reference to their superclass. In other words, the functions of the actual object are called when a function is invoked on the reference to that object.

3.Write a function to reverse a linked list p in C++?

A:

Link* reverse_list(Link* p)
{
if (p == NULL)
return NULL;

Link* h = p;
p = p->next;
h->next = NULL;
while (p != null)
{
Link* t = p->next;
p->next = h;
h = p;
p = t;
}

return h;
}

4.In C++, what is the usefulness of Virtual destructors?

A:Virtual destructors are neccessary to reclaim memory that were allocated for objects in the class hierarchy. If a pointer to a base class object is deleted, then the compiler guarantees the various subclass destructors are called in reverse order of the object construction chain.

5.What are mutex and semaphore? What is the difference between them?

A:A mutex is a synchronization object that allows only one process or thread to access a critical code block. A semaphore on the other hand allows one or more processes or threads to access a critial code block. A semaphore is a multiple mutex

Java Latest / Recent Placement Paper questions and answers for programming / technical paper for leading IT Companies Infosys, Wipro, IBM, CISCO, Oracle, SAP, TCS, Satyam Computers, HCL, Microsoft, etc.

Java Enterprise Advanced Interview Questions - 3 IMP interview questions

Advanced enterprise Java interview questions

1) What is the purpose of garbage collection in Java, and when is it used?

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.

2) Describe synchronization in respect to multithreading.

With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchonization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors.

3) How is JavaBeans differ from Enterprise JavaBeans?

The JavaBeans architecture is meant to provide a format for general-purpose components. On the other hand, the Enterprise JavaBeans architecture provides a format for highly specialized business logic components.

4) In what ways do design patterns help build better software?

Design patterns helps software developers to reuse successful designs and architectures. It helps them to choose design alternatives that make a system reusuable and avoid alternatives that compromise reusability through proven techniques as design patterns.

5) Describe 3-Tier Architecture in enterprise application development.

In 3-tier architecture, an application is broken up into 3 separate logical layers, each with a well-defined set of interfaces. The presentation layer typically consists of a graphical user interfaces. The business layer consists of the application or business logic, and the data layer contains the data that is needed for the application.

Java Networking Technical Questions 4 IMP interview questions

Java and networking interview questions

1. What is a JavaBean? (asked by Lifescan inc)

ANSWER: JavaBeans are reusable software components written in the Java programming language, designed to be manipulated visually by a software develpoment environment, like JBuilder or VisualAge for Java. They are similar to Microsoft’s ActiveX components, but designed to be platform-neutral, running anywhere there is a Java Virtual Machine (JVM).

2. What are the seven layers(OSI model) of networking? (asked by Caspio.com)

ANSWER: 1.Physical, 2.Data Link, 3.Network, 4.Transport, 5.Session, 6.Presentation and 7.Application Layers.

3. What are some advantages and disadvantages of Java Sockets? (asked by Arashsoft.com)

ANSWER:
Advantages of Java Sockets:

Sockets are flexible and sufficient. Efficient socket based programming can be easily implemented for general communications.

Sockets cause low network traffic. Unlike HTML forms and CGI scripts that generate and transfer whole web pages for each new request, Java applets can send only necessary updated information.

Disadvantages of Java Sockets:

Security restrictions are sometimes overbearing because a Java applet running in a Web browser is only able to establish connections to the machine where it came from, and to nowhere else on the network

Despite all of the useful and helpful Java features, Socket based communications allows only to send packets of raw data between applications. Both the client-side and server-side have to provide mechanisms to make the data useful in any way.

Since the data formats and protocols remain application specific, the re-use of socket based implementations is limited.

4. What is the difference between a NULL pointer and a void pointer? (asked by Lifescan inc)

ANSWER: A NULL pointer is a pointer of any type whose value is zero. A void pointer is a pointer to an object of an unknown type, and is guaranteed to have enough bits to hold a pointer to any object. A void pointer is not guaranteed to have enough bits to point to a function (though in general practice it does).

5. What is encapsulation technique? (asked by Microsoft)

ANSWER: Hiding data within the class and making it available only through the methods. This technique is used to protect your class against accidental changes to fields, which might leave the class in an inconsistent state.

JSP Tech Interview Questions 5 IMP interview questions

JSP interview questions

1. What are the most common techniques for reusing functionality in object-oriented systems?
A: The two most common techniques for reusing functionality in object-oriented systems are class inheritance and object composition.

Class inheritance lets you define the implementation of one class in terms of another’s. Reuse by subclassing is often referred to as white-box reuse.
Object composition is an alternative to class inheritance. Here, new functionality is obtained by assembling or composing objects to get more complex functionality. This is known as black-box reuse.

2. Why would you want to have more than one catch block associated with a single try block in Java?
A: Since there are many things can go wrong to a single executed statement, we should have more than one catch(s) to catch any errors that might occur.

3. What language is used by a relational model to describe the structure of a database?
A: The Data Definition Language.

4. What is JSP? Describe its concept.
A: JSP is Java Server Pages. The JavaServer Page concept is to provide an HTML document with the ability to plug in content at selected locations in the document. (This content is then supplied by the Web server along with the rest of the HTML document at the time the document is downloaded).

5. What does the JSP engine do when presented with a JavaServer Page to process?
A: The JSP engine builds a servlet. The HTML portions of the JavaServer Page become Strings transmitted to print methods of a PrintWriter object. The JSP tag portions result in calls to methods of the appropriate JavaBean class whose output is translated into more calls to a println method to place the result in the HTML document

B.tech Freshers Technical Interview Java Software Questions 6 IMP interview questions

Java software engineering interview questions

1. What is the three tier model?
Answer: It is the presentation, logic, backend
2. Why do we have index table in the database?
Answer: Because the index table contain the information of the other tables. It will
be faster if we access the index table to find out what the other contain.
3. Give an example of using JDBC access the database.
Answer:
try
{
Class.forName("register the driver");
Connection con = DriverManager.getConnection("url of db", "username","password");
Statement state = con.createStatement();
state.executeUpdate("create table testing(firstname varchar(20), lastname varchar(20))");
state.executeQuery("insert into testing values(?phu?,'huynh?)");
state.close();
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
4. What is the different of an Applet and a Java Application
Answer: The applet doesn?t have the main function
5. How do we pass a reference parameter to a function in Java?
Answer: Even though Java doesn?t accept reference parameter, but we can
pass in the object for the parameter of the function.
For example in C++, we can do this:

void changeValue(int& a)
{
a++;
}
void main()
{
int b=2;
changeValue(b);
}

however in Java, we cannot do the same thing. So we can pass the
the int value into Integer object, and we pass this object into the
the function. And this function will change the object.

More Helpful Placement Question Papers Resources: Free download online recent and current year solved placement question papers 2008 of leading companies in India and Abroad. See More Latest and previous expert, common, basic, important, advanced questions asked in technical interviews for 2007, 2008 january, february, march, april, may, june, july, august, september, october, november, decemberfor leading IT Companies in India, USA, UK, Norway, China. Reputed MNCs testing job interview questions for Wipro, Infosys, TCS, Satyam Computers, HCL, IBM, Cisco, Microsoft, Keane, Flextronics, Accenture, Cognizant, T Systems, SAP, Oracle, Texas Instruments, Quark, Patni Computer Systems, Mastek, BT, Dell, BPO, ITES companies, Software Companies. Freshers and on campus interview held in delhi, mumbai, bangalore, chennai, madurai, noida, gurgaon, chandigarh, mohali, pune, hyderabad, kolkata, thane, ahmedabad, etc. Recent, latest reasoning, multiple choice questions, verbal, non verbal, mathematics questions with solutions / solved / answer keys, booklet. GD topics for leading campus placement interview, placement drive, HR Interview Questions and answers, how to behave, Tips, preparation, most recently asked / important software testing interview, java, oracle, c, c++, networking, web designing, windows 2000, vista, etc. questions. Keep Watching Previouspapers.blogspot.com for more stuff!

Core Java Questions IT Companies Interview - 7 IMP interview questions

Core Java interview questions

1. Can there be an abstract class with no abstract methods in it? - Yes

2. Can an Interface be final? - No
3. Can an Interface have an inner class? - Yes.

public interface abc
{
static int i=0; void dd();
class a1
{
a1()
{
int j;
System.out.println(\"inside\");
};
public static void main(String a1[])
{
System.out.println(\"in interfia\");

}
}
}

4. Can we define private and protected modifiers for variables in interfaces? - No
5. What is Externalizable? - Externalizable is an Interface that extends Serializable Interface. And sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal(ObjectInput in)
6. What modifiers are allowed for methods in an Interface? - Only public and abstract modifiers are allowed for methods in interfaces.
7. What is a local, member and a class variable? - Variables declared within a method are “local” variables. Variables declared within the class i.e not within any methods are “member” variables (global variables). Variables declared within the class i.e not within any methods and are defined as “static” are class variables
8. What are the different identifier states of a Thread? - The different identifiers of a Thread are: R - Running or runnable thread, S - Suspended thread, CW - Thread waiting on a condition variable, MW - Thread waiting on a monitor lock, MS - Thread suspended waiting on a monitor lock
9. What are some alternatives to inheritance? - Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance. It is often safer than inheritance because it forces you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn’t force you to accept all the methods of the super class: you can provide only the methods that really make sense. On the other hand, it makes you write more code, and it is harder to re-use (because it is not a subclass).
10. Why isn’t there operator overloading? - Because C++ has proven by example that operator overloading makes code almost impossible to maintain. In fact there very nearly wasn’t even method overloading in Java, but it was thought that this was too useful for some very basic methods like print(). Note that some of the classes like DataOutputStream have unoverloaded methods like writeInt() and writeByte().
11. What does it mean that a method or field is “static”? - Static variables and methods are instantiated only once per class. In other words they are class variables, not instance variables. If you change the value of a static variable in a particular object, the value of that variable changes for all instances of that class. Static methods can be referenced with the name of the class rather than the name of a particular object of the class (though that works too). That’s how library methods like System.out.println() work. out is a static field in the java.lang.System class.
12. How do I convert a numeric IP address like 192.18.97.39 into a hostname like java.sun.com?

String hostname =

InetAddress.getByName(\"192.18.97.39\").getHostName();

13. Difference between JRE/JVM/JDK?
14. Why do threads block on I/O? - Threads block on i/o (that is enters the waiting state) so that other threads may execute while the I/O operation is performed.
15. What is synchronization and why is it important? - With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object’s value. This often leads to significant errors.
16. Is null a keyword? - The null value is not a keyword.
17. Which characters may be used as the second character of an identifier,but not as the first character of an identifier? - The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.
18. What modifiers may be used with an inner class that is a member of an outer class? - A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.
19. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters? - Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.
20. What are wrapped classes? - Wrapped classes are classes that allow primitive types to be accessed as objects.
21. What restrictions are placed on the location of a package statement within a source code file? - A package statement must appear as the first line in a source code file (excluding blank lines and comments).
22. What is the difference between preemptive scheduling and time slicing? - Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.
23. What is a native method? - A native method is a method that is implemented in a language other than Java.
24. What are order of precedence and associativity, and how are they used? - Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to-right or right-to-left
25. What is the catch or declare rule for method declarations? - If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.
26. Can an anonymous class be declared as implementing an interface and extending a class? - An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.
27. What is the range of the char type? - The range of the char type is 0 to 2^16 - 1.

Java Developers Technical Interview - 8 IMP interview questions

Interview questions for Java junior developer position
What gives Java its “write once and run anywhere” nature? - Java is compiled to be a byte code which is the intermediate language between source code and machine code. This byte code is not platorm specific and hence can be fed to any platform. After being fed to the JVM, which is specific to a particular operating system, the code platform specific machine code is generated thus making java platform independent.

What are the four corner stones of OOP? - Abstraction, Encapsulation, Polymorphism and Inheritance.


Difference between a Class and an Object? - A class is a definition or prototype whereas an object is an instance or living representation of the prototype.

What is the difference between method overriding and overloading? - Overriding is a method with the same name and arguments as in a parent, whereas overloading is the same method name but different arguments.

What is a “stateless” protocol? - Without getting into lengthy debates, it is generally accepted that protocols like HTTP are stateless i.e. there is no retention of state between a transaction which is a single request response combination.

What is constructor chaining and how is it achieved in Java? - A child object constructor always first needs to construct its parent (which in turn calls its parent constructor.). In Java it is done via an implicit call to the no-args constructor as the first statement.

What is passed by ref and what by value? - All Java method arguments are passed by value. However, Java does manipulate objects by reference, and all object variables themselves are references

Can RMI and Corba based applications interact? - Yes they can. RMI is available with IIOP as the transport protocol instead of JRMP.

You can create a String object as String str = “abc”; Why cant a button object be created as Button bt = “abc”;? Explain - The main reason you cannot create a button by Button bt1= “abc”; is because “abc” is a literal string (something slightly different than a String object, by the way) and bt1 is a Button object. The only object in Java that can be assigned a literal String is java.lang.String. Important to note that you are NOT calling a java.lang.String constuctor when you type String s = “abc”;

What does the “abstract” keyword mean in front of a method? A class? - Abstract keyword declares either a method or a class. If a method has a abstract keyword in front of it,it is called abstract method.Abstract method hs no body.It has only arguments and return type.Abstract methods act as placeholder methods that are implemented in the subclasses. Abstract classes can’t be instantiated.If a class is declared as abstract,no objects of that class can be created.If a class contains any abstract method it must be declared as abstract.

How many methods do u implement if implement the Serializable Interface? - The Serializable interface is just a “marker” interface, with no methods of its own to implement. Other ‘marker’ interfaces are

java.rmi.Remote
java.util.EventListener

What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. import java.net.* versus import java.net.Socket)? - It makes no difference in the generated class files since only the classes that are actually used are referenced by the generated class file. There is another practical benefit to importing single classes, and this arises when two (or more) packages have classes with the same name. Take java.util.Timer and javax.swing.Timer, for example. If I import java.util.* and javax.swing.* and then try to use “Timer”, I get an error while compiling (the class name is ambiguous between both packages). Let’s say what you really wanted was the javax.swing.Timer class, and the only classes you plan on using in java.util are Collection and HashMap. In this case, some people will prefer to import java.util.Collection and import java.util.HashMap instead of importing java.util.*. This will now allow them to use Timer, Collection, HashMap, and other javax.swing classes without using fully qualified class names in.

What is the difference between logical data independence and physical data independence? - Logical Data Independence - meaning immunity of external schemas to changeds in conceptual schema. Physical Data Independence - meaning immunity of conceptual schema to changes in the internal schema.

What is a user-defined exception? - Apart from the exceptions already defined in Java package libraries, user can define his own exception classes by extending Exception class.

Describe the visitor design pattern? - Represents an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates. The root of a class hierarchy defines an abstract method to accept a visitor. Subclasses implement this method with visitor.visit(this). The Visitor interface has visit methods for all subclasses of the baseclass in the hierarchy.



16.What are the advantages of OOPL?

Ans: Object oriented programming languages directly represent the real life objects. The features of OOPL as inhreitance, polymorphism, encapsulation makes it powerful.

17. What do mean by polymorphisum, inheritance, encapsulation?

Ans: Polymorhisum: is a feature of OOPl that at run time depending upon the type of object the appropriate method is called.
Inheritance: is a feature of OOPL that represents the "is a" relationship between different objects(classes). Say in real life a manager is a employee. So in OOPL manger class is inherited from the employee class.
Encapsulation: is a feature of OOPL that is used to hide the information.

18. What do you mean by static methods?

Ans: By using the static method there is no need creating an object of that class to use that method. We can directly call that method on that class. For example, say class A has static function f(), then we can call f() function as A.f(). There is no need of creating an object of class A.

19. What do you mean by virtual methods?

Ans: virtual methods are used to use the polymorhism feature in C++. Say class A is inherited from class B. If we declare say fuction f() as virtual in class B and override the same function in class A then at runtime appropriate method of the class will be called depending upon the type of the object.

20. Given two tables Student(SID, Name, Course) and Level(SID, level) write the SQL statement to get the name and SID of the student who are taking course = 3 and at freshman level.

Ans: SELECT Student.name, Student.SID
FROM Student, Level
WHERE Student.SID = Level.SID
AND Level.Level = "freshman"
AND Student.Course = 3;

21. What are the disadvantages of using threads?

Ans: DeadLock.


22. Write the Java code to declare any constant (say gravitational constant) and to get its value

Ans: Class ABC
{
static final float GRAVITATIONAL_CONSTANT = 9.8;
public void getConstant()
{
system.out.println("Gravitational_Constant: " + GRAVITATIONAL_CONSTANT);
}
}
23. What do you mean by multiple inheritance in C++ ?

Ans: Multiple inheritance is a feature in C++ by which one class can be of different types. Say class teachingAssistant is inherited from two classes say teacher and Student.

24. Can you write Java code for declaration of multiple inheritance in Java ?

Ans: Class C extends A implements B
{
}

Java Tutorials - Free Technical Questions 9 Large collection of Java interview questions

Large collection of Java interview questions

1.

What is the difference between an Abstract class and Interface ?
2.

What is user defined exception ?
3.

What do you know about the garbage collector ?

4.

What is the difference between C++ & Java ?
5.

Explain RMI Architecture?
6.

How do you communicate in between Applets & Servlets ?
7.

What is the use of Servlets ?
8.

What is JDBC? How do you connect to the Database ?
9.

In an HTML form I have a Button which makes us to open another page in 15 seconds. How will do you that ?
10.

What is the difference between Process and Threads ?
11.

What is the difference between RMI & Corba ?
12.

What are the services in RMI ?
13.

How will you initialize an Applet ?
14.

What is the order of method invocation in an Applet ?
15.

When is update method called ?
16.

How will you pass values from HTML page to the Servlet ?
17.

Have you ever used HashTable and Dictionary ?
18.

How will you communicate between two Applets ?
19.

What are statements in JAVA ?
20.

What is JAR file ?
21.

What is JNI ?
22.

What is the base class for all swing components ?
23.

What is JFC ?
24.

What is Difference between AWT and Swing ?
25.

Considering notepad/IE or any other thing as process, What will happen if you start notepad or IE 3 times? Where 3 processes are started or 3 threads are started ?
26.

How does thread synchronization occurs inside a monitor ?
27.

How will you call an Applet using a Java Script function ?
28.

Is there any tag in HTML to upload and download files ?
29.

Why do you Canvas ?
30.

How can you push data from an Applet to Servlet ?
31.

What are 4 drivers available in JDBC ?
32.

How you can know about drivers and database information ?
33.

If you are truncated using JDBC, How can you know ..that how much data is truncated ?
34.

And What situation , each of the 4 drivers used ?
35.

How will you perform transaction using JDBC ?
36.

In RMI, server object first loaded into the memory and then the stub reference is sent to the client ? or whether a stub reference is directly sent to the client ?
37.

Suppose server object is not loaded into the memory, and the client request for it , what will happen?
38.

What is serialization ?
39.

Can you load the server object dynamically? If so, what are the major 3 steps involved in it ?
40.

What is difference RMI registry and OSAgent ?
41.

To a server method, the client wants to send a value 20, with this value exceeds to 20,. a message should be sent to the client ? What will you do for achieving for this ?
42.

What are the benefits of Swing over AWT ?
43.

Where the CardLayout is used ?
44.

What is the Layout for ToolBar ?
45.

What is the difference between Grid and GridbagLayout ?
46.

How will you add panel to a Frame ?
47.

What is the corresponding Layout for Card in Swing ?
48.

What is light weight component ?
49.

Can you run the product development on all operating systems ?
50.

What is the webserver used for running the Servlets ?
51.

What is Servlet API used for connecting database ?
52.

What is bean ? Where it can be used ?
53.

What is difference in between Java Class and Bean ?
54.

Can we send object using Sockets ?
55.

What is the RMI and Socket ?
56.

How to communicate 2 threads each other ?
57.

What are the files generated after using IDL to Java Compilet ?

More of our resources: Free download online recent and current year solved placement question papers 2008 of leading companies in India and Abroad. See More Latest and previous expert, common, basic, important, advanced questions asked in technical interviews for 2007, 2008 january, february, march, april, may, june, july, august, september, october, november, decemberfor leading IT Companies in India, USA, UK, Norway, China. Reputed MNCs testing job interview questions for Wipro, Infosys, TCS, Satyam Computers, HCL, IBM, Cisco, Microsoft, Keane, Flextronics, Accenture, Cognizant, T Systems, SAP, Oracle, Texas Instruments, Quark, Patni Computer Systems, Mastek, BT, Dell, BPO, ITES companies, Software Companies. Freshers and on campus interview held in delhi, mumbai, bangalore, chennai, madurai, noida, gurgaon, chandigarh, mohali, pune, hyderabad, kolkata, thane, ahmedabad, etc. Recent, latest reasoning, multiple choice questions, verbal, non verbal, mathematics questions with solutions / solved / answer keys, booklet. GD topics for leading campus placement interview, placement drive, HR Interview Questions and answers, how to behave, Tips, preparation, most recently asked / important software testing interview, free tutorials for java, oracle, c, c++, networking, web designing, windows 2000, vista, etc. questions. Keep Watching Previouspapers.blogspot.com for more stuff!

Java Servlets Basic Technical Interview Questions 10 IMP interview questions

Basic Java servlet interview questions

1.

What is the difference between CGI and Servlet?
2.

What is meant by a servlet?

3.

What are the types of servlets? What is the difference between 2 types of Servlets?
4.

What is the type of method for sending request from HTTP server ?
5.

What are the exceptions thrown by Servlets? Why?
6.

What is the life cycle of a servlet?
7.

What is meant by cookies? Why is Cookie used?
8.

What is HTTP Session?
9.

What is the difference between GET and POST methods?
10.

How can you run a Servlet Program?
11.

What is the middleware? What is the functionality of Webserver?
12.

What webserver is used for running the Servlets?
13.

How do you invoke a Servelt? What is the difference in between doPost and doGet methods?
14.

What is the difference in between the HTTPServlet and Generic Servlet? Explain their methods? Tell me their parameter names also?
15.

What are session variable in Servlets?
16.

What is meant by Session? Tell me something about HTTPSession Class?
17.

What is Session Tracking?
18.

Difference between doGet and doPost?
19.

What are the methods in HttpServlet?
20.

What are the types of SessionTracking? Why do you use Session Tracking in HttpServlet?

Java Latest / Recent Placement Paper questions and answers for programming / technical paper for leading IT Companies Infosys, Wipro, IBM, CISCO, Oracle, SAP, TCS, Satyam Computers, HCL, Microsoft, Ramco, Cognizant, Verizon, Cingular, Patni, Capegemini, Quark, Keane, Mastek, Ebay, etc.

Java free Interview Questions With Solutions 11 IMP interview questions

Java interview questions

1.

What is a class? A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind.
2.

What is a object? An object is a software bundle of variables and related methods.An instance of a class depicting the state and behavior at that particular time in real world.
3.

What is a method? Encapsulation of a functionality which can be called to perform specific tasks.
4.

What is encapsulation? Explain with an example. Encapsulation is the term given to the process of hiding the implementation details of the object. Once an object is encapsulated, its implementation details are not immediately accessible any more. Instead they are packaged and are only indirectly accessible via the interface of the object
5.

What is inheritance? Explain with an example. Inheritance in object oriented programming means that a class of objects can inherit properties and methods from another class of objects.
6.

What is polymorphism? Explain with an example. In object-oriented programming, polymorphism refers to a programming language’s ability to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes. For example, given a base class shape, polymorphism enables the programmer to define different area methods for any number of derived classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the area method to it will return the correct results. Polymorphism is considered to be a requirement of any true object-oriented programming language
7.

Is multiple inheritance allowed in Java? No, multiple inheritance is not allowed in Java.
8.

What is interpreter and compiler? Java interpreter converts the high level language code into a intermediate form in Java called as bytecode, and then executes it, where as a compiler converts the high level language code to machine language making it very hardware specific
9.

What is JVM? The Java interpreter along with the runtime environment required to run the Java application in called as Java virtual machine(JVM)
10.

What are the different types of modifiers? There are access modifiers and there are other identifiers. Access modifiers are public, protected and private. Other are final and static.
11.

What are the access modifiers in Java? There are 3 access modifiers. Public, protected and private, and the default one if no identifier is specified is called friendly, but programmer cannot specify the friendly identifier explicitly.
12.

What is a wrapper class? They are classes that wrap a primitive data type so it can be used as a object
13.

What is a static variable and static method? What’s the difference between two? The modifier static can be used with a variable and method. When declared as static variable, there is only one variable no matter how instances are created, this variable is initialized when the class is loaded. Static method do not need a class to be instantiated to be called, also a non static method cannot be called from static method.
14.

What is garbage collection? Garbage Collection is a thread that runs to reclaim the memory by destroying the objects that cannot be referenced anymore.
15.

What is abstract class? Abstract class is a class that needs to be extended and its methods implemented, aclass has to be declared abstract if it has one or more abstract methods.
16.

What is meant by final class, methods and variables? This modifier can be applied to class method and variable. When declared as final class the class cannot be extended. When declared as final variable, its value cannot be changed if is primitive value, if it is a reference to the object it will always refer to the same object, internal attributes of the object can be changed.
17.

What is interface? Interface is a contact that can be implemented by a class, it has method that need implementation.
18.

What is method overloading? Overloading is declaring multiple method with the same name, but with different argument list.
19.

What is method overriding? Overriding has same method name, identical arguments used in subclass.
20.

What is singleton class? Singleton class means that any given time only one instance of the class is present, in one JVM.
21.

What is the difference between an array and a vector? Number of elements in an array are fixed at the construction time, whereas the number of elements in vector can grow dynamically.
22.

What is a constructor? In Java, the class designer can guarantee initialization of every object by providing a special method called a constructor. If a class has a constructor, Java automatically calls that constructor when an object is created, before users can even get their hands on it. So initialization is guaranteed.
23.

What is casting? Conversion of one type of data to another when appropriate. Casting makes explicitly converting of data.
24.

What is the difference between final, finally and finalize? The modifier final is used on class variable and methods to specify certain behaviour explained above. And finally is used as one of the loop in the try catch blocks, It is used to hold code that needs to be executed whether or not the exception occurs in the try catch block. Java provides a method called finalize( ) that can be defined in the class. When the garbage collector is ready to release the storage ed for your object, it will first call finalize( ), and only on the next garbage-collection pass will it reclaim the objects memory. So finalize( ), gives you the ability to perform some important cleanup at the time of garbage collection.
25.

What is are packages? A package is a collection of related classes and interfaces providing access protection and namespace management.
26.

What is a super class and how can you call a super class? When a class is extended that is derived from another class there is a relationship is created, the parent class is referred to as the super class by the derived class that is the child. The derived class can make a call to the super class using the keyword super. If used in the constructor of the derived class it has to be the first statement.
27.

What is meant by a Thread? Thread is defined as an instantiated parallel process of a given program.
28.

What is multi-threading? Multi-threading as the name suggest is the scenario where more than one threads are running.
29.

What are two ways of creating a thread? Which is the best way and why? Two ways of creating threads are, one can extend from the Java.lang.Thread and can implement the rum method or the run method of a different class can be called which implements the interface Runnable, and the then implement the run() method. The latter one is mostly used as first due to Java rule of only one class inheritance, with implementing the Runnable interface that problem is sorted out.
30.

What is deadlock? Deadlock is a situation when two threads are waiting on each other to release a resource. Each thread waiting for a resource which is held by the other waiting thread. In Java, this resource is usually the object lock obtained by the synchronized keyword.
31.

What are the three types of priority? MAX_PRIORITY which is 10, MIN_PRIORITY which is 1, NORM_PRIORITY which is 5.
32.

What is the use of synchronizations? Every object has a lock, when a synchronized keyword is used on a piece of code the, lock must be obtained by the thread first to execute that code, other threads will not be allowed to execute that piece of code till this lock is released.

Java Lanugage Interview Questions 12 IMP interview questions

Java interview questions

1.

What is the Collections API? - The Collections API is a set of classes and interfaces that support operations on collections of objects
2.

What is the List interface? - The List interface provides support for ordered collections of objects.

3.

What is the Vector class? - The Vector class provides the capability to implement a growable array of objects
4.

What is an Iterator interface? - The Iterator interface is used to step through the elements of a Collection
5.

Which java.util classes and interfaces support event handling? - The EventObject class and the EventListener interface support event processing
6.

What is the GregorianCalendar class? - The GregorianCalendar provides support for traditional Western calendars
7.

What is the Locale class? - The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region
8.

What is the SimpleTimeZone class? - The SimpleTimeZone class provides support for a Gregorian calendar
9.

What is the Map interface? - The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values
10.

What is the highest-level event class of the event-delegation model? - The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy
11.

What is the Collection interface? - The Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates
12.

What is the Set interface? - The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements
13.

What is the purpose of the enableEvents() method? - The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.
14.

What is the ResourceBundle class? - The ResourceBundle class is used to store locale-specific resources that can be loaded by a program to tailor the program’s appearance to the particular locale in which it is being run.
15.

What is the difference between yielding and sleeping? - When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.
16.

When a thread blocks on I/O, what state does it enter? - A thread enters the waiting state when it blocks on I/O.
17.

When a thread is created and started, what is its initial state? - A thread is in the ready state after it has been created and started.
18.

What invokes a thread’s run() method? - 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.
19.

What method is invoked to cause an object to begin executing as a separate thread? - The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.
20.

What is the purpose of the wait(), notify(), and notifyAll() methods? - The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object’s wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object’s notify() or notifyAll() methods.
21.

What are the high-level thread states? - The high-level thread states are ready, running, waiting, and dead
22.

What happens when a thread cannot acquire a lock on an object? - If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object’s lock, it enters the waiting state until the lock becomes available.
23.

How does multithreading take place on a computer with a single CPU? - The operating system’s task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.
24.

What happens when you invoke a thread’s interrupt method while it is sleeping or waiting? - When a task’s interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown.
25.

What state is a thread in when it is executing? - An executing thread is in the running state
26.

What are three ways in which a thread can enter the waiting state? - A thread can enter the waiting state by invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object’s lock, or by invoking an object’s wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.
27.

What method must be implemented by all threads? - All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.
28.

What are the two basic ways in which classes that can be run as threads may be defined? - A thread class may be declared as a subclass of Thread, or it may implement the Runnable interface.
29.

How can you store international / Unicode characters into a cookie? - One way is, before storing the cookie URLEncode it. URLEnocder.encoder(str); And use URLDecoder.decode(str) when you get the stored cookie.

The latest java language Questions asked in Technical Interviews of Oracle, SAP, Peoplesoft, Sun Microsystems, CISCO India, Infosys, Wipro, TCS, IBM, etc. with solutions for years 2007, 2008. Fully detailed answers of recent tech interview questions

Java free explanations, basic and advanced questions 13 IMP interview questions

Java interview questions

1.

What are synchronized methods and synchronized statements? Synchronized methods are methods that are used to control access to an object. For example, a thread only executes a synchronized method after it has acquired the lock for the method’s object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.
2.

What are different ways in which a thread can enter the waiting state? A thread can enter the waiting state by invoking its sleep() method, blocking on I/O, unsuccessfully attempting to acquire an object’s lock, or invoking an object’s wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.
3.

Can a lock be acquired on a class? Yes, a lock can be acquired on a class. This lock is acquired on the class’s Class object.
4.

What’s new with the stop(), suspend() and resume() methods in new JDK 1.2? The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.
5.

What is the preferred size of a component? The preferred size of a component is the minimum component size that will allow the component to display normally.
6.

What method is used to specify a container’s layout? The setLayout() method is used to specify a container’s layout. For example, setLayout(new FlowLayout()); will be set the layout as FlowLayout.
7.

Which containers use a FlowLayout as their default layout? The Panel and Applet classes use the FlowLayout as their default layout.
8.

What state does a thread enter when it terminates its processing? When a thread terminates its processing, it enters the dead state.
9.

What is the Collections API? The Collections API is a set of classes and interfaces that support operations on collections of objects. One example of class in Collections API is Vector and Set and List are examples of interfaces in Collections API.
10.

What is the List interface? The List interface provides support for ordered collections of objects. It may or may not allow duplicate elements but the elements must be ordered.
11.

How does Java handle integer overflows and underflows? It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.
12.

What is the Vector class? The Vector class provides the capability to implement a growable array of objects. The main visible advantage of this class is programmer needn’t to worry about the number of elements in the Vector.
13.

What modifiers may be used with an inner class that is a member of an outer class? A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.
14.

If a method is declared as protected, where may the method be accessed? A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.
15.

What is an Iterator interface? The Iterator interface is used to step through the elements of a Collection.
16.

How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters? Unicode requires 16 bits, ASCII require 7 bits (although the ASCII character set uses only 7 bits, it is usually represented as 8 bits), UTF-8 represents characters using 8, 16, and 18 bit patterns, UTF-16 uses 16-bit and larger bit patterns
17.

What is the difference between yielding and sleeping? Yielding means a thread returning to a ready state either from waiting, running or after creation, where as sleeping refers a thread going to a waiting state from running state. With reference to Java, when a task invokes its yield() method, it returns to the ready state and when a task invokes its sleep() method, it returns to the waiting state
18.

What are wrapper classes? Wrapper classes are classes that allow primitive types to be accessed as objects. For example, Integer, Double. These classes contain many methods which can be used to manipulate basic data types
19.

Does garbage collection guarantee that a program will not run out of memory? No, it doesn’t. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection. The main purpose of Garbage Collector is recover the memory from the objects which are no longer required when more memory is needed.
20.

Name Component subclasses that support painting? The following classes support painting: Canvas, Frame, Panel, and Applet.
21.

What is a native method? A native method is a method that is implemented in a language other than Java. For example, one method may be written in C and can be called in Java.
22.

How can you write a loop indefinitely?

for(;;) //for loop
while(true); //always true

23.

Can an anonymous class be declared as implementing an interface and extending a class? An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.
24.

What is the purpose of finalization? The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected. For example, closing a opened file, closing a opened database Connection.
25.

What invokes a thread’s run() method? 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.
26.

What is the GregorianCalendar class? The GregorianCalendar provides support for traditional Western calendars.
27.

What is the SimpleTimeZone class? The SimpleTimeZone class provides support for a Gregorian calendar.
28.

What is the Properties class? The properties class is a subclass of Hashtable that can be read from or written to a stream. It also provides the capability to specify a set of default values to be used.
29.

What is the purpose of the Runtime class? The purpose of the Runtime class is to provide access to the Java runtime system.
30.

What is the purpose of the System class? The purpose of the System class is to provide access to system resources.
31.

What is the purpose of the finally clause of a try-catch-finally statement? The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught. For example,

try
{
//some statements
}
catch
{
// statements when exception is cought
}
finally
{
//statements executed whether exception occurs or not
}

32.

What is the Locale class? The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.
33.

What must a class do to implement an interface? It must provide all of the methods in the interface and identify the interface in its implements clause.

Java on Oracle Technical Interview 2008 IMP interview questions

Java on Oracle interview questions

1.

What is JServer and what is it used for? Oracle JServer Option is a Java Virtual Machine (Java VM) which runs within the Oracle database server’s address space. Oracle also provides a JServer Accelerator to compile Java code natively. This speeds up the execution of Java code by eliminating interpreter overhead.
2.

How does one install the Oracle JServer Option?Follow these steps to activate the Oracle JServer/ JVM option:
1.

Make sure your database is started with large java_pool_size (>20M) and shared_pool_size (>50M) INIT.ORA parameter values.
2.

Run the $ORACLE_HOME/javavm/install/initjvm.sql script from SYS AS SYSDBA to install the Oracle JServer Option on a database.
3.

Grant JAVAUSERPRIV to users that wants to use Java:
SQL> GRANT JAVAUSERPRIV TO SCOTT;

4.

The rmjvm.sql script can be used to deinstall the JServer option from your database.
5.

Follow the steps in the Oracle Migrations Guide to upgrade or downgrade the JServer option from one release to
another.
3.

source code into the database? Use the “CREATE OR REPLACE JAVA SOURCE” command or “loadjava” utility. Loaded code can be viewed by selecting from the USER_SOURCE view.
4.

Why does one need to publish Java in the database? Publishing Java classes on the database makes it visible on a SQL and PL/SQL level. It is important to publish your code before calling it from SQL statements or PL/SQL code.
5.

What is JDBC and what is it used for? JDBC is a set of classes and interfaces written in Java to allow other Java programs to send SQL statements to a relational database management system. Oracle provides three categories of JDBC drivers: (a) JDBC Thin Driver (No local Net8 installation required/ handy for applets), (b) JDBC OCI for writing stand-alone Java applications, (c) JDBC KPRB driver (default connection) for Java Stored Procedures and Database JSP’s.
6.

How does one connect with the JDBC Thin Driver?
The the JDBC thin driver provides the only way to access Oracle from the Web (applets). It is smaller and faster than the OCI drivers, and doesn’t require a pre-installed version of the JDBC drivers.

import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException
{
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

Connection conn = DriverManager.getConnection
(\"jdbc:oracle:thin:@hostname:1526:orcl\", \"scott\", \"tiger\");
// @machineName:port:SID, userid, password

Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(\"select BANNER from SYS.V_$VERSION\");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();
}
}

7.

How does one connect with the JDBC OCI Driver? One must have Net8 (SQL*Net) installed and working before attempting to use one of the OCI drivers.

import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException
{
try {
Class.forName (\"oracle.jdbc.driver.OracleDriver\");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

Connection conn = DriverManager.getConnection
(\"jdbc:oracle:oci8:@hostname_orcl\", \"scott\", \"tiger\");
// or oci7 @TNSNames_Entry, userid, password

Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(\"select BANNER from SYS.V_$VERSION\");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();
}
}

8.

How does one connect with the JDBC KPRB Driver? One can obtain a handle to the default or current connection (KPRB driver) by calling the OracleDriver.defaultConenction() method. Please note that you do not need to specify a database URL, username or password as you are already connected to a database session. Remember not to close the default connection. Closing the default connection might throw an exception in future releases of Oracle.

import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException
{
Connection conn = (new oracle.jdbc.driver.OracleDriver()).defaultConnection();

Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery(\"select BANNER from SYS.V_$VERSION\");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();
}
}

9.

What is SQLJ and what is it used for? SQLJ is an ANSI standard way of coding SQL access in Java. It provides a Java precompiler that translates SQLJ call to JDBC calls. The idea is similar to that of other Oracle Precompilers.
10.

How does one deploy SQLJ programs? Use the sqlj compiler to compile your *.sqlj files to *.java and *.ser files. The *.ser files contain vendor specific database code. Thereafter one invokes the javac compiler to compile the .java files to *.class files. The *.class and *.ser files needs to be deployed.
11.

What is JDeveloper and what is it used for? JDeveloper is the Oracle IDE (Integrated Development Environment) for developing SQLJ and JDBC programs, applets, stored procedures, EJB’s, JSP’s etc.
12.

What is InfoBus DAC and what is it used for? InfoBus DAC (Data Aware Controls) is a standard Java extension used in JDeveloper to create data aware forms. It replaced the JBCL interface that were used in JDeveloper V1 and V2.
13.

What is a JSP and what is it used for? Java Server Pages (JSP) is a platform independent presentation layer technology that comes with SUN’s J2EE platform. JSPs are normal HTML pages with Java code pieces embedded in them. JSP pages are saved to *.jsp files. A JSP compiler is used in the background to generate a Servlet from the JSP page.
14.

What is the difference between ASP and JSP? Active Server Pages (ASP) is a Microsoft standard, which is easier to develop than Java Server Pages (JSP). However ASP is a proprietary technology and is less flexible than JSP. For more information about ASP, see the Oracle ASP FAQ.
15.

How does one invoke a JSP? A JSP gets invoked when you call a *.jsp file from your Web Server like you would call a normal *.html file. Obviously your web server need to support JSP pages and must be configured properly to handle them.
16.

How does a JSP gets executed? The first time you call a JSP, a servlet (*.java) will be created and compiled to a .class file. The class file is then executed on the server. Output produced by the servlet is returned to the web browser. Output will typically be HTML or XML code.
17.

What is a Java Stored Procedure/ Trigger? A Java Stored Procedure is a procedure coded in Java (as opposed to PL/SQL) and stored in the Oracle database. Java Stored procedures are executed by the database JVM in database memory space. Java Stored Procedures can be developed in JDBC or SQLJ. Interfacing between PL/SQL and Java are extremely easy. Please note that Java Stored procedures are by default executed with invokers rights. PL/SQL procedures are by default executed with defines rights.

See more Java Language latest basic and advanced expert questions and answers / solutions to java programs and free tutorials for admission / technical interview selection to various reputed IT Companies and institutions / colleges. Test your java knowledge - answer these questions for 2007 and 2008 provided by real candidates.. Good Luck. Keep watching PreviousPapers.blogspot.com for more free technical and HR Interview Questions.

Java Applets Technical Interview Test Questions 15 IMP interview questions

1.

What is an Applet? Should applets have constructors?
- Applets are small programs transferred through Internet, automatically installed and run as part of web-browser. Applets implements functionality of a client. Applet is a dynamic and interactive program that runs inside a Web page displayed by a Java-capable browser. We don’t have the concept of Constructors in Applets. Applets can be invoked either through browser or through Appletviewer utility provided by JDK.
2.

What are the Applet’s Life Cycle methods? Explain them? - Following are methods in the life cycle of an Applet:
*

init() method - called when an applet is first loaded. This method is called only once in the entire cycle of an applet. This method usually intialize the variables to be used in the applet.
*

start( ) method - called each time an applet is started.
*

paint() method - called when the applet is minimized or refreshed. This method is used for drawing different strings, figures, and images on the applet window.
*

stop( ) method - called when the browser moves off the applet’s page.
*

destroy( ) method - called when the browser is finished with the applet.

3.

What is the sequence for calling the methods by AWT for applets? - When an applet begins, the AWT calls the following methods, in this sequence:
*

init()
*

start()
*

paint()

When an applet is terminated, the following sequence of method calls takes place :
*

stop()
*

destroy()
4.

How do Applets differ from Applications? - Following are the main differences: Application: Stand Alone, doesn’t need
web-browser. Applet: Needs no explicit installation on local machine. Can be transferred through Internet on to the local machine and may run as part of web-browser. Application: Execution starts with main() method. Doesn’t work if main is not there. Applet: Execution starts with init() method. Application: May or may not be a GUI. Applet: Must run within a GUI (Using AWT). This is essential feature of applets.
5.

Can we pass parameters to an applet from HTML page to an applet? How? - We can pass parameters to an applet using Access those parameters inside the applet is done by calling getParameter() method inside the applet. Note that getParameter() method returns String value corresponding to the parameter name.
#

How do we read number information from my applet’s parameters, given that Applet’s getParameter() method returns a string?
- Use the parseInt() method in the Integer Class, the Float(String) constructor or parseFloat() method in the Class Float, or the
Double(String) constructor or parseDoulbl() method in the class Double.
#

How can I arrange for different applets on a web page to communicate with each other?
- Name your applets inside the Applet tag and invoke AppletContext’s getApplet() method in your applet code to obtain references to the
other applets on the page.
#

How do I select a URL from my Applet and send the browser to that page? - Ask the applet for its applet context and invoke showDocument() on that context object.

URL targetURL;
String URLString
AppletContext context = getAppletContext();
try
{
targetURL = new URL(URLString);
}
catch (MalformedURLException e)
{
// Code for recover from the exception
}
context. showDocument (targetURL);

#

Can applets on different pages communicate with each other?
- No, Not Directly. The applets will exchange the information at one meeting place either on the local file system or at remote system.
#

How do I determine the width and height of my application?
- Use the getSize() method, which the Applet class inherits from the Component class in the Java.awt package. The getSize() method returns the size of the applet as a Dimension object, from which you extract separate width, height fields. The following code snippet explains this:

Dimension dim = getSize();
int appletwidth = dim.width();
int appletheight = dim.height();

#

Which classes and interfaces does Applet class consist? - Applet class consists of a single class, the Applet class and three interfaces: AppletContext, AppletStub, and AudioClip.
#

What is AppletStub Interface?
- The applet stub interface provides the means by which an applet and the browser communicate. Your code will not typically implement this interface.
#

What tags are mandatory when creating HTML to display an applet?

1.

name, height, width
2.

code, name
3.

codebase, height, width
4.

code, height, width

Correct answer is d.
#

What are the Applet’s information methods?
- The following are the Applet’s information methods: getAppletInfo() method: Returns a string describing the applet, its author, copyright information, etc. getParameterInfo( ) method: Returns an array of string describing the applet’s parameters.
#

What are the steps involved in Applet development? - Following are the steps involved in Applet development:

*

Create/Edit a Java source file. This file must contain a class which extends Applet class.
*

Compile your program using javac
*

Execute the appletviewer, specifying the name of your applet’s source file or html file. In case the applet information is stored in html file then Applet can be invoked using java enabled web browser.

#

Which method is used to output a string to an applet? Which function is this method included in? - drawString( ) method is used to output a string to an applet. This method is included in the paint method of the Applet.

Java AWT Tutorials / Technical Interview Question Solutions 2008 IMP interview questions

Java AWT interview questions

1.

What is meant by Controls and what are different types of controls? - Controls are componenets that allow a user to interact with your application. The AWT supports the following types of controls:
*

Labels
*

Push buttons
*

Check boxes
*

Choice lists
*

Lists
*

Scroll bars
*

Text components

These controls are subclasses of Component.
2.

Which method of the component class is used to set the position and the size of a component? - setBounds(). The following code snippet explains this:

txtName.setBounds(x,y,width,height);

places upper left corner of the text field txtName at point (x,y) with the width and height of the text field set as width and height.
3.

Which TextComponent method is used to set a TextComponent to the read-only state? - setEditable()
4.

How can the Checkbox class be used to create a radio button? - By associating Checkbox objects with a CheckboxGroup.
5.

What methods are used to get and set the text label displayed by a Button object? - getLabel( ) and setLabel( )
6.

What is the difference between a Choice and a List? - Choice: A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. List: A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.
7.

What is the difference between a Scollbar and a Scrollpane? - A Scrollbar is a Component, but not a Container. A Scrollpane is a Container and handles its own events and performs its own scrolling.
8.

Which are true about the Container class?
*

The validate( ) method is used to cause a Container to be laid out and redisplayed.
*

The add( ) method is used to add a Component to a Container.
*

The getBorder( ) method returns information about a Container’s insets.
*

getComponent( ) method is used to access a Component that is contained in a Container.

Answers: a, b and d
9.

Suppose a Panel is added to a Frame and a Button is added to the Panel. If the Frame’s font is set to 12-point TimesRoman, the Panel’s font is set to 10-point TimesRoman, and the Button’s font is not set, what font will be used to display the Button’s label?
*

12-point TimesRoman
*

11-point TimesRoman
*

10-point TimesRoman
*

9-point TimesRoman

Answer: c.
10.

What are the subclasses of the Container class? - The Container class has three major subclasses. They are:
*

Window
*

Panel
*

ScrollPane
11.

Which object is needed to group Checkboxes to make them exclusive? - CheckboxGroup.
12.

What are the types of Checkboxes and what is the difference between them? - Java supports two types of Checkboxes:
*

Exclusive
*

Non-exclusive.

In case of exclusive Checkboxes, only one among a group of items can be selected at a time. I f an item from the group is selected, the checkbox currently checked is deselected and the new selection is highlighted. The exclusive Checkboxes are also called as Radio buttons. The non-exclusive checkboxes are not grouped together and each one can be selected independent of the other.
13.

What is a Layout Manager and what are the different Layout Managers available in java.awt and what is the default Layout manager for the panel and the panel subclasses? - A layout Manager is an object that is used to organize components in a container. The different layouts available in java.awt are:
*

FlowLayout: The elements of a FlowLayout are organized in a top to bottom, left to right fashion.
*

BorderLayout: The elements of a BorderLayout are organized at the borders (North, South, East and West) and the center of a container.
*

CardLayout: The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.
*

GridLayout: The elements of a GridLayout are of equal size and are laid out using the square of a grid.
*

GridBagLayout:
The elements of a GridBagLayout are organized according to a grid.However, the elements are of different sizes and may occupy more
than one row or column of the grid. In addition, the rows and columns may have different sizes.

The default Layout Manager of Panel and Panel sub classes is FlowLayout.
14.

Can I add the same component to more than one container? - No. Adding a component to a container automatically removes it from any previous parent (container).
15.

How can we create a borderless window? - Create an instance of the Window class, give it a size, and show it on the screen.

Frame aFrame = new Frame();
Window aWindow = new Window(aFrame);
aWindow.setLayout(new FlowLayout());
aWindow.add(new Button(\"Press Me\"));
aWindow.getBounds(50,50,200,200);
aWindow.show();

16.

Can I create a non-resizable windows? If so, how? - Yes. By using setResizable() method in class Frame.
17.

Which containers use a BorderLayout as their default layout? Which containers use a FlowLayout as their default layout? - The Window, Frame and Dialog classes use a BorderLayout as their default layout. The Panel and the Applet classes use the FlowLayout as their default layout.
18.

How do you change the current layout manager for a container?
*

Use the setLayout method
*

Once created you cannot change the current layout manager of a component
*

Use the setLayoutManager method
*

Use the updateLayout method

Answer: a.
19.

What is the difference between a MenuItem and a CheckboxMenuItem?- The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked

Free download online recent and current year solved placement question papers 2008 of leading companies in India and Abroad. See More Latest and previous expert, common, basic, important, advanced questions asked in college admission, entrance tests and technical interviews for 2007, 2008 january, february, march, april, may, june, july, august, september, october, november, december for leading IT Companies in India, USA, UK, Norway, China. Reputed MNCs testing job interview questions for Wipro, Infosys, TCS, Satyam Computers, HCL, IBM, Cisco, Microsoft, Keane, Flextronics, Accenture, Cognizant, T Systems, SAP, Oracle, Texas Instruments, Quark, Patni Computer Systems, Mastek, BT, Dell, BPO, ITES companies, Software Companies. Freshers and on campus interview held in delhi, mumbai, bangalore, chennai, madurai, noida, gurgaon, chandigarh, mohali, pune, hyderabad, kolkata, thane, ahmedabad, etc. Recent, latest reasoning, multiple choice questions, verbal, non verbal, mathematics questions with solutions / solved / answer keys, booklet. GD topics for leading campus placement interview, placement drive, HR Interview Questions and answers, how to behave, Tips, preparation, most recently asked / important software testing interview, free tutorials for java, oracle, c, c++, networking, web designing, windows 2000, vista, etc. questions. Keep Watching Previouspapers.blogspot.com for more stuff!

Java Database JDBC, Bridge, Interview Questions 17 IMP interview questions

Java database interview questions

1.

How do you call a Stored Procedure from JDBC? - The first step is to create a CallableStatement object. As with Statement and PreparedStatement objects, this is done with an open Connection object. A CallableStatement object contains a call to a stored procedure.

CallableStatement cs =
con.prepareCall("{call SHOW_SUPPLIERS}");
ResultSet rs = cs.executeQuery();

2.

Is the JDBC-ODBC Bridge multi-threaded? - No. The JDBC-ODBC Bridge does not support concurrent access from different threads. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge, but they won’t get the advantages of multi-threading.
3.

Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection? - No. You can open only one Statement object per connection when you are using the JDBC-ODBC Bridge.
4.

What is cold backup, hot backup, warm backup recovery? - Cold backup (All these files must be backed up at the same time, before the databaseis restarted). Hot backup (official name is ‘online backup’) is a backup taken of each tablespace while the database is running and is being accessed by the users.
5.

When we will Denormalize data? - Data denormalization is reverse procedure, carried out purely for reasons of improving performance. It maybe efficient for a high-throughput system to replicate data for certain data.
6.

What is the advantage of using PreparedStatement? - If we are using PreparedStatement the execution time will be less. The PreparedStatement object contains not just an SQL statement, but the SQL statement that has been precompiled. This means that when the PreparedStatement is executed,the RDBMS can just run the PreparedStatement’s Sql statement without having to compile it first.
7.

What is a “dirty read”? - Quite often in database processing, we come across the situation wherein one transaction can change a value, and a second transaction can read this value before the original change has been committed or rolled back. This is known as a dirty read scenario because there is always the possibility that the first transaction may rollback the change, resulting in the second transaction having read an invalid value. While you can easily command a database to disallow dirty reads, this usually degrades the performance of your application due to the increased locking overhead. Disallowing dirty reads also leads to decreased system concurrency.
8.

What is Metadata and why should I use it? - Metadata (’data about data’) is information about one of two things: Database information (java.sql.DatabaseMetaData), or Information about a specific ResultSet (java.sql.ResultSetMetaData). Use DatabaseMetaData to find information about your database, such as its capabilities and structure. Use ResultSetMetaData to find information about the results of an SQL query, such as size and types of columns
9.

Different types of Transaction Isolation Levels? - The isolation level describes the degree to which the data being updated is visible to other transactions. This is important when two transactions are trying to read the same row of a table. Imagine two transactions: A and B. Here three types of inconsistencies can occur:
*

Dirty-read: A has changed a row, but has not committed the changes. B reads the uncommitted data but his view of the data may be wrong if A rolls back his changes and updates his own changes to the database.

*

Non-repeatable read: B performs a read, but A modifies or deletes that data later. If B reads the same row again, he will get different data.
*

Phantoms: A does a query on a set of rows to perform an operation. B modifies the table such that a query of A would have given a different result. The table may be inconsistent.

TRANSACTION_READ_UNCOMMITTED : DIRTY READS, NON-REPEATABLE READ AND PHANTOMS CAN OCCUR.
TRANSACTION_READ_COMMITTED : DIRTY READS ARE PREVENTED, NON-REPEATABLE READ AND PHANTOMS CAN OCCUR.
TRANSACTION_REPEATABLE_READ : DIRTY READS , NON-REPEATABLE READ ARE PREVENTED AND PHANTOMS CAN OCCUR.
TRANSACTION_SERIALIZABLE : DIRTY READS, NON-REPEATABLE READ AND PHANTOMS ARE PREVENTED.
10.

What is 2 phase commit? - A 2-phase commit is an algorithm used to ensure the integrity of a committing transaction. In Phase 1, the transaction coordinator contacts potential participants in the transaction. The participants all agree to make the results of the transaction permanent but do not do so immediately. The participants log information to disk to ensure they can complete In phase 2 f all the participants agree to commit, the coordinator logs that agreement and the outcome is decided. The recording of this agreement in the log ends in Phase 2, the coordinator informs each participant of the decision, and they permanently update their resources.
11.

How do you handle your own transaction ? - Connection Object has a method called setAutocommit(Boolean istrue)
- Default is true. Set the Parameter to false , and begin your transaction

12.

What is the normal procedure followed by a java client to access the db.? - The database connection is created in 3 steps:
1.

Find a proper database URL

2.

Load the database driver
3.

Ask the Java DriverManager class to open a connection to your database

In java code, the steps are realized in code as follows:
1.

Create a properly formatted JDBR URL for your database. (See FAQ on JDBC URL for more information). A JDBC URL has the form
jdbc:someSubProtocol://myDatabaseServer/theDatabaseName

2.

Class.forName(”my.database.driver”);
3.

Connection conn = DriverManager.getConnection(”a.JDBC.URL”, “databaseLogin”,”databasePassword”);
13.

What is a data source? - A DataSource class brings another level of abstraction than directly using a connection object. Data source can be referenced by JNDI. Data Source may point to RDBMS, file System , any DBMS etc.
14.

What are collection pools? What are the advantages? - A connection pool is a cache of database connections that is maintained in memory, so that the connections may be reused
15.

How do you get Column names only for a table (SQL Server)? Write the Query. -

select name from syscolumns
where id=(select id from sysobjects where name='user_hdr')
order by colid --user_hdr is the table name

Java Graphics User Interface Designer - Interview Questions 18 IMP interview questions

Java GUI designer interview questions

1.

What advantage do Java’s layout managers provide over traditional windowing systems? - Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java’s layout managers aren’t tied to absolute sizing and positioning, they are able to accomodate platform-specific differences among windowing systems.
2.

What is the difference between the paint() and repaint() methods? - The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

3.

How can the Checkbox class be used to create a radio button? - By associating Checkbox objects with a CheckboxGroup
4.

What is the difference between a Choice and a List? - A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.
5.

What interface is extended by AWT event listeners? - All AWT event listeners extend the java.util.EventListener interface.
6.

What is a layout manager? - A layout manager is an object that is used to organize components in a container
7.

Which Component subclass is used for drawing and painting? - Canvas
8.

What are the problems faced by Java programmers who dont use layout managers? - Without layout managers, Java programmers are faced with determining how their GUI will be displayed across multiple windowing systems and finding a common sizing and positioning that will work within the constraints imposed by each windowing system
9.

What is the difference between a Scrollbar and a ScrollPane? (Swing) - A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs its own scrolling.

See Latest Java Language Graphic User Interface Interview Questions For Animation Companies - Mauj, Maya, Land Marvel, Compact Disc India, Illion, Illuminated, Imagi, Houston, Pixar 3d Studio, Animantz, PNC Pritish Nandy Communications, Animation 5, i2eye animation studio, Dreamworks Animation Interview Questions, Thomson, Arena Multimedia Multiple Choice Questions with answers key, Aptech Academy Java Placement Interview Questions, Prana 3d studios detailed graphics GUI Questions with detailed solutions. Keep Watching Previouspapers.blogspot.com for more free stuff..

Friday, August 8, 2008

IMP interview questions Java Important Technical Interview Questions - 20

#

What is garbage collection? What is the process that is responsible for doing that in java? - Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process
#

What kind of thread is the Garbage collector thread? - It is a daemon thread.

#

What is a daemon thread? - These are the threads which can run without user intervention. The JVM can exit when there are daemon thread by killing them abruptly.
#

How will you invoke any external process in Java? - Runtime.getRuntime().exec(….)
#

What is the finalize method do? - Before the invalid objects get garbage collected, the JVM give the user a chance to clean up some resources before it got garbage collected.
#

What is mutable object and immutable object? - If a object value is changeable then we can call it as Mutable object. (Ex., StringBuffer, …) If you are not allowed to change the value of an object, it is immutable object. (Ex., String, Integer, Float, …)
#

What is the basic difference between string and stringbuffer object? - String is an immutable object. StringBuffer is a mutable object.
#

What is the purpose of Void class? - The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.
#

What is reflection? - Reflection allows programmatic access to information about the fields, methods and constructors of loaded classes, and the use reflected fields, methods, and constructors to operate on their underlying counterparts on objects, within security restrictions.
#

What is the base class for Error and Exception? - Throwable
#

What is the byte range? -128 to 127
#

What is the implementation of destroy method in java.. is it native or java code? - This method is not implemented.
#

What is a package? - To group set of classes into a single unit is known as packaging. Packages provides wide namespace ability.
#

What are the approaches that you will follow for making a program very efficient? - By avoiding too much of static methods avoiding the excessive and unnecessary use of synchronized methods Selection of related classes based on the application (meaning synchronized classes for multiuser and non-synchronized classes for single user) Usage of appropriate design patterns Using cache methodologies for remote invocations Avoiding creation of variables within a loop and lot more.
#

What is a DatabaseMetaData? - Comprehensive information about the database as a whole.
#

What is Locale? - A Locale object represents a specific geographical, political, or cultural region
#

How will you load a specific locale? - Using ResourceBundle.getBundle(…);
#

What is JIT and its use? - Really, just a very fast compiler… In this incarnation, pretty much a one-pass compiler — no offline computations. So you can’t look at the whole method, rank the expressions according to which ones are re-used the most, and then generate code. In theory terms, it’s an on-line problem.
#

Is JVM a compiler or an interpreter? - Interpreter
#

When you think about optimization, what is the best way to findout the time/memory consuming process? - Using profiler
#

What is the purpose of assert keyword used in JDK1.4.x? - In order to validate certain expressions. It effectively replaces the if block and automatically throws the AssertionError on failure. This keyword should be used for the critical arguments. Meaning, without that the method does nothing.
#

How will you get the platform dependent values like line separator, path separator, etc., ? - Using Sytem.getProperty(…) (line.separator, path.separator, …)
#

What is skeleton and stub? what is the purpose of those? - Stub is a client side representation of the server, which takes care of communicating with the remote server. Skeleton is the server side representation. But that is no more in use… it is deprecated long before in JDK.
#

What is the final keyword denotes? - final keyword denotes that it is the final implementation for that method or variable or class. You can’t override that method/variable/class any more.
#

What is the significance of ListIterator? - You can iterate back and forth.
#

What is the major difference between LinkedList and ArrayList? - LinkedList are meant for sequential accessing. ArrayList are meant for random accessing.
#

What is nested class? - If all the methods of a inner class is static then it is a nested class.
#

What is inner class? - If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class.
#

What is composition? - Holding the reference of the other class within some other class is known as composition.
#

What is aggregation? - It is a special type of composition. If you expose all the methods of a composite class and route the method call to the composite method through its reference, then it is called aggregation.
#

What are the methods in Object? - clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString
#

Can you instantiate the Math class? - You can’t instantiate the math class. All the methods in this class are static. And the constructor is not public.
#

What is singleton? - It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class. For eg., public class Singleton { private static final Singleton s = new Singleton(); private Singleton() { } public static Singleton getInstance() { return s; } // all non static methods … }
#

What is DriverManager? - The basic service to manage set of JDBC drivers.
#

What is Class.forName() does and how it is useful? - It loads the class into the ClassLoader. It returns the Class. Using that you can get the instance ( “class-instance”.newInstance() )