0% found this document useful (0 votes)
74 views

Java Interview Que

The document contains questions related to various Java programming concepts grouped under different topics. Some of the main topics covered include: - Core Java concepts like OOPs principles (abstraction, encapsulation, inheritance, polymorphism), JDK vs JRE vs JVM - Java data types, operators, control statements - Arrays and common array operations - Strings and String class methods - Classes and objects, constructors - Inheritance and exception handling The document provides a list of questions under each topic to help assess knowledge of fundamental and advanced Java concepts for interview preparation. There are over 50 questions related to concepts like variables, methods, exception handling etc.

Uploaded by

Charan Andey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

Java Interview Que

The document contains questions related to various Java programming concepts grouped under different topics. Some of the main topics covered include: - Core Java concepts like OOPs principles (abstraction, encapsulation, inheritance, polymorphism), JDK vs JRE vs JVM - Java data types, operators, control statements - Arrays and common array operations - Strings and String class methods - Classes and objects, constructors - Inheritance and exception handling The document provides a list of questions under each topic to help assess knowledge of fundamental and advanced Java concepts for interview preparation. There are over 50 questions related to concepts like variables, methods, exception handling etc.

Uploaded by

Charan Andey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Core Java Interview Questions

Other Questions

⚫ What History of java?


⚫ What Difference between java and C++?
⚫ What Difference between JDK , JVM & JRE ?
⚫ What is difference between static & dynamic binding?
⚫ What are escape sequences in Java?
⚫ What is Variables & tell us it’s naming roles?
⚫ What is the use of super & this keyword in java?
⚫ What is class & Object in java?
⚫ What is Abstraction in java? Explain with real world example.
⚫ What is Encapsulation in java? Explain with real world example.
⚫ What is Inheritance in java? Explain with real world example.
⚫ What is Polymorphic in java? Explain with real world example.

Topic :- Data Type

⚫ What are the primitive data types in Java?


⚫ Explain the differences between int and Integer.
⚫ What is the default value of the all primitive data type in Java?
⚫ Why use a primitive data type like int instead of an object type like Integer?
⚫ Explain the concept of a "floating-point" data type in Java.
⚫ What is the difference between float and double data types in Java?
⚫ Explain the concept of "type casting" or "type conversion."
⚫ What is "autoboxing" and "unboxing" in Java?
⚫ Explain the concept of "widening"(implicit) and "narrowing"(Explicit) conversions.
⚫ What is the purpose of the String data type in Java?
⚫ What is the default value of the boolean data type in Java?

Topic :- Operators

⚫ What is operators in Java?


⚫ Differentiate between unary, binary, and ternary operators.
⚫ Explain the difference between the == operator and the equals() method for comparing objects.
⚫ Explain the difference between the pre-increment and post-increment operators.
⚫ What is operator precedence in Java?
⚫ What is the difference between the & and && operators?
⚫ What is the use of the instanceof operator in Java?
⚫ What is the difference between == and equals() for comparing strings?
Topic :- Control Statements

⚫ What are control statements in Java?


⚫ Differentiate between conditional and looping control statements.
⚫ Explain the switch statement in Java.
⚫ What is the difference between the while and do-while loops?
⚫ What is an infinite loop, and how can it be created?
⚫ What is the break & continue statement used for?
⚫ What is the purpose of the labeled break and labeled continue statements?

Topic :- Array

⚫ What is an array & it's type in Java?


⚫ How to declared each types of array in java?
⚫ How do you access elements of an array in Java?
⚫ What is the use of length variable in array in Java?
⚫ Can we put array index with negative value?
⚫ When IndexOutofBounds Exception come?
⚫ What is irregular array in java?
⚫ What is anonymous Array in java?
⚫ How would you iterate through elements of an array using a for loop?
⚫ Explain the concept of a multidimensional array.
⚫ What is the difference between an array and an ArrayList?
⚫ Explain the java.util.Arrays class.
⚫ Explain the concept of an array initializer in Java.
Coding Question of Array :-

⚫ How do you find the maximum and minimum values in an array?


⚫ How do you sort an array in ascending order in Java?
⚫ Find the Missing Number.
⚫ Kth Largest Element in an Array
⚫ Find duplicate element in Array.

Topic :- Command Line Argument

⚫ What is command line argument concept in java?


⚫ How do you pass command-line arguments to a Java program?
⚫ Explain the main method in Java.
⚫ How can you access command-line arguments inside the main method?
⚫ What is the purpose of the String[] args parameter in the main method?
⚫ Give an example of a Java program that takes two integers as command-line arguments and
prints their sum.
⚫ How would you handle the scenario when the required number of command-line arguments is
not provided?
⚫ Explain how to convert command-line arguments from strings to other data types.
⚫ What happens if you provide non-integer values as command-line arguments in a program that
expects integers?
⚫ Is there a limit to the number of command-line arguments that can be passed to a Java program?
⚫ Can you modify the command-line arguments within the main method?
⚫ How can you provide multiple space-separated words as a single command-line argument?
⚫ Can you use command-line arguments in Java applications that have a graphical user interface
(GUI)?

Topic :- Instance & Local variable

⚫ What is an instance variable in Java?


⚫ What is a local variable in Java?
⚫ Difference between instance & local variable.
⚫ What is the scope of an instance variable?
⚫ What is the scope of a local variable?
⚫ Do instance variables have default values in Java? if yes, So what are the default value with each
data type.
⚫ Do local variables have default values in Java?
⚫ What is the difference between instance variables and class variables?
⚫ Can instance variables be accessed from static methods?
⚫ Can we create local variables as static?
⚫ Are instance variables thread-safe?
⚫ Are local variables thread-safe?
⚫ When is memory allocated for instance variables and local variables?
⚫ What is the lifetime of instance variables and local variables?

Topic :- String class

⚫ What is a string in Java?


⚫ How can you create an instance of the String class in Java?
⚫ What is the difference between string literals and String objects created using new?
⚫ How do you concatenate strings in Java?
⚫ Why String is immutable in java
⚫ What is String immutability?
⚫ How to create immutable class in java?
⚫ What is difference between immutable & final?
⚫ What are the String class methods name?
⚫ Explain the length() method of the String class.
⚫ What is the charAt() method used for?
⚫ How do you compare strings in Java?
⚫ Explain the substring() method of the String class.
⚫ What is the purpose of the trim() method?
⚫ How can you convert a string to uppercase or lowercase?
⚫ What is the split(), indexOf(), replace() method used for?
⚫ Can strings be modified after they are created?

Topic :- Constructor

⚫ What is a constructor in Java?


⚫ What is the purpose of a constructor?
⚫ What is the naming convention for constructors?
⚫ Can a class have multiple constructors?
⚫ What are the types of constructor in java?
⚫ What is the default constructor?
⚫ What is constructor chaining?
⚫ Can constructors have return types?
⚫ Does constructor return anything?
⚫ Can constructors be inherited in Java?
⚫ What is the role of the this() constructor call?
⚫ What happens if you don't explicitly define any constructors in a class?
⚫ Who is responsible to create a default constructor in java?
⚫ Can you call a constructor directly like a method?
⚫ What is the difference between a constructor and a method?
⚫ Can you make a constructor private? If yes, why would you do that?
⚫ Can constructors be overridden in Java?
⚫ What is the order of execution when creating an object with constructors and instance
initialization blocks?
⚫ What is the difference between a default constructor and a parameterized constructor?
⚫ Can you call one constructor from another constructor of the same class?
⚫ Explain the concept of constructor overloading.
⚫ Can we create constructor as final?
⚫ Can we create constructor as static?
⚫ What is the purpose of a no-argument constructor in a class with other constructors?
⚫ How can you prevent a class from being instantiated using constructors?
⚫ Can constructors throw exceptions?
⚫ What happens if you create a constructor that takes no arguments and don't define a default
constructor?
⚫ Can constructors be used to initialize static variables?
⚫ What is an instance initialization block, and how does it relate to constructors?
⚫ Can you create an abstract class with constructors?
⚫ What is the role of the super() constructor call?
⚫ Can constructors have access modifiers such as public, private, or protected?
⚫ How is constructor execution ordered when creating a subclass object?
⚫ Can a constructor be abstract?
⚫ Can constructors be marked as synchronized?
⚫ What is the difference between an instance initializer block and a constructor?
⚫ Can constructors throw checked exceptions?
⚫ Is it possible to create a constructor with var args type parameter?

Topic :- Inheritance

⚫ What is inheritance in Java?


⚫ What are the benefits of inheritance?
⚫ How is inheritance represented in Java?
⚫ What is a superclass and a subclass?
⚫ What is method overriding?
⚫ Can a subclass access private members of its superclass?
⚫ Can a subclass access final methods of its superclass?
⚫ How does the Object class relate to inheritance in Java?
⚫ Can a class inherit from multiple classes in Java?
⚫ What is the purpose of the protected access modifier?
⚫ Explain the final class modifier and its implications for inheritance.
⚫ Can constructors be inherited from the superclass in Java?
⚫ What is the purpose of the @Override annotation when overriding methods?
⚫ Can a subclass access the private members of its superclass using inheritance?
⚫ What is the purpose of the Object class's clone() method?
Topic :- Exception Handling

⚫ What is an exception in Java?


⚫ What is exception handling?
⚫ What are the types of exception in java?
⚫ What is the purpose of exception handling in Java?
⚫ How is exception handling done in Java?
⚫ When exception is generated compile time or runtime?
⚫ Explain the try-catch block.
⚫ What is finally block & it's use in java?
⚫ Can you have multiple catch blocks in a single try statement?
⚫ Can you have a finally block without a catch block?
⚫ Can you have a try block without any catch & finally block?
⚫ What is the purpose of the throw statement?
⚫ What is the purpose of the throws statement?
⚫ What are the differences between checked and unchecked exceptions?
⚫ Can you catch multiple exceptions in a single catch block?
⚫ Can you throw an exception from a finally block?
⚫ What is the role of the try-with-resources statement?
⚫ What happens if an exception is thrown within a catch block?
⚫ What will happen if we use return statement in try block & we have also finally block?
⚫ What is the difference between System.out.println() and System.err.println()?
⚫ Explain the concept of try-with-resources and why it's beneficial.
⚫ Can you throw an exception without using the throw statement?
⚫ What is the difference between the printStackTrace() and getMessage() methods of the
Throwable class?
⚫ What is the difference between throw & throws keyword?
⚫ Can you catch an exception of a superclass type before catching a subclass type?
⚫ If super class is not throws any exception. So can sub class throws any exception?
⚫ Is it mandatory to catch or declare checked exceptions in Java?
⚫ What is the purpose of the getMessage() method in exceptions?
⚫ Can we have nested try-catch blocks?
⚫ What is the difference between the catch block and the finally block in exception handling?
⚫ Can you throw multiple exceptions in a single throw statement?
⚫ Can you rethrow an exception caught in a catch block?
⚫ What happens if an exception is thrown in a finally block?
⚫ What is the purpose of creating custom exception classes?
⚫ Explain the concept of exception chaining.
⚫ Explain the concept of stack trace in the context of exceptions.
⚫ What is the the exception propagation?
⚫ Can you catch an Error in a try-catch block?
⚫ What is the purpose of the RuntimeException class?
⚫ By how many way we can print an exception?
⚫ What is fully checked Exception?
⚫ What is partially checked exception?

Topic :- static keyword

⚫ What is static keyword in Java?


⚫ What is the use of static keyword in java?
⚫ What things can we static?
⚫ What is a static variable in Java?
⚫ How is a static variable different from an instance variable?
⚫ Can a static variable be accessed without creating an object of the class?
⚫ What is a static method in Java?
⚫ Can you override a static method in a subclass?
⚫ What is the purpose of a static block?
⚫ What is the use of static variable in java?
⚫ What is the difference between a static block and instance block & a constructor?
⚫ Can you use the this & super keyword in a static method?
⚫ What is the difference between a static import and a regular import statement?
⚫ Can a static method access instance variables?
⚫ Can a static method call a non-static method?
⚫ What are the restrictions on using static methods?
⚫ Can a class be both final and static?
⚫ Can outer class be static?
⚫ What is the role of the ClassLoader in loading static members?
⚫ Can you use the static keyword with local variables or parameters?
⚫ Explain the Singleton design pattern and how the static keyword is used in its implementation.
⚫ What is a static initializer or static block?
⚫ What is the difference between a static variable and a constant (i.e., final static variable)?
⚫ Where static things are gets saved in java?
⚫ What is the significance of the main method being declared as static?
⚫ Can you declare a static constructor in Java?
⚫ What is the difference between a static variable and a static method?
⚫ Can you access non-static members in a static method using an instance of the class?
⚫ What is the significance of the static keyword in the context of memory efficiency?
⚫ Tell me condition where you will use static in java?
⚫ Can we have more than one static & instance block in java?
⚫ Does JVM calls main method by creating instance of class?
⚫ Explain System.out.println()
⚫ Can we create static object in java?

Topic :- Polymorphism

⚫ What is polymorphism in Java?


⚫ Explain the two types of polymorphism in Java.
⚫ How is method overloading achieved in Java?
⚫ What is method overriding in Java?
⚫ What is dynamic method dispatch?
⚫ Can constructors be overridden in Java?
⚫ What is the difference between compile-time polymorphism and runtime polymorphism?
⚫ Can you use method overloading and method overriding together in the same class hierarchy?
⚫ What is the significance of the super keyword in method overriding?
⚫ Can you override a private or final method in Java?
⚫ How does polymorphism contribute to code reusability and extensibility?
⚫ What is an abstract class, and how does it relate to polymorphism?
⚫ What is the difference between method overloading and method overriding?
⚫ Can we override final, private & static method in java?
⚫ What is covariant return type in Java?
⚫ What is method hiding?
⚫ Difference between method hiding & method overriding?
⚫ Can we have different return type in method overriding?
⚫ Can we have different return type in method overloading?
⚫ Can you achieve runtime polymorphism with variables and fields?
⚫ How does polymorphism contribute to the concept of loose coupling in software design?
Topic :- Varargs

⚫ What are varargs in Java?


⚫ How are varargs implemented in Java methods?
⚫ Can a method have multiple parameters along with a varargs parameter?
⚫ What happens if you pass no arguments to a varargs method?
⚫ Can a method have multiple varargs parameters?
⚫ How can you call a method with varargs?
⚫ What is the data type of the parameter used for varargs?
⚫ Can you pass an array to a varargs parameter?
⚫ Can you define a method with both an array parameter and a varargs parameter with the same
data type?
⚫ Can you pass arguments of different data types to a varargs method?
⚫ Can you make a method with varargs final or abstract?
⚫ Can we override varargs parameter in java?

Topic :- final keyword

⚫ What is the final keyword in Java?


⚫ How is the final keyword used with variables?
⚫ Can a final variable be modified after its initial assignment?
⚫ Can a final method be overloaded in a subclass?
⚫ Can an abstract class be marked as final?
⚫ Can a final class have final methods?
⚫ Can constructor parameters be marked as final?
⚫ Can an interface have final methods?
⚫ What is the purpose of the final keyword in the context of security?
⚫ Can you declare a final constructor in Java?
⚫ Is it necessary to initialize a final variable at the time of declaration?
⚫ What is blank final variable?
⚫ How do you initialize blank final variable?
⚫ Can we assign value with the help of constructor & instance block simultaneously?
⚫ Can a class have both final methods and abstract methods?
⚫ Is it possible to mark an interface as final?
⚫ Can a final method be synchronized?
⚫ Can a final class have non-final methods?

Topic :-Package

⚫ What is a package in Java?


⚫ Why are packages used in Java?
⚫ What is the default package in Java?
⚫ What are the access modifier & how it used in package & scopes?
⚫ What access modifier will be consider by the JVM. If there is no access modifier?
⚫ How are classes organized within packages?
⚫ What is the naming convention for packages in Java?
⚫ How do you declare a class to be part of a specific package?
⚫ Can you use classes from the same package without an import statement?
⚫ What is the purpose of the import statement in Java?
⚫ Can you use classes from the default package in other packages?
⚫ Can you have duplicate package names in different parts of the classpath?
⚫ How can you create a sub-package within an existing package?
⚫ Can you have private and protected top-level classes in a package?

Topic :- Abstraction

⚫ What is abstraction?
⚫ What is an abstract class in Java?
⚫ What is the purpose of an abstract class?
⚫ Can you create an instance of an abstract class?
⚫ Can an abstract class have non-abstract methods?
⚫ Can an abstract class have instance variables?
⚫ Can you define a constructor in an abstract class?
⚫ What is an abstract method in Java?
⚫ Can an abstract class have no abstract methods?
⚫ Can an abstract class implement an interface?
⚫ Can a class be both abstract and final?
⚫ Can a class be both abstract and static?
⚫ Can an abstract class extend another class in Java?
⚫ Why would you use an abstract class instead of an interface?
⚫ Can an abstract method be private or final?
⚫ Can you create an abstract class without any methods?
⚫ Can an abstract class have a static method?
⚫ Can an abstract class be marked as public and have a protected constructor?
⚫ What is the difference between an abstract class and an interface?
⚫ Why can't you create an instance of an abstract class?
⚫ Can an abstract class extend multiple abstract classes?
⚫ Can we create main method class as abstract?

Topic :- interface

⚫ What is an interface in Java?


⚫ Can you create an instance of an interface in Java?
⚫ What is the purpose of using interfaces in Java?
⚫ Can we create an instance of interface?
⚫ Does .class file generate for interface?
⚫ Can a class implement multiple interfaces in Java?
⚫ Can an interface extend another interface?
⚫ Can an interface extend multiple interfaces?
⚫ Can an interface have instance variables?
⚫ Can an interface have constructors in Java?
⚫ Can an interface have a static method in Java?
⚫ Can an interface have a default method in Java?
⚫ Can an interface have a private method in Java?
⚫ Can an interface have protected access modifier for its methods?
⚫ Can an interface extend a class?
⚫ Can an interface have a non-public method?
⚫ What is the purpose of the @FunctionalInterface annotation?
⚫ Can an interface extend an abstract class?
⚫ Can an interface have a static variable in Java?
⚫ Can an interface extend a final class?
⚫ Can an interface extend a default method from another interface?
⚫ What is the purpose of the super keyword when implementing an interface with a default
method?
⚫ Can an interface extend a class and another interface at the same time?
⚫ Can a class implement multiple interfaces that have methods with the same name?
⚫ Can a private method in an interface be overridden in an implementing class?
⚫ What is marker interface?
⚫ What is the purpose of the marker interface pattern in Java?
⚫ What is serializable interface?
⚫ What is functional interface?
⚫ Can a protected method in an interface be accessed in implementing classes?
⚫ Can an interface have a method with a final keyword?

Topic :- I/O

⚫ What is I/O in Java?


⚫ What are the primary streams used for I/O in Java?
⚫ What is the difference between byte streams and character streams?
⚫ What is the purpose of the java.io package in Java?
⚫ What is the difference between file I/O and stream I/O?
⚫ What is a file in Java I/O?
⚫ How do you read from a text file in Java?
⚫ How do you write to a text file in Java?
⚫ What is the purpose of byte streams like InputStream and OutputStream?
⚫ How can you read binary data from a file using byte streams?
⚫ How can you write binary data to a file using byte streams?
⚫ What is the purpose of the DataInputStream and DataOutputStream classes?
⚫ What is the purpose of the ObjectInputStream and ObjectOutputStream classes?
⚫ What is the difference between Reader and InputStreamReader in Java I/O?
⚫ What is the purpose of the Scanner class in Java?

You might also like