Skip to main content

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). Therefore, native methods allow Java Developer to directly access platform specific APIs. Often, native methods are linked to native library.

3. What is System class?

System.class is a final class provided by java.lang package. It contains several useful class fields and methods. The purpose of System class is to provide access to system resources.

4. What is System, out and println in System.out.println method call?

System is a final class provided by java.lang package. out refers to PrintStream class and a static member of System class. println is a method of PrintStream class.

5. What is the other name of Shallow Copy in Java?

Object Cloning. A Shallow Copy just copies the values of references in a Class.

6. What is the difference between Shallow Copy and Deep Copy in Java?

A Shallow copy just copies the values of the references in the class. A Deep copy copies the values of the objects as well.

7. What is a Singleton class?

A Singleton class in Java has maximum one instance of the class present in JVM, all the time. The constructor of this class is written in such a way that it never creates more than one object of same class.

8. What is the difference between Singleton class and Static class?

A static class in Java has only static methods. It is a container of functions. It is created based on procedural programming design. Singleton class is a pattern in Object Oriented Design. A Singleton class has only one instance of an object in JVM. This pattern is implemented in such a way that there is always only one instance of that class present in JVM.





Comments

Popular posts from this blog

DOCKER Interview questions

DOCKER 1. What is Docker? Docker is Open Source software. It provides the automation of Linux application deployment in a software container. We can do operating system level virtualization on Linux with Docker. Docker can package software in a complete file system that contains software code, runtime environment, system tools, & libraries that are required to install and run the software on a server. 2. What is the difference between Docker image and Docker container? Docker container is simply an instance of Docker image. A Docker image is an immutable file, which is a snapshot of container. We create an image with build command. When we use run command, an Image will produce a container. In programming language, an Image is a Class and a Container is an instance of the class. 3. How will you remove an image from Docker? We can use docker rmi command to delete an image from our local system. Exact command is: % docker rmi <Image Id> If we want to fin...

Amazon Web Services(AWS) Interview questions

Amazon Web Services 1. What do you know about AWS Region? An AWS Region is a completely independent entity in a geographical area. There are two more Availability Zones in an AWS Region. Within a region, Availability Zones are connected through lowlatency links. Since each AWS Region is isolated from another Region, it provides very high fault tolerance and stability. For launching an EC2 instance, we have to select an AMI within the same region. 2. What are the important components of IAM? The important components of IAM are as follows: 1.     IAM User : An IAM User is a person or service that will interact with AWS. User can sign into AWS Management Console for performing tasks in AWS. 2.     IAM Group : An IAM Group is a collection of IAM users. We can specify permission to an IAM Group. This helps in managing large number of IAM users. We can simply add or remove an IAM User to an IAM Group to manage the permissions. 3. ...

Top 80+ Android Interview Questions and Answers

Top 80+ Android Interview Questions Answers Basic Android interview questions for experienced and freshers developers and testers: In this technological era, there is a huge demand for Android Application developers and it is one of the highly paid jobs too. Hence many tech-savvy people are trying to make their way into this career. There are several tricky interview questions that are asked in many MNC’s and some small scale companies. And this article includes a set of such Android interview questions and answers that will be helpful to millions of job seekers. Let’s Explore!! Android Interview Questions This article includes a set of most commonly asked android interview questions and answers covering almost all the important concepts in simple terms in order to enable any job seeker to clear the interview successfully. Most Popular Android Interview Questions & Answers Given below is the list of most commonly asked Android Interview questions 01. What is android? Android is a ...