Another important concept while learning object oriented programming was understanding how variables behave inside a program. Depending on where a variable is declared and how it is used, Java treats it differently. Things that became clear : • local variables are declared inside methods and exist only during that method execution • instance variables are declared inside a class but outside methods, and each object gets its own copy • static variables belong to the class itself and are shared among all objects • local variables do not get default values, while instance and static variables do • the place where a variable is declared affects its lifetime and accessibility Seeing these differences made it clearer how memory and data management work inside a Java program. Understanding variable behaviour also helps avoid common mistakes when writing larger programs. #java #oop #programming #learning #dsajourney
Lakhyadeep Sen’s Post
More Relevant Posts
-
While learning object oriented programming in Java, the next step was understanding classes and objects. At first the terms sounded simple, but writing small examples made the idea clearer. Things that became clear : - a class acts like a blueprint that defines what properties and behaviours something will have - an object is the actual instance created from that blueprint - objects allow programs to represent real world entities in code - data and the operations on that data stay grouped inside the same structure - multiple objects can be created from the same class, each having its own state A simple example helped visualize this better : class Student { int rollNo; String name; void display() { System.out.println(rollNo + " " + name); } } Objects created from this class can store different student details while using the same structure. Understanding this idea made it clearer how Java programs move from simple logic to modelling real world entities. #java #oop #programming #learning #dsajourney
To view or add a comment, sign in
-
While studying object oriented programming in Java, access modifiers explain how data and methods can be accessed from different places in a program. They help control visibility and protect the internal structure of classes. Things that became clear : • access modifiers define where a variable or method can be accessed • private members are accessible only inside the same class • default members are accessible within the same package • protected members are accessible within the same package and also in subclasses • public members can be accessed from anywhere These access levels help control how different parts of a program interact with each other. A simple structure shows how access modifiers appear in code : class Example { private int a; int b; protected int c; public int d; } Using the correct access level helps maintain better control over data and keeps the program structure organized. #java #oop #programming #learning #dsajourney
To view or add a comment, sign in
-
Completed the object oriented programming section in Java. At the beginning it felt like a collection of separate topics, but while going through the concepts step by step it became clearer how everything connects. Things that stood out while learning this section : - classes and objects form the basic structure of object oriented programs - variables, constructors, and access modifiers help control how objects are created and how data is accessed - encapsulation protects internal data and allows controlled interaction - inheritance allows classes to reuse behaviour instead of rewriting logic - polymorphism makes programs more flexible by allowing the same operation to behave in different ways - abstraction helps focus on what an object does rather than how it does it One noticeable shift was moving from thinking about programs as a sequence of steps to thinking about them as groups of interacting objects. The concepts are simple individually, but together they create a much more organized way of designing programs. #java #oop #programming #learning #dsajourney
To view or add a comment, sign in
-
🔐 Today I Learned: Access Modifiers in Java Understanding access modifiers is key to writing secure, maintainable, and scalable code. Here’s a quick breakdown 👇 ✅ public → Accessible from anywhere Used when you want to expose functionality globally (APIs, main methods) 🔒 private → Accessible only within the same class Best for data hiding & encapsulation 📦 default (package-private) → Accessible within the same package Useful for internal communication between classes 🧬 protected → Accessible within package + outside package via inheritance Mainly used in parent-child relationships 💡 Key Takeaways: private = highest restriction public = no restriction protected = inheritance-based access default = package-level access 📊 Choosing the right access modifier helps in: ✔ Encapsulation ✔ Code security ✔ Better design #Java #Programming #OOP #Encapsulation #Coding #Developer #SoftwareEngineering #Learning #Tech #JavaDeveloper #Java #OOP #Inheritance #Programming #Coding #JavaDeveloper #Learning #InterviewPrep #Java #JavaProgramming #JavaDeveloper #SoftwareDevelopment #Programming #Coding #BackendDevelopment #TechLearning #Developers #LearnToCode #ProgrammingCommunity #100DaysOfCode #CodeNewbie #TechCareer #SoftwareEngineer
To view or add a comment, sign in
-
-
Another important concept while working with classes in Java is the constructor. Constructors are closely related to object creation and help initialize the data inside an object. Things that became clear : • a constructor is a special method used to initialize objects • it has the same name as the class • constructors do not have a return type • they are called automatically when an object is created • they are commonly used to set initial values for instance variables A simple example helps illustrate the idea : class Employee { String name; int age; Employee() { System.out.println("Constructor called"); } } Whenever an object of the class is created, the constructor runs automatically and prepares the object for use. Understanding constructors made it clearer how Java ensures that objects start with proper initial values. #java #oop #programming #learning #dsajourney
To view or add a comment, sign in
-
🚀 Java Concepts Made Simple (Visual Notes) While learning Java, I created my own notes to understand concepts like: • JVM & JRE • Platform Independent Programming • Classes & Objects • Variables & Data Types • Naming Conventions • Type Casting Later I enhanced these notes using AI to make them cleaner and more readable, so anyone starting with Java can understand them easily. Swipe through the slides to explore the concepts 📚 If you are learning Java, save this post for revision. Anshika Sinha Sonam Yadav Roshani Kumari #java #programming #coding #javadeveloper #learnjava #computerscience #codingjourney
To view or add a comment, sign in
-
Java Learning Journey – Day 12 Today I explored another powerful concept of Object-Oriented Programming (OOP) — Polymorphism in Java. 🔹 What is Polymorphism? Polymorphism means “one interface, multiple forms” — the same method can behave differently depending on the object. 🔹 Types of Polymorphism: • Compile-Time (Method Overloading) Same method name with different parameters. • Runtime (Method Overriding) Child class provides a specific implementation of a method already defined in the parent class. 🔹 Example: class Animal { void makeSound() { System.out.println("Animal sound"); } } class Dog extends Animal { void makeSound() { System.out.println("Barking"); } } 💡 Key Learning: Polymorphism helps make code more flexible, reusable, and scalable, which is very important in real-world applications. Step by step growing stronger in Java and OOP concepts 🚀 If you're also learning Java or working in development, let’s connect and grow together. 🤝 #Java #JavaDeveloper #OOP #Polymorphism #Programming #CodingJourney #SoftwareDevelopment #LearnJava #Hariom #HariomKumar #Hariomcse
To view or add a comment, sign in
-
-
🚀 Day 2/45 – Understanding Variables and Data Types in Java Today was the second day of my 45 days Java learning journey, and I focused on understanding one of the most fundamental concepts in programming: Variables and Data Types. In any programming language, variables act as containers that store data which can be used and manipulated throughout a program. Learning how to declare and use them correctly is an important step toward writing efficient programs. 📚 What I Learned Today Today I explored how Java handles different types of data and how they are stored in memory. Some of the key concepts I learned include: ✔ Declaring and initializing variables in Java ✔ Understanding primitive data types such as int, double, char, and boolean ✔ How variables help store and manage values in a program ✔ Writing simple programs using variables for calculations and output 💻 Practice Programs To strengthen my understanding, I practiced small programs such as: • Storing and printing student details using variables • Adding two numbers using integer variables • Calculating the area of a rectangle using length and width variables Example: class Addition { public static void main(String args[]) { int a = 10; int b = 20; int sum = a + b; System.out.println("Sum = " + sum); } } 🎯 Key Takeaway Even though variables and data types seem simple, they are the foundation of programming logic. Mastering these basics will make it easier to learn advanced concepts like loops, functions, and object-oriented programming. I will continue learning and sharing my progress as I move forward in this journey. #Java #Programming #LearningInPublic #CodingJourney #SoftwareDevelopment #Consistency
To view or add a comment, sign in
-
🚀 Day 6/45 – Learning Arrays in Java On Day 6 of my Java learning journey, I explored the concept of Arrays, which are used to store multiple values of the same data type in a single variable. Arrays play an important role in programming as they help manage and organize data efficiently. 📚 What I Learned Today Today I learned: ✔ What arrays are and why they are used ✔ How to declare and initialize arrays ✔ Understanding array indexing (starting from 0) ✔ Using loops to access and process array elements 💻 Practice Work To strengthen my understanding, I implemented: • Printing all elements of an array • Calculating the sum of array elements • Finding the largest number in an array • Reversing an array 🎯 Key Takeaway Arrays make it easier to handle large amounts of data efficiently. Combining arrays with loops helps in solving many real-world problems. This concept is very important for logic building and future topics like data structures. #Java #Programming #LearningInPublic #arrays #CodingJourney #SoftwareDevelopment #Consistency
To view or add a comment, sign in
-
🚀 Day 12/45 – Understanding Constructors in Java On Day 12 of my Java learning journey, I explored the concept of Constructors, which play an important role in object initialization. Constructors are automatically called when an object is created and help in assigning initial values to object properties. 📚 What I Learned Today Today I learned: ✔ What constructors are and how they work ✔ Difference between constructors and methods ✔ Default constructors ✔ Parameterized constructors for initializing values 💻 Practice Work To apply my learning, I implemented: • A program using a default constructor • A program using a parameterized constructor • Creating multiple objects with different values 🎯 Key Takeaway Constructors make object creation more efficient and organized by initializing data at the time of object creation. This concept is very important for building structured and scalable applications. Learning OOP step by step is making programming more interesting. #Java #Programming #LearningInPublic #CodingJourney #SoftwareDevelopment #OOP
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development