Core Java refers to the fundamentals of Java, necessary to learn all essential components for being a Java programmer. Core java is not only essential for beginners but also for professionals who are master in advanced java as whenever you go for the interview, interviewer can ask any questions in the stock pile of core java questions and answers.
It is not possible to anyone to cover all essential core java questions and answers but we are trying to cover up as much possible crucial core java questions. Mastering in Java is a different thing and facing an interview is a different. In any interview, a simple question can dooms the possibility of your selection despite having deep and broad knowledge. Thus it is essential for all to prepare themselves very well before going to any interview.
Here we are covering basic and moderate questions occasionally asked in any interview with a fresher or having experience of 1-2 years. Read carefully:
Ques: What is Java?
Ans: Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. This tutorial gives a complete understanding of Java. For more views: http://www.roseindia.net/java/beginners/what-is-java.shtml
Ques: Is java platform Independent? Or What is the most important feature of Java?
Ans: Yes, It is a platform independent language, able to run and execute at any platforms like Windows, Linux, MacOS and Solaris etc.
Ques: What do you mean by platform independence?
Ans: Platform independence refers to non-dependency of operating system, and browser. Platform independent software can run and execute at any platforms, no matter where it is written.
Ques: What is Object in Java?
Ans: Objects are the basic run time entity or in other words object is a instance of a class. An object is a software bundle of variables and related methods of the special class. In the above example the sq is the object of square class and rect is the object of the rectangle class. In real-world objects share two characteristics: They have all state and behavior. For detail view: http://www.roseindia.net/java/beginners/ObjectClass.shtml
Ques: What is class in Java?
Ans: Whatever we can see in this world all the things are a object. And all the objects are categorized in a special group. That group is termed as a class. All the objects are direct interacted with its class that mean almost all the properties of the object should be matched with it's own class. For detail view: http://www.roseindia.net/java/beginners/ObjectClass.shtml
Ques: What is the term 'Methods' used in Java?
Ans: Methods in Java depicts about how a logic is written and how we can communicate with objects. If we call or invoke any method, it is called implementing a behaviour in object.
Ques: What are Instance Variables in Java?
Ans: an instance variable is similar and contrast with a class variable and each instance variable has a separate copy, or instance.
Ques: What are transient variables in java?
Ans: The variable that cannot be serialized is known as transient variable.
Ques: How Observer and Observable are used?
Ques: What is synchronization?
Ans: view in detail: http://www.roseindia.net/java/thread/synchronization.shtml
Ques: What is List interface?
Ques: What is a Vector?
Ans: Vectors are used instead of arrays because unlike array they can adjust according to the component added or removed from them. For more visit: http://www.roseindia.net/java/collection/java-vector.shtml
Ques: Is java a case sensitive language?
Ans: Yes! Java is a case sensitive language. For example: identifier Hello and hello would have different meaning in Java.
Ques: What are the identifiers in Java?
Ans: An identifier is a sequence of one or more characters used for naming the classes, variables and methods as all Java components need names to be identified. A query language identifier is case-sensitive, with two exceptions: Keywords, and Identification variables. An identifier cannot be the same as a query language keyword. For more, visit: http://www.roseindia.net/java/beginners/identifierandpdatatype.shtml
Ques: What is Object Oriented Programming?
Ans: Object Oriented Programming is a programming language that enables the programmer to associate a set of procedures with each type of data structure. Object-oriented programming makes it easier for programmers to structure and organize software programs. Because individual objects can be modified without affecting other aspects of the program, it is also easier to update and change programs written in object-oriented languages.
Ques: What is the difference between yield() and sleep()?
Ques: What are Wrapper Classes ?
Ques: Can we call finalize() method ?
Ques: Why threads block or enters to waiting state on I/O?
Ans: Threads enters to waiting state or block on I/O because other threads can execute while the I/O operations are performed.
Ques: What is the difference between time slicing and preemptive scheduling?
Ques: What is the initial state of a thread when it is created and started?
Ans: The thread remains in ready state.
Ques: Can we declare an anonymous class as both extending a class and implementing an interface?
Ans: No. An anonymous class can extend a class or implement an interface, but it cannot be declared to do both.
Ques: What are the differences between boolean & operator and & operator?
Ques: What is the use of the finally block?
Ans: Finally is the block of code that executes always. The code in finally block will execute even if an exception is occurred. Finally will not execute when the user calls System.exit().
Ques: What is an abstract method?
Ans: An abstract method is a method that doesn't have a body. It is declared with modifier abstract.
Ques: What is the difference between System.err and System.out?
Ans: We can redirect System.out to another file but we cannot redirect System.err stream.
Ques: What are the differences between an abstract class and an interface?
Ans: View in detail: http://www.roseindia.net/help/java/a/interface-diference-abstractclass.shtml
Ques: What is the difference between synchronized block and synchronized method?
Ques: How can you force garbage collection in java?
Ans: Garbage collection is an automatic process and can't be forced. Garbage collection is one of the most important features of Java. 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. Garbage collection is also called automatic memory management. In Java, it is good idea to explicitly assign null into a variable when no more in use. In Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected.
For more, visit: http://www.roseindia.net/java/example/java/io/code-for-garbage-collection.shtml
Ques: How can you call a constructor from another constructor?
Ans: By using this() reference.
Ques: How can you call the constructor of super class?
Ans: By using super() syntax.
Ques: What's the difference between normal methods and constructors?
Ans: Normal methods can be called many times whenever it needs while Constructors can be called once. Constructors too have similar name of the class and but not have a return type.
Ques: What is the use of packages in java?
Ans: Package is a mechanism for organizing a group of related files in the same directory. In a computer system, we organize files into different directories according to their functionality, usability and category. It helps in resolving name conflicts when different modules have classes with the similar names.
Ques: What must be the order of catch blocks when catching more than one exception?
Ans: The sub classes must come first or else it will give a compile time error.
Ques: How can we call a method or variable of the super class from child class?
Ans: For calling a method or variable of the super class from child class, super.method() or super.variable syntax is used.
Ques: If you are overriding equals() method of a class, what other methods you might need to override ?
Ques: How can you create your own exception?
Ans: Our class must extend either Exception or its sub class
Ques: What is serialization?
Ans: Serialization is the process of saving the state of an object. View: http://www.roseindia.net/java/example/java/io/Serialization-java.shtml
Ques: What is de-serialization?
Ans: De-serialization is the process of restoring the state of an object. View: http://www.roseindia.net/java/example/java/io/DeserializingObject.shtml
Ques: What is externalizable?
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Ask Questions? Discuss: Important Interview Questions in Core Java
Post your Comment