Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
FAQ JAVA 1.) Difference between Enumeration and Iteration? Both will help you to travel into collection bag, but Enumeration is a legacy classes, Iterator have introduced in Collection framework. In enumeration we can modify the collection objects but throw Iterator it is possible. Enumeration can be used for Collection objects as well as Iterator can be used for legacy classes. Enumeration acts as Read-only interface, where as using Iterator we can manipulate the objects also like adding and removing the objects. So Enumeration is used whenever we want to make Collection objects as Read-only. 2.) What’s the difference between Transient and Volatile? Transient: The transient modifier applies to variables only and it is not stored as part of its object’s Persistent state. These variables are not serialized. Transient instance fields are neither saved nor restored by the standard serialization. You have to handle restoring them yourself. Volatile: Volatile modifier tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of the program. For example a Variable might be read from Cache and not update the content if it has been changed by another thread. Specifying a variable as volatile tells the JVM that any threads using that variable are not allowed to cache that value at all. Making the Variable Volatile will ensure that the compiler will get the content of the variable every time it is used and not cache its content. If not used Carefully this modifier might introduce bugs. 3.) Is JVM platform dependent? Although java is platform independent but still JVM IS platform dependent one of the feature called byte code makes JVM platform dependent. Byte code is an intermediate machine code of compiled source code. The byte code can run on all machines, however the JVM must be installed in each machine. 4.) What are wrapper classes? Why do we need wrapper classes? Java provides specialized classes corresponding to each of the primitive data types. These are called wrapper classes. They are Boolean, Byte, Character, Double, Float, Integer, Long, and Short. We can create instances of these classes hence we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an object. 5.) What are Checked and Unchecked Exception? A checked exception is generally known as Compiletime Exception. Checked exception forces client programmers to deal with the possibility that the exception will be thrown hence the programmer has to handle these types of exceptions. e.g., IOException thrown by java.io.FileInputStream’s read( ) method. Where as Unchecked exceptions are Runtime Exception. With an unchecked exception, however, the compiler doesn’t force client programmers either to catch the exception or declare it in a throws clause. In fact, client programmers may not even know that the exception could be thrown. e.g., StringIndexOutOfBounds Exception thrown by String’s charAt () method· Checked exceptions must be caught at compile time but Runtime exceptions do not need to be. 6.) What is deadlock and how it can be avoid? 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. 7.) What is the difference between interface and abstract class? Difference between interface and abstract: All the methods declared inside interface should be abstract, and there is no need to use the key word “abstract” for those method, but in case of abstract class at least one method should be abstract, most importantly u have to use the “abstract” key word for that method, besides that it may contain concrete methods. Abstract class must be extended abstract () methods generally contain only declaration part without definition part. 8.) Why are there no global variables in Java? Global variables are considered bad form for a variety of reasons: Adding state variables breaks referential transparency (you no longer can understand a statement or expression on its own: you need to understand it in the context of the settings of the global variables). State variables lessen the cohesion of a program: you need to know more to understand how something works. A major point of Object-Oriented programming is to break up global state into more easily understood collections of local state. When you add one variable, you limit the use of your program to one instance. What you thought was global, someone else might think of as local: they may want to run two copies of your program at once. 9.) What are the steps in the JDBC connection? For making a JDBC connection we need to go through the following steps: Step 1: Register the database driver by using: Class.forName (\” driver class for that specific database\”); Step 2 : Create a database connection using: Connection con = DriverManager.getConnection (url, username, password); Step 3: Create a query using: Statement stmt = Connection.Statement (\”select * from TABLE NAME\”); Step 4: Exceute the query: Stmt.exceuteUpdate (); 10.) What is an enumeration? An enumeration is an interface which containing methods for accessing the underlying data structure. It is a construct which collection classes return when you request a collection of all the objects stored in the collection. It allows sequential access to all the elements stored in the collection. 11.) How Application is differ from Applet? Applications: Applications are Stand Alone and the doesn’t need web-browser. Execution of Applications starts with main (). Applets: 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. Execution Applets starts with init () method and it must run within a GUI, it may be AWT / Swing. 12.) What is CDC? The Connected Device Configuration (CDC) is a specification for a J2ME configuration. Conceptually, CDC deals with devices with more memory and processing power than CLDC; it is for devices with an always-on network connection and a minimum of 2 MB of memory available for the Java system. 13.) What is the MIDP? The MIDP defines a set of APIs for mobile devices, such as cell phones and low-end PDAs 14.) What is variable typing in javascript? It is perfectly legal to assign a number to a variable and then assign a string to the same variable as follows Example: i = 10; i = “string”; 15.) What does a well-written java program look like? A well-written java program exhibits recurring structures that promote abstraction, flexibility, modularity and elegance.