-->

IBM Integration Bus (IBM Message Broker)

This site is under construction

Wednesday, August 31, 2016

Core Java



1. what is the access modifiers/specifiers or what is the difference between them?

A) Access modifiers/specifiers:
               








         JVM(java virtual machine) Architecture 


            
                   





 Reference 

                   https://www.youtube.com/watch?v=dncpVFP1JeQ





Q) Difference between array and ArrayList in java?
Sol:
   Refer:
      
http://javahungry.blogspot.com/2015/03/difference-between-array-and-arraylist-in-java-example.html



Q)  What is Generics in java and what is use of the Generics?

sol:

 Reference:    
http://www.javatpoint.com/generics-in-java





Q) Difference between DAO and DTO in Java?
Sol:
      Data Access Object (DAO)
      DAO is a class that usually has the CRUD operations like save, update, delete.

     Data Transfer Object (DTO).
     The DTO is just an object that holds data. It is really a bean with instance variables and setter and getters.


 Reference:
   https://coderanch.com/t/99834/difference-DTO-DAO


Q) AutoBoxing and AutoUnboxing in Java?



AutoBoxing(wrapping):
·         Converting  primitive data types into reference type or corresponding object wrapper class is called AutoBoxing
·         Java compiler performs automatic conversation.
·         Ex:      int a= 10;
          Integer b = a:
·         Here we are assigning primitive value to object type. Internally java compiler converts below conversation operation.
       Integer b = Integer.valueOf (a);

AutoUnBoxing(unwrapping):
·         Converting  reference type or object  of wrapper class into primitive data types is called AutoUnBoxing
·         Java compiler performs automatic conversation.
·         Ex:      Integer a= 100;
             int b = a:
·         Here we are assigning object to primitive type. Internally java compiler converts below conversation operation.
       int b =a.intValue();
·         Using reference type will reduces performance because it has to recreate the object first then memory created in the heap.
·         Primitive types will have default values so need of checking null check on the primitive types.
Ex: int a;
Means int default value is 0
·         Object types of default values are null. We have to apply null check object/reference types.
·         All primitive types will have corresponding wrapper class.


Q) Generics  in Java ?
Generics:
·         The purpose of Generics is to provide Type Safety and to resolve typecasting.
·         Arrays are type safety that means it will store only specified data type in the array but the size is fixed.
Ex: Array[String ]  a = new [String](10);
·         Collections are not type safety which means it can store any kind of data type.
·         To achieve  above  two draw backs in arrays and collections Generics are introduced which generics is type safety and size is not fixed.
Ex:  Box<Integer> integerBox = new Box<Integer>();
·         Generics will accept only object type but not primitive types.
Ex: List<Integer> a = new Arraylist<>();  correct
       List<int> a = new Arraylist<>();  is wrong because int is primitive type.   


Q)  How to print the  SQL query which is used in hibernate or spring in the console using log4j?
 A) log4j.logger.org.hibernate.SQL=debug
 


Q) how to add jar to M2 repository manually ?
A)
mvn install:install-file -Dfile=<physical location of the jar file with name> -DgroupId=<groupId> -DartifactId=<artifactId> -Dversion=<version> -Dpackaging=jar

  



No comments :

Post a Comment