Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
9 views

Programming in Java

Programming in Java

Uploaded by

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

Programming in Java

Programming in Java

Uploaded by

deepak kumbhar
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Programming With Java

Core Concepts:

1. What is Java, and why is it called a "platform-independent" language?

2. Explain the difference between JDK, JRE, and JVM.

3. What are the main features of object-oriented programming (OOP)? Can you
name and describe the four pillars of OOP?

4 What are data types in Java? Mention a few primitive and non-primitive data
iypes.

5. What is the difference between a class and an object?

6. Explain access modifiers (public, private, protected, default) in Java.

7. Whatis the significance of the public static void main(String[]

args) declaration? Explain each keyword.


8. Can you have multiple main methods in a single Java class? Explain why or
why not.
9 How does garbage collection work in Java? What are its advantages?
10. What is the difference between checked and unchecked exceptions?

11. What is the purpose of the final keyword? Explain its use with variables,

methods, and classes.

12. What is type casting in Java? Explain implicit and explicit casting with
examples.

13. What are wrapper classes, and why are they used?

14. How does Java handle automatic type promotion?


15.What is the difference between local variables, instance variables, and class
variables (static variables)?

16. Explain the difference between the == operator and the .equals() method
for comparing objects.

17.What are bitwise operators, and when would you use them?

18. Explain the ternary operator (? :) in Java with an example.

19.What is operator precedence, and how does it affect the evaluation of


expressions?

20. What is short-circuit evaluation in the context of logical operators (&& and

||)?

Syntax and Control Flow:

1. What is the purpose of the main method in a Java program?


How do you declare and initialize variables in Java’?
What are the different types of operators in Java? Give some examples.

Explain conditional statements (12, else, switch) in Java with examples.

oe we oN

What are loops (for, while, do-while) used for? When would you use each
type?

6. What are labeled break and continue statements, and how are they used?
7. Explain the concept of "fall-through” in switch statements. How can it be

prevented?

8. What is the purpose of the return statement? Can a void method have a

return statement?

9. Explain the difference between break and System.exit() for terminating a

program.
Arrays and Strings:

1. Whatis an array? How do you create and access elements in an array?

2. How does a String differ from other data types in Java?

3. What are some common String manipulation methods (€.g., length (),
substring(), indexo£f() )?

4. What is the difference between an array and an ArrayList?

5. How do you find the length of an array in Java?

6. What is the default value of elements in an array of int, double, and boolean
types?

7. Can you resize an array after it has been created in Java? Explain your

answer.

8. What are multidimensional arrays? How do you declare and initialize them?

9 What is the enhanced for loop (for-each loop), and how is it used with arrays?
10. What happens if you try to access an element outside the bounds of an array?
11. Explain how to sort an array in Java.

12. How can you search for a specific element within an array?
Strings:

1. What is immutability in the context of strings? How does it affect string


manipulation?

2. How do you concatenate strings in Java?

3. What is the difference between the length property and the

length( ) method when dealing with arrays and strings?


4 Explain how to convert a string to an array of characters and vice
versa.

5. How would you check if a string is empty?


_ What is the difference between String, StringBuilder, and

StringBuffer? When would you use each?

_ What are regular expressions, and how can they be used with strings

in Java?

_ How do you compare two strings in a case-insensitive manner?

. How would you find the first non-repeating character in a string?

Object-Oriented Concepts

_ Explain inheritance in Java. What are its benefits?

. What is polymorphism, and how does method overriding and method

overloading relate to it?


What is encapsulation, and how does it help in achieving data hiding?

What is Abstraction, how to implement this?

Inheritance:

ee wf

_ What are the different types of inheritance supported in Java?

Explain the concept of "is-a" relationship in inheritance.


Can a class inherit from multiple classes in Java? Why or why not?

What is the difference between method overriding and method overloading?

What is the purpose of the super keyword?

How does inheritance promote code reusability?

What is the difference between a superclass and a subclass?


Polymorphism:

1. Whai are the two types of polymorphism in Java?


Explain dynamic (runtime) polymorphism with an example.
How does method overriding enable runtime polymorphism?

What is the role of the virtual method table (vtable) in polymorphism?

ao ff wf

What is the difference between upcasting and downcasting?

Abstraction:

1. Whatis an abstract class? How does it differ from a regular class?


Can you create an object of an abstract class? Explain.
What is an interface, and how does it relate to abstraction?

What is the difference between abstract classes and interfaces?

ao fw NM

When would you use an abstract class over an interface, and vice versa?

Encapsulation:

1. Explain the concept of encapsulation with an example.

2. How does encapsulation achieve data hiding?

3. What is the role of access modifiers (public, private, protected) in


encapsulation?

4. Why is encapsulation considered a good practice in OOP?

5. What are getter and setter methods, and how do they relate to encapsulation?

Additional OOP Concepts:

1. What is the purpose of the this keyword?

2. Explain the concept of object composition.

3. What is the difference between association, aggregation, and composition?


4 What are the SOLID principles of object-oriented design?

5. Explain the concept of dependency injection and its benefits.

You might also like