Q. What are supported platforms by Java Programming Language?
Answer: Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.Linux like HP-Unix, Sun Solaris, Redhat Linux, Ubuntu, CentOS, etc.
Q. What kind of variables a class can consist of?
Answer: Class consist of local variable, instance variables and class variables.
Q.What is Local variable?
Answer: Local Variables are defined in the method and scope of the variables existed inside the method itself.
Q.What is Class Variable?
Answer: Class variables also known as static variables are declared with the static keyword in a class, but outside a method, constructor or a block. There would only be one copy of each class variable per class, regardless of how many objects are created from it.
Q.What is instance Variable?
Answer: Instance Variable is defined inside the class and outside the method and the scope of the variables exists throughout the class.
Q.What is Singleton class?
Answer: Singleton class control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes.
Q.What is the default value of byte datatype in java?
Answer: 0 (Zero)
Q.What is the default value of float & Double Data type in java?
Answer: float 0.0f And double 0.0d
Q.What do you mean by synchronized Non Access Modifier?
Answer:Java provides these modifiers for providing functionalities other than Access Modifiers, synchronized used to indicate that a method can be accessed by only one thread at a time.
Q.Variable used in a switch statement can be used with which datatypes?
Answer: Switch statement use only string, enum, byte, short, int, or char.
Q. Why is String class considered immutable?
Answer: The string class is immutable, so that once it is created a String object cannot be changed. Since String is immutable it can safely be shared between many threads, which is considered very important for multithreaded programming.
Q.Why is StringBuffer called mutable?
Answer: The String class is considered as immutable, so that once it is created a String object cannot be changed. If there is a necessity to make a lot of modifications to Strings of characters then StringBuffer should be used.
Q.Which package is used for pattern matching with regular expressions?
Answer: java.util.regex package is used for this purpose. It consists of three classes – Pattern class, Matcher class and PatternSyntaxException Class.
Q.What do you mean by Checked Exceptions?
Answer: A checked exception is a type of exception that must be either caught or declared in the method in which it is thrown. For example, the java.io.IOException is a checked exception.
Q.Which are the two subclasses under exception class?
Answer: IOException class and RunTimeException class are two subclasses under exception class.
Q. Define immutable object?
Answer: An immutable object is an object that will not change its internal state after creation. Immutable objects are very useful in multithreaded applications because they can be shared between threads without synchronization. Immutable objects are always thread safe.
Q. Define JRE
Q. Define JRE
Answer: JRE is an acronym for Java Runtime Environment. It is also written as Java RTE. The Java Runtime Environment is a set of software tools which are used for developing Java applications. It is used to provide the runtime environment. It is the implementation of JVM. It physically exists. It contains a set of libraries + other files that JVM uses at runtime.
Q. What is JAR file?
Q. What is JAR file?
Answer: JAR stands for Java ARchive. It's a file format based on the popular ZIP file format and is used for aggregating many files into one.
Q. What is a WAR file?
Q. What is a WAR file?
Answer: A war (web archive) File contains files of a web project. It may have servlet, xml, jsp, image, html, css, js etc. files.
Q. What is the difference between yielding and sleeping in Java?
Here, we will discuss what is war file, how to create war file, how to deploy war file and how to extract war file.
Q. What is the difference between yielding and sleeping in Java?
Answer: The major difference between yield and sleep in Java is that yield() method pauses the currently executing thread temporarily for giving a chance to the remaining waiting threads of the same priority to execute.
Q. What are wrapper classes?
Q. What are wrapper classes?
Answer: The wrapper class in Java provides the mechanism to convert primitive into object and object into primitive. The eight classes of the java.lang package are known as wrapper classes in Java. Boolean, Character, Byte, Short, Integer, Long, Float, Double are 8 wrapper classes in java.
Q. Which package has light weight components?
Answer: javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components.
Light weight Component takes the components from the jvm, means it does not request the operating System for getting the components.
Answer: javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components.
Light weight Component takes the components from the jvm, means it does not request the operating System for getting the components.
Q. What is the difference between the paint() and repaint() methods?
Answer:
paint()
1.The paint() method is called
when some action is performed on the window.
2.This method supports painting
via graphics object.
repaint()
1.Whenever a repaint method is
called, the update method is also called along with paint() method.
2.This method is used to cause
paint() to be invoked by the AWT painting thread.
Q. What is Serialization & Deserialization?
Answer: Serialization is a mechanism of converting the state of an object into a byte stream. Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory.
Q. What is the difference between Swing & AWT components?
Answer: The main difference between AWT and Swing in Java is that the AWT is Java’s original platform-dependent windowing, graphics, and user interface widget toolkit while the Swing is a GUI widget toolkit for Java that is an extension of AWT.
Q. When is the ArrayStoreException thrown?
Q. What is the difference between Swing & AWT components?
Answer: The main difference between AWT and Swing in Java is that the AWT is Java’s original platform-dependent windowing, graphics, and user interface widget toolkit while the Swing is a GUI widget toolkit for Java that is an extension of AWT.
Q. When is the ArrayStoreException thrown?
Answer: ArrayStoreException in Java. ArrayStoreException in Java occurs whenever an attempt is made to store the wrong type of object into an array of objects.
Q. What is a transient variable?
Answer: Transient variable in Java is a variable whose value is not serialized during Serialization and which is initialized by its default value during de-serialization, for example for object transient variable it would be null.
Q. What are ClassLoaders?
Answer: Class loaders are responsible for loading Java classes during runtime dynamically to the JVM (Java Virtual Machine).
Q. What is the difference between an Interface and an Abstract Class?
Answer:
Answer: Class loaders are responsible for loading Java classes during runtime dynamically to the JVM (Java Virtual Machine).
Q. What is the difference between an Interface and an Abstract Class?
Answer:
- Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
- Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
- Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
- Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
- An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces.
- A Java class can implement multiple interfaces but it can extend only one abstract class.
- Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
- In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.
Answer: Program throws "NoSuchMethodError" error at runtime
Q. Can a top level class be private or protected?
Q. Can a top level class be private or protected?
Answer: A top level class can not be private or protected. It can have either "public" or no modifier.
Q. What is the difference between error and an exception?
Q. What is the difference between error and an exception?
Answer: java.lang.Error class represents the errors which are mainly caused by the environment in which application is running Where as java.lang.Exception class represents the exceptions which are mainly caused by the application itself.
Q. Is it necessary that each try block must be followed by a catch block?
Q. Is it necessary that each try block must be followed by a catch block?
Answer: No, it is not mandatory that each try block must be followed by a catch block in Java.
Q. When a thread is created and started, what is its initial state?
Q. When a thread is created and started, what is its initial state?
Answer: A thread is in the ready state after it has been created and started.
Q. What is the Locale class?
Answer: The Java Locale class object represents a specific geographic, cultural, or political region. It is a mechanism to for identifying objects, not a container for the objects themselves. A Locale object logically consists of the fields like languages, script, country, variant, extensions.
Q. Can Constructor be inherited?
Q. Can Constructor be inherited?
Answer: No, because Constructors are not members of classes and only members are inherited. You cannot inherit a constructor.
Q. Why deletion in LinkedList is fast than ArrayList?
Q. Why deletion in LinkedList is fast than ArrayList?
Answer: ArrayList is slower because it needs to copy part of the array in order to remove the slot that has become free. If the deletion is done using the ListIterator.remove() API, LinkedList just has to manipulate a couple of references; if the deletion is done by value or by index, LinkedList has to potentially scan the entire list first to find the element(s) to be deleted.
Q. What is dot operator?
Answer: The (.) operator is also known as member operator it is used to access the member of a package or a class.
Q. Where and how can you use a private constructor?
Answer: There are various scenarios where we can use private constructors. The major ones are
Answer: >>> basically means unsigned right shift operator. Which means that even if you perform >>> on a signed number (for example -22), it will not take account of the sign and simple perform right shift on the binary representation of -22.
On the other hand, >> means signed right shift operator. This operator considers the sign bit of the number, and works accordingly.
Q. What is Socket?
Answer: A socket is one end-point of a two-way communication link between two programs running on the network.
The java.net package in the Java development environment provides a class--Socket--that represents one end of a two-way connection between your Java program and another program on the network. The Socket class implements the client side of the two-way link.
Q. What is dot operator?
Answer: The (.) operator is also known as member operator it is used to access the member of a package or a class.
Q. Where and how can you use a private constructor?
Answer: There are various scenarios where we can use private constructors. The major ones are
- Internal Constructor chaining
- Singleton class design pattern
Answer: >>> basically means unsigned right shift operator. Which means that even if you perform >>> on a signed number (for example -22), it will not take account of the sign and simple perform right shift on the binary representation of -22.
On the other hand, >> means signed right shift operator. This operator considers the sign bit of the number, and works accordingly.
Q. What is Socket?
Answer: A socket is one end-point of a two-way communication link between two programs running on the network.
The java.net package in the Java development environment provides a class--Socket--that represents one end of a two-way connection between your Java program and another program on the network. The Socket class implements the client side of the two-way link.
