EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

12. Describe the access modifiers in Java.

Public: Accessible everywhere.

Protected: Accessible within the same package and subclasses.

Default: Accessible within the same package only.

Private: Accessible within the same class only.

 

13. What is encapsulation? How is it implemented in Java?

Encapsulation is bundling data (variables) and methods into a single unit (class). It’s implemented using:

1. Private access modifiers for fields.

2. Public getter and setter methods for access.

 

14. Explain the concept of packages in Java.

Packages are namespaces used to group related classes and interfaces. They help avoid name conflicts and improve organization.

 

15. What are static variables and methods? Provide examples.

Static Variable: Belongs to the class, shared by all objects.

Static Method: Can be called without creating an object of the class.

java

CopyEdit

class Example (

static int count = 0; // Static variable

static void display() { //Static method System.out.println(“Count: count);

}

 

16. Discuss the lifecycle of a thread in Java.

1. New: Thread is created.

2. Runnable: Thread is ready to run.

3. Running: Thread is executing.

4. Blocked/Waiting: Thread is waiting for a resource.

5. Terminated: Thread execution is complete.

Java important interview questions

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer