100 Core Java Interview Questions and Answers - Part 10

Here are top selected core java interview questions asked in high level interviews, these questions may be helpful for both freshers or experienced professional going for interview.

91) What is synchronization in Java?

In java synchronization is the ability to control the access of multiple threads to shared resources. Synchronization ensures that only one thread can access a shared resource at a time.

92) What are wrapper classes in Java.

Java provides some equivalent classes to represent primitive types as object these classes are called wrapper classes. There are 8 wrapper classes in java ; Byte, Short, Integer, Long, Float, Double, Character and Boolean.

93) Can we have more than one class declaration in a single java file.

We can have only a single public class declaration per java file, whereas we can have multiple non-public classes in a single java file.

94) Can we declare main() method as private?

No, We cannot declare main() method as private. If we does so the program will compile fine but at runtime it will give ?Main Method Not Public? message.

95) Explain System.out.println() briefly?

System is a predefined final class, out is a PrintStream object and println is a built-in overloaded method in the out object.

About The Author

Nagesh Chauhan

Nagesh Chauhan has 8+ years of software design and development experience in variety of technologies like - Core Java, Java 8 (Streams, Lambda), J2EE (Servlet, JSP), Spring Framework (MVC, IOC, JDBC, SECURITY etc), Spring Boot and Microservices, Kafla, Redis, Cassandra and Spark.