Skip to main content

Posts

Showing posts with the label Java Tricky Mixed

Mixed Java Tricky Interview Questions

Tricky Mixed Interview Questions 1. What are Wrapper classes in Java? Java has concept of Wrapper classes to allow primitive types to be accessed as objects. Primitive types like boolean, int, double, float etc. have corresponding Wrappers classes – Boolean, Integer, Double, Float etc. Many of these Wrapper classes are in java.lang package. Java 5.0 has launched the concept of Autoboxing and Unboxing in Java for Wrapper classes. E.g. public class WrapperTest{ public static void main(String args[]){ //Converting int into Integer int count=50; Integer i=Integer.valueOf(count); //converting int into Integer Integer j=a; //autoboxing, now compiler will write Integer.valueOf(count) internally System.out.println(count+" "+i+" "+j); } } 2. What is the purpose of native method in Java? The native keyword is used for applying to a method to indicate that the method is implemented in native code using JNI(Java Native Interface). The...