CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies
Core Java Interview Questions & Answers - Learning Mode
COOLINTERVIEW.COM J2EE INTERVIEW QUESTIONS CORE JAVA INTERVIEW QUESTIONS QUESTIONS & ANSWERS - LEARNING MODE

Core Java Interview Questions & Answers - Learning Mode

"Core Java" is Sun's term, used to refer to Java SE, the standard edition and a set of related technologies, like the Java VM, CORBA, et cetera. This is mostly to differentiate from, say, Java ME or Java EE. Also note that they're talking about a set of libraries rather than the programming language. When people talk about core java they usually refer to the features of the java language and the standard libraries alone. Advanced Java is probably everything else you can add, such as Java Enterprise Edition libraries.

Try Core Java Interview Questions & Answers - Exam Mode

1 2 3 4 5 Next

Sort By : Latest First | Oldest First | By Rating

Core Java Interview Questions & Answers - Learning Mode
Try Core Java Interview Questions & Answers - Exam Mode
Question: What do u mean by "method" in java ?

Answer: Java methods are similar to functions or procedures in other programming languages.

Every Java program must have one main() method.

Here is the main() method from a Java program which prints
"Hello World":

public static void main (String[] args) {
// This Java program prints "Hello World!"
System.out.println{"Hello World!");
Source: CoolInterview.com
Question: Why would you use a synchronized block vs. synchronized method?

Answer: Synchronized blocks place locks for shorter periods than synchronized methods. Source: CoolInterview.com
Question: What modifiers are allowed for methods in an Interface?

Answer: Only public and abstract modifiers are allowed for methods in interfaces. Source: CoolInterview.com
Question: How are this() and super() used with constructors?

Answer: * Constructors use this to refer to another constructor in the same class with a different parameter list.
* Constructors use super to invoke the superclass's constructor. If a constructor uses super, it must use it in the first line; otherwise, the compiler will complain.
Source: CoolInterview.com
Question: What are the differences between Interface and Abstract class?

Answer: Abstract Class Interfaces
An abstract class can provide complete, default code and/or just the details that have to be overridden. An interface cannot provide any code at all,just the signature.
In case of abstract class, a class may extend only one abstract class. A Class may implement several interfaces.
An abstract class can have non-abstract methods. All methods of an Interface are abstract.
An abstract class can have instance variables. An Interface cannot have instance va Source: CoolInterview.com
Question: What is the difference between throw and throws?

Answer: Throw:it is used to raise exception explicitly
that means it is use when a user defined exception is raised.

Throws:if a method is capable of throwing an exception but
it does not handle the exception that must be specified by using "throws" class. Source: CoolInterview.com
Question: What is difference between an Abstract class and Interface?

Answer: 1.Interfaces provide a form of multiple inheritance. A class can extend only one other class.
2.Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.
3. A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.
4. Interfaces are slow as it requires extra indirection to to find corresponding method in in the actual c Source: CoolInterview.com
Question: What modifiers are allowed for methods in an Interface?

Answer: Only public and abstract modifiers are allowed for methods in interfaces. Source: CoolInterview.com
Question: What is an exception?

Answer: An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions. Source: CoolInterview.com
Question: What is Abstraction?

Answer: Abstraction refers to the act of representing essential features without including the background details or explanations. Source: CoolInterview.com
Question: What does it mean that a method or field is ?static??

Answer: 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 j Source: CoolInterview.com
Question: What is static block?

Answer: Static block which exactly executed exactly once when the class is first loaded into JVM. Before going to the main method the static block will execute. Source: CoolInterview.com
Question: What is method overloading?

Answer: Method Overloading means to have two or more methods with same name in the same class with different arguments. The benefit of method overloading is that it allows you to implement methods that support the same semantic operation but differ by argument number or type.
Note:

* Overloaded methods MUST change the argument list
* Overloaded methods CAN change the return type
* Overloaded methods CAN change the access modifier
* Overloaded methods CAN declare new or Source: CoolInterview.com
Question: Which is superclass of Exception?

Answer: "Throwable", the parent class of all exception related classes. Source: CoolInterview.com
Question: What are the different ways to handle exceptions?

Answer: There are two ways to handle exceptions:

* Wrapping the desired code in a try block followed by a catch block to catch the exceptions.
* List the desired exceptions in the throws clause of the method and let the caller of the method handle those exceptions.
Source: CoolInterview.com
Question: What are the differences between Contructors and Methods?

Answer: Constructors Methods

Purpose


Create an instance of a class


Group Java statements

Modifiers


Cannot be abstract, final, native, static, or synchronized


Can be abstract, final, native, static, or synchronized

Return Type


No return type, not even void


void or a valid return type

Name


Same name as the class (first letter is capitalized by convention) -- usually a noun


Any nam Source: CoolInterview.com
Question: What is final modifier?

Answer: The final modifier keyword makes that the programmer cannot change the value anymore. The actual meaning depends on whether it is applied to a class, a variable, or a method.

* final Classes- A final class cannot have subclasses.
* final Variables- A final variable cannot be changed once it is initialized.
* final Methods- A final method cannot be overridden by subclasses.
Source: CoolInterview.com
Question: How do you prevent a method from being overridden?

Answer: To prevent a specific method from being overridden in a subclass, use the final modifier on the method declaration, which means "this is the final implementation of this method", the end of its inheritance hierarchy.

public final void exampleMethod() {
// Method statements
}
Source: CoolInterview.com
Question: Is it possible to override the main method?

Answer: NO, because main is a static method. A static method can't be overridden in Java.
Source: CoolInterview.com
Question: What are the advantages of using exception handling?

Answer: Exception handling provides the following advantages over "traditional" error management techniques:

* Separating Error Handling Code from "Regular" Code.
* Propagating Errors Up the Call Stack.
* Grouping Error Types and Error Differentiation.
Source: CoolInterview.com

1 2 3 4 5 Next



India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.09375 Seconds