core java most ask
core java most ask
No, class does not have private and protected as access modifier, class can be default and public.
Abstraction is the method of hiding the unwanted information. Whereas encapsulation is a method to hide the data in a single entity
or unit along with a method to protect information from outside.In abstraction, implementation complexities are hidden using
abstract classes and interfaces. While in encapsulation, the data is hidden using methods of getters and setters.
If we declare class as abstract it must be extended by another class but if we declare final class it cannot be extended by other class.
Object cloning means exact copy of Object by using Cloneable interface must be implemented by class and if you not implemented it
throws cloneNotSupportedException
Wrapper class is a mechanism which contains primitive data types of class and it converts to primitive data type to object and object
to primitive data type by using Autoboxing and unboxing technique.For example Primitive data type ‘char’ and wrapper class is
‘Character’
Can you implement pointers in a Java Program?No, Pointers are not available in java so, we cannot implement pointers
Nested or inner static class doesn’t need a reference of Outer class but a non static nested class or Inner class requires Outer class
reference.
Both dates are storing date and time information but java.sql.Date is used to communication of java applications with the database
but java.util.Date get time and date from the system.Sometimes we need to convert sql date into util date and vice versa based on
date formate
We have two types of inner classes one is static inner class and non static inner classInner class is defined as class provides another
class inside that class or group of classes in one place it is more reliable to maintain.
What is the anonymous class?Anonymous class is nothing but without a class name of inner class which is only create
single object and a anonymous class must be defined inside another classAnonymous class may have to create in two ways like class
and interface.
super keyword?The super keyword is used for refers to superclass (parent) objects and It is used to call superclass methods,
and to access the superclass constructor.
What is Custom exception? Custom Exception is nothing but user defined exceptions or own exception derived from
exception class