Tuesday, November 29, 2011
Core Java Interview Questions :Why would you use a synchronized block vs. synchronized method?
Synchronized blocks place locks for shorter periods than synchronized methods.:I guess, synchronized block or synchronized methods are depends on the user requirements. :First of all to achieve Multithreading mechanism in java we should go for synchronization. And this can be done in two ways depending on the requirement. :There is not a clear advantage of using synchronized method over block.:in some times only some part of the method doesn&
Core Java Interview Questions :Why Runtime Exceptions are Not Checked?
The runtime exception classes (RuntimeException and its subclasses) are exempted from compile-time checking because, in the judgment of the designers of the Java programming language, having to declare such exceptions would not aid significantly in establishing the correctness of programs. Many of the operations and constructs of the Java programming language can result in runtime exceptions. The information available to a compiler, and the level of analysis the compiler performs, are usually not sufficient to establish that such run-time exceptions cannot occur, even though this may be obvious to the programmer. Requiring such exception classes to be declared would simply be an irritation to programmers.
Core Java Interview Questions :Why operator overloading is not there in java?
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().:I belive Operator Overloading exists in Java.:Operator overloading makes the code more complex and less readable. Also we could define different methods in the same class like plus(),plusplus(), minus() etc and thus bringing operator overloading in Java:I guess,Operator overloading is not supported in Java as its create lot of confusion instead of solving the problems. :Operator Overloading
Core Java Interview Questions :why java uses singly rooted heirarchy?
All objects in Java are inherited from same base class called &
Core Java Interview Questions :Why Errors are Not Checked?
A unchecked exception classes which are the error classes (Error and its subclasses) are exempted from compile-time checking because they can occur at many points in the program and recovery from them is difficult or impossible. A program declaring such exceptions would be pointlessly.:Errors are not predictable at compile time.The problem which halt the execution of program, called error and these are uncheck. So, it is difficult to provide a solution for particular problem.
Core Java Interview Questions :Why does Java not support Multiple Inheritance?
java does not support multiple inheritance because different classes may have different variable with same name that may be be contradicted and can cause confusions resulting in errors.:confusion may not be the problem because we use interface for multiple inheritance so there we will mention function names so the primary reason may be the complexity of holding objects of different datatypes:so that one could get easy view by interfacethat program is using multiple inheritance.Hence to increase readability of code. :Java doesn&
Core Java Interview Questions :Which is superclass of Exception?
"Throwable", the parent class of all exception related classes.: Throwable
Core Java Interview Questions :When you declare a method as abstract, can other nonabstract methods access it?
Yes, other nonabstract methods can access a method that you declare as abstract.:No, Abstract method has only definition no implementation so other methods cannot access it until and unless we provide the body in the sub class.:Yes , non abstract method can access abstract method , but this abstract method will be implemented in its subclass and the same will be invoked from the non abstarct method of abstract super class. if not implemented the subclass must also be an abstract class. so doesn&
Core Java Interview Questions :What modifiers are allowed for methods in an Interface?
Only public and abstract modifiers are allowed for methods in interfaces.
Core Java Interview Questions :What is the use of finally block?
The finally block encloses code that is always executed at some point after the try block, whether an exception was thrown or not. This is right place to close files, release your network sockets, connections, and perform any other cleanup your code requires.:Finally block is used to handle an exception(The common error which stop the complete execution of program.) in JAVA. It can be better understood by the following code::finally block is also called as resource handler block.this block is used for frees the resources at the time of terminating the program.these resources are used for other programs.:finally block is also called as resounce handler block.it is follewed by try(if catch is there,after catch)block.it is compulsary executing block eventhough exceptions are rised.:finally block is executing by default means , whether try block rised exception or not and whether the rised exception is handiled by catch block or not by automatically finally block will be executing. :finally block is not executing in only one sinario i.e is when the try block contained the System.exit statement that time finally block will not be executing. Except this condition in all remaining conditions finally block will be executing by default.:One doubt why use Finaly ? we can give the same code to release memory and etcc... even after catch block
Core Java Interview Questions :What is the difference between throw and throws?
Throw:it is used to raise exception explicitly:they are not same.:Throw:it is used to raise exception explicitly:Throw:it is used to raise exception explicitly:throw: it is used to generate an exception.:throws clause is used when the programmer does not want to handle the exception and throw it out side of method.:throw is used for the User defined Exception, but we need to handle it.:throw is user defined exception but nee to handle it:well. throws clause is used to specify that the caller of that method should handle the exception if one is raised.:Throws:-when programmer does&
Core Java Interview Questions :What is the difference between static and non-static variables?
A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.:To access the static variable we don&
Core Java Interview Questions :what is the difference between arraylist nd linked list?which is faster?why?
ArrayList : List implementation backed by a Java array, similar to the Vector class. As the number of elements in the collection increases, the internal array grows to fit them. If there are lots of growth periods, performance degrades as the old array needs to be copied into the new array. However, random access is very quick as it uses an array index to access.
Core Java Interview Questions :What is the difference between abstraction and encapsulation?
* Abstraction focuses on the outside view of an object (i.e. the interface) Encapsulation (information hiding) prevents clients from seeing it?s inside view, where the behavior of the abstraction is implemented.:Abstraction is hiding the implementation details of the object from its specifications.:abstraction:Abstraction means hiding the data.
Core Java Interview Questions :what is the class variables ?
When we create a number of objects of the same class, then each object will share a common copy of variables. That means that there is only one copy per class, no matter how many objects are created from it. Class variables or static variables are declared with the static keyword in a class, but mind it that it should be declared outside outside a class. These variables are stored in static memory. Class variables are mostly used for constants, variable that never change its initial value. Static variables are always called by the class name. This variable is created when the program starts i.e. it is created before the instance is created of class by using new operator and gets destroyed when the programs stops. The scope of the class variable is same a instance variable. The class variable can be defined anywhere at class level with the keyword static. It initial value is same as instance variable. When the class variable is defined as int then it&
Core Java Interview Questions :What is super?
super is a keyword which is used to access the method or member variables from the superclass. If a method hides one of the member variables in its superclass, the method can refer to the hidden variable through the use of the super keyword. In the same way, if a method overrides one of the methods in its superclass, the method can invoke the overridden method through the use of the super keyword.
Core Java Interview Questions :What is static block?
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.:Static block runs once and it is before program enter into main().:after loading java source code loaded into jvm,static blocks if present,will be executed first before main().
Core Java Interview Questions :What is similarities between an Abstract class and Interface?
Neither Abstract classes or Interface can be instantiated.:We can&
Core Java Interview Questions :What is runtime polymorphism or dynamic method dispatch?
In Java, runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. In this process, an overridden method is called through the reference variable of a superclass. The determination of the method to be called is based on the object being referred to by the reference variable.
Core Java Interview Questions :What is Polymorphism?
Polymorphism is briefly described as "one interface, many implementations." Polymorphism is a characteristic of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a variable, a function, or an object to have more than one form.
Core Java Interview Questions :What is method overriding?
Method overriding occurs when sub class declares a method that has the same type arguments as a method declared by one of its superclass. The key benefit of overriding is the ability to define behavior that?s specific to a particular subclass type.<br>Note:<br><br> The overriding method cannot have a more restrictive access modifier than the method being overridden (Ex: You can?t override a method marked public and make it protected).<br> * You cannot override a method marked final<br> * You cannot override a method marked static<br>
Core Java Interview Questions :What is method overloading?
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.:Method overloading refers to using of two methods with the same names in a class.
Core Java Interview Questions :what is main purpose of interface?
There is no multiple inheritance in java,we can&
Core Java Interview Questions :what is main purpose of abstract class?
if a class contains abstract method,that class must be declared as a abstract class. Abstract methods contains only declarations. it does not contain objects.:If a class contains abstract method,that class must be declared as a abstract class. Abstract methods contains only declarations. It does not contain objects.....:Even if a single method in a class is abstract then the class must be declared with the modifier abstract.:Abstract classes are class which provides partial implementation,so does&
Core Java Interview Questions :What is Inheritance?
* Inheritance is the process by which objects of one class acquire the properties of objects of another class.
Core Java Interview Questions :What is final modifier?
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.
Core Java Interview Questions :What is error?
An Error indicates that a non-recoverable condition has occurred that should not be caught. Error, a subclass of Throwable, is intended for drastic problems, such as OutOfMemoryError, which would be reported by the JVM itself.
Core Java Interview Questions :What is Encapsulation?
Encapsulation is a technique used for hiding the properties and behaviors of an object and allowing outside access only as appropriate. It prevents other objects from directly altering or accessing the properties or methods of the encapsulated object.:Wrapping up a data and function together in a singal unit is called encapsulation:combine the data & members in one :Writing Operations and methods stored in a single:encapsulation is nthing but of the binding the data n its related functionalities in a single unit ....:Encapsulation is a technique used for hiding the properties and behaviors of an object and allowing outside access only as appropriate. It prevents other objects from directly altering or accessing the properties or methods of the encapsulated object:It.s similar to the wrapping of choclate in a golden foil so that it doesn&
Core Java Interview Questions :What is Early Binding?
Early binding is nothing but declaring the Object of specific type but with this kind of object its cant be used to hold any other type of the Object/class.:Assigning values to variables during design time or exposing object model at design time.:Early binding means body provided during compilation time , Late binding means body will be provided during run time
Core Java Interview Questions :What is Dynamic Binding?
Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding (also known as late binding) means that the code associated with a given procedure call is not known until the time of the call at run-time. It is associated with polymorphism and inheritance.
Core Java Interview Questions :What is difference between an Abstract class and Interface?
1.Interfaces provide a form of multiple inheritance. A class can extend only one other class.:An Interface has only Abstract methods and final static variable, where as an Abstract class have both instances methods as well as abstract methods.:Abstract are the classes in which both abstract methods and concrete methods(the methods which have implementation) can be written whereas in interface only abstract methods which dont have implementation are there.Other difference is an abstract class can extend only one class but an interface can implement many classes which supports multiple inheritance.:Interfaces provide a common method&
Core Java Interview Questions :What is Constructor?
* A constructor is a special method whose task is to initialize the object of its class.:constuctor name and class name is must same:=>The main purpose of constructor is initializing the object with default values.
Core Java Interview Questions :What is Collection API?
The Collection API is a set of classes and interfaces that support operation on collections of objects. These classes and interfaces are more flexible, more powerful, and more regular than the vectors, arrays, and hashtables if effectively replaces.:The Collection API is a set of classes and interfaces that support operation on collections of objects. These classes and interfaces are more flexible, more powerful, and more regular than the vectors, arrays, and hashtables if effectively replaces.:The Collection API is a set of classes and interfaces.:A collection is simply an object. collections is a group of objects known as its elements. It is used to store, retrieve, manipulate the objects.
Core Java Interview Questions :What is a marker interface?
Marker interfaces are those which do not declare any required methods, but signify their compatibility with certain operations. The java.io.Serializable interface and Cloneable are typical marker interfaces. These do not contain any methods, but classes must implement this interface in order to be serialized and de-serialized.:I dont know
Core Java Interview Questions :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:Variable declared with in the scope of a method called Local Variable.:Local Variable:
Core Java Interview Questions :What is an Interface?
An interface is a description of a set of methods that conforming implementing classes must have.:Interface is a collection of method and data member that can be implemented by any number of class residing in a class hierarchy. Interface is also known as prototype for a class.
Core Java Interview Questions :What is an exception?
An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program&
Core Java Interview Questions :What is an abstract class?
Abstract classes are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation.:Class can be abstract even it doesn&
Core Java Interview Questions :What is Abstraction?
Abstraction refers to the act of representing essential features without including the background details or explanations.:-Hidding the data from user is called Abstraction.
Core Java Interview Questions :What if there is a break or return statement in try block followed by finally block?
If there is a return statement in the try block, the finally block executes right after the return statement encountered, and before the return executes.:If there is a break or return statement in try block.The statements before the break are executed in try block and it will go to final.The statements after the break are not executed.
Core Java Interview Questions :What do you understand by Synchronization?
Synchronization is a process of controlling the access of shared resources by the multiple threads in such a manner that only one thread can access one resource at a time. In non synchronized multithreaded application, it is possible for one thread to modify a shared object while another thread is in the process of using or updating the object&
Core Java Interview Questions :What do u mean constructor in java ?
A constructor creates an Object of the class that it is in by initializing all the instance variables and creating a place in memory to hold the Object. It is always used with the keyword new and then the Class name. For instance, new:Constructor in java::Constuctor is a definition block used to create the initial state of an object with the desired value.
Core Java Interview Questions :What do u mean by "method" in java ?
Java methods are similar to functions or procedures in other programming languages.:Methods are similar to functions or procedures that are available in other programming languages.:Methods are similar to functions or procedures that are available in other programming languages.
Core Java Interview Questions :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.:static key word is prefixed with field are method that is not issu in both case the memory is first allocated and aso to break the oops concept rule: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.: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.:Basically, static methods will be written in an application when user need to do static logic irrespective of the object wise coding. Similarly, static methods will be accessed at class level.:static members are called class members.class members are initialized only once ,at the time the class is loaded in to jvm.class members have only one copy for particular application and same copy used by all instances of that class.:All of the basic, we make the method static when we want to access that method before the class is instantiated. (i.e. calling the method without any object) and so is the main() method static.:If a member (ie methods & Fields) is declared as static then those things are belong to Class rather than Instances. You can access these static fields by using Class name.These members are also known as class members.:The static method or the fields can be instantiated only once per class. Any changes made to the static method will reflect within the scope. More over the the methods or the fields cannot be inherited.:static data can be accessed by only static members because this we can access any static member of other class in "public static void main()" function.:variables and methods accessed with out creating the instance of a class:static methods and variables are not object specific. Only one copy of them is there for all the objects of that class.
Core Java Interview Questions :What are wrapped classes?
Wrapped classes are classes that allow primitive types to be accessed as objects.:Java is Object Oriented Programing it means everything in java treated as object, inorder to convert primitive types/data types into objects we will use Wrapper classes. For Ex:The autoboxing and unboxing feature introduced to convert Primitive type to its wrapper class automatically .:Wrapper classes correspond to the primitive data types in the Java language. These classes represent the primitive values as objects.
Core Java Interview Questions :What are the uses of final method?
There are two reasons for marking a method as final::The reason behind making method final is that, if any class extends the class containing final method is not able to change the logic written in method which is declared as final
Core Java Interview Questions :What are the types of Exceptions in Java
There are two types of exceptions in Java, unchecked exceptions and checked exceptions.
Core Java Interview Questions :What are the similarities between an array and an Array List?
An array is indexed fixed number of homogeneous elements. :Both array and arraylist are collections of homogenous elements like int,etc. Both can store duplicate elements in an unordered way.
Core Java Interview Questions :What are the principle concepts of OOPS?
There are four principle concepts upon which object oriented design and programming rest. They are::there r 8 concepts in oops............they r.....
Core Java Interview Questions :What are the different ways to handle exceptions?
There are two ways to handle exceptions::There are three ways to handle exception.
Core Java Interview Questions :What are the differences between method overloading and method overriding?
Overloaded Method Overridden Method
Core Java Interview Questions :What are the differences between Interface and Abstract class?
Abstract Class Interfaces:Features
Core Java Interview Questions :What are the differences between Contructors and Methods?
Constructors Methods:Constructors are invoked using the new keyword. Methods can be invoked by using the dot operator on the object of the class.
Core Java Interview Questions :What are the differences between Class Methods and Instance Methods?
Class Methods Instance Methods
Core Java Interview Questions :What are the advantages of using exception handling?
Exception handling provides the following advantages over "traditional" error management techniques::exception Handling mechanism is used to execute the program even though errors are existing in it.it also used to show the non technical messages on the screen.these non technical messages are very useful to non technical peoples also :it is like filtering all the errors apart into the section where exception is being implemented and more shortly ,the errors which are existing which are responsible for the program not to be run is put in the exception handling part
Core Java Interview Questions :What are static variables?
Variables that have only one copy per class are known as static variables. They are not attached to a particular instance of a class but rather belong to a class as a whole. They are declared by using the static keyword as a modifier.
Core Java Interview Questions :What are static methods?
Methods declared with the keyword static as modifier are called static methods or class methods. They are so called because they affect a class as a whole, not a particular instance of the class. Static methods are always invoked without reference to a particular instance of a class.
Core Java Interview Questions :What are Access Specifiers available in Java?
Access specifiers are keywords that determines the type of access to the member of a class. These are:
Core Java Interview Questions :What are Access Specifiers?
One of the techniques in object-oriented programming is encapsulation. It concerns the hiding of data in a class and making this class available only through methods. Java allows you to control access to classes, methods, and fields via so-called access specifiers..:public, protected, private are the access specifiers...
Core Java Interview Questions :Is it possible to override the main method?
NO, because main is a static method. A static method can&
Core Java Interview Questions :How to invoke a superclass version of an Overridden method?
To invoke a superclass method that has been overridden in a subclass, you must either call the method directly through a superclass instance, or use the super prefix in the subclass itself. From the point of the view of the subclass, the super prefix provides an explicit reference to the superclass&
Core Java Interview Questions :How to define an Interface?
In Java Interface defines the methods but does not implement them. Interface can include constants. A class that implements the interfaces is bound to implement all the methods defined in Interface.:interface contains abstract methods only.It does not contain the body of the methods.It definitely override by the class which implement that method......:Interface is syntatically similar to classes. Its variables and methods are declared without any defination(body).
Core Java Interview Questions :How to define an Abstract class?
A class containing abstract method is called Abstract class. An Abstract class can&
Core Java Interview Questions :How to create custom exceptions?
By extending the Exception class or one of its subclasses.:class myexc extends Exception
Core Java Interview Questions :how many ways to create Thread and which one is good? runnable interface or Thread class?
Two ways to create threads:creating the thread by runnaable interface is best way of creating interface.b&
Core Java Interview Questions :How do you prevent a method from being overridden?
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.:to prevent a method from overriding,it must be qualified as final.
Core Java Interview Questions :How does the Java default constructor be provided?
If a class defined by the code does not have any constructor, compiler will automatically provide one no-parameter-constructor (default-constructor) for the class in the byte code. The access modifier (public/private/etc.) of the default constructor is the same as the class itself.:when we are not create any constructor then java take itself default constructor as(public,private,etc.)class.:but if you are providing the parameterized constructor u must provide the default constructor as well otherwise the complier will complain.....:The statement "but if you are providing the parameterized constructor u must provide the default constructor as well otherwise the complier will complain" is wrong. The compiler will not complain if you do not provide the default constructor with parameterized. But the user will not be allowed to create an object with the default constructor
Core Java Interview Questions :How does Java implement polymorphism?
(Inheritance, Overloading and Overriding are used to achieve Polymorphism in java).:(Inheritance, Overloading and Overriding are used to achieve Polymorphism in java).
Core Java Interview Questions :How are this() and super() used with constructors?
* Constructors use this to refer to another constructor in the same class with a different parameter list.
Core Java Interview Questions :Explain the user defined Exceptions?
User defined Exceptions are the separate Exception classes defined by the user for specific purposed. An user defined can created by simply sub-classing it to the Exception class. This allows custom exceptions to be generated (using throw) and caught in the same way as normal exceptions.:for eg: :User defines exception are Exception Subclasses. It allows you to create your own exception types to handle situations specific to your application....
Core Java Interview Questions :Explain the usage of the keyword transient?
This keyword indicates that the value of this member variable does not have to be serialized with the object. When the class will be de-serialized, this variable will be initialized with a default value of its data type (i.e. zero for integers).:Keyword "transient" indicates the JVM that this particular variable should not be serialized. Memory should be allocated at top level irrespective of the thread level.
Core Java Interview Questions :Explain the significance of try-catch blocks?
Whenever the exception occurs in Java, we need a way to tell the JVM what code to execute. To do this, we use the try and catch keywords. The try is used to define a block of code in which exceptions may occur. One or more catch clauses match a specific exception to a block of code that handles it.
Core Java Interview Questions :Explain the Polymorphism principle.
The meaning of Polymorphism is something like one name many forms. Polymorphism enables one entity to be used as general category for different types of actions. The specific action is determined by the exact nature of the situation. The concept of polymorphism can be explained as "one interface, multiple methods".
Core Java Interview Questions :Explain the Inheritance principle.
Inheritance is the process by which one object acquires the properties of another object.: INHERITENCE IS THE HEART BEAT OF OOPS BY WHICH WE CAN USE THE DATA MEMBERS OF BASE CLASS IN DERIVED CLASS.
Core Java Interview Questions :Explain the Encapsulation principle.
Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.:Encapsulation is the ability to hide implementation details by making class members(instance variables & methods) private or protected. So that you can make changes in your implementation code without breaking the code of others who use your code is a key benefit of encapsulation. :Encapsulation is one mechanism that enables the java developer to combine the data(can be attributes of an object),and actions (methods or behaviors) that perform on the data.:Encapsulation is one mechanism that enables the java developer to combine the data(can be attributes of an object),and actions (methods or behaviors) that perform on the data.:Encapsulation is a process of Wrapping data and functions into single unit.
Core Java Interview Questions :Explain the different forms of Polymorphism.
Polymorphism exists in three distinct forms in Java: :polymorphism is of two type-:The Greek Work "Poly" means many and "Morph" means forms. The Polymorphism has many types that depend on the situation in which we are use the concept on polymorphism. Like::Actually both method overloading and overriding are examples of runtime polymorphism.:polymorphism translates from Greek as many forms ( poly - many morph - forms):Universal polymorphism:
Core Java Interview Questions :Explain garbage collection?
Garbage collection is one of the most important feature of Java. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. User program cann&
Core Java Interview Questions :Do interfaces have member variables?
Interfaces may have member variables, but these are implicitly public, static, and final- in other words, interfaces can declare only constants, not instance variables that are available to all implementations and may be used as key references for method arguments for example.
Core Java Interview Questions :Describe the wrapper classes in Java.
Wrapper class is wrapper around a primitive data type. An instance of a wrapper class contains, or wraps, a primitive value of the corresponding type.:Wrapper class is wrapper around a primitive data type(i.e int,float,double,long).Some Examples Of wrapper classes are INTEGER,DOUBLE,LONG etc.:wraper class is a class. whose object are wrapped in to primitive data type. wraper class is basically use in convert into primitive data type to object
Core Java Interview Questions :Describe the principles of OOPS.
There are four main principals of oops which are called Polymorphism, Inheritance and Encapsulation and abstraction.
Core Java Interview Questions :Can we instantiate an interface?
You can?t instantiate an interface directly, but you can instantiate a class that implements an interface.:we can create the instance of interface:
Core Java Interview Questions :Can we instantiate an abstract class?
An abstract class can never be instantiated. Its sole purpose is to be extended (subclassed).:No we can not instantiate an abstract class. Even though its sole purpose is to be extended & define the general behavior, its meaningless to instantiate a class whose methods do not have implementation(body) or little(half/very less generalized) implementation.
Core Java Interview Questions :Can we have the try block without catch block?
Yes, we can have the try block without catch block, but finally block should follow the try block.:Yes It is possible to write a try without catch block, By using the finally block next to the try block
Core Java Interview Questions :Can we create an object for an interface?
Yes, it is always necessary to create an object implementation for an interface. Interfaces cannot be instantiated in their own right, so you must write a class that implements the interface and fulfill all the methods defined in it.:NO, Instance of an interface can not be creted however refrencing can be possible:no we can&
Core Java Interview Questions :Can there be an abstract class with no abstract methods in it?
Yes, there can be an abstract class without abstract methods.:no there cant be abstract class without abstract methods:Yes there can be an abstract class without an abstract method declared in it. But if there is even one method declared as abstract then this class must be declared as abstract.:Yes there can be a class which can be declared as ABSTRACT without any abstract methods. If any one method of class is declared as abstract then the class to which it belongs must be declared as abstract. There&
Core Java Interview Questions :Can overloaded methods be override too?
Yes, derived classes still can override the overloaded methods. Polymorphism can still happen. Compiler will not binding the method calls since it is overloaded, because it might be overridden now or in the future.
Core Java Interview Questions :Can constructor be inherited?
No, constructor cannot be inherited, though a derived class can call the base class constructor.
Subscribe to:
Posts (Atom)