JAVA CODE
JAVA PROGRAMME
Java Basics
Working with Objects
Arrays, Conditionals, and Loops
Creating Classes and Applications in Java
More About Methods
Java Applet Basics
Graphics, Fonts, and Color
Simple Animation and Threads
More Animation, Images, and Sound
Managing Simple Events and Interactivity
Creating User Interfaces with the awt
Windows, Networking, and Other Tidbits
Modifiers, Access Control, and Class Design
Packages and Interfaces
Exceptions
Multithreading
Streams and I/O
Using Native Methods and Libraries
Under the Hood
Java Programming Tools
Working with Data Structures in Java
Advanced Animation and Media
Fun with Image Filters
Client/Server Networking in Java
Emerging Technologies
appendix A :- Language Summary
appendix B :- Class Hierarchy Diagrams
appendix C The Java Class Library
appendix D Bytecodes Reference
appendix E java.applet Package Reference
appendix F java.awt Package Reference
appendix G java.awt.image Package Reference
appendix H java.awt.peer Package Reference
appendix I java.io Package Reference
appendix J java.lang Package Reference
appendix K java.net Package Reference
appendix L java.util Package Reference

Thinking in Objects: An Analogy

Consider, if you will, Legos. Legos, for those who do not spend much time with children, are small plastic building blocks in various colors and sizes. They have small round bits on one side that fit into small round holes
on other Legos so that they fit together snugly to create larger shapes. With different Lego parts (Lego wheels, Lego engines, Lego hinges, Lego pulleys), you can put together castles, automobiles, giant robots that
swallow cities, or just about anything else you can imagine. Each Lego part is a small object that fits together with other small objects in predefined ways to create other larger objects. That is roughly how object-oriented
programming works: putting together smaller elements to build larger ones.

Here’s another example. You can walk into a computer store and, with a little background and often some help, assemble an entire pc computer system from various components: a motherboard, a CPU chip, a video
card, a hard disk, a keyboard, and so on. Ideally, when you finish assembling all the various self-contained units, you have a system in which all the units work together to create a larger system with which you can solve
the problems you bought the computer for in the first place.

Internally, each of those components may be vastly complicated and engineered by different companies with different methods of design. But you don’t need to know how the component works, what every chip on the
board does, or how, when you press the A key, an A gets sent to your computer. As the assembler of the overall system, each component you use is a self-contained unit, and all you are interested in is how the units
interact with each other. Will this video card fit into the slots on the motherboard, and will this monitor work with this video card? Will each particular component speak the right commands to the other components it
interacts with so that each part of the computer is understood by every other part? Once you know what the interactions are between the components and can match the interactions, putting together the overall system is
easy.

What does this have to do with programming? Everything. Object-oriented programming works in exactly this same way. Using object-oriented programming, your overall program is made up of lots of different
self-contained components (objects), each of which has a specific role in the program and all of which can talk to each other in predefined ways.

More Info

Imagine you’re building a city from scratch. In traditional, procedural thinking, you might start by laying down roads, building individual houses, and adding infrastructure piece by piece. It’s like constructing everything from the ground up, focusing on each element separately.

Now, let’s apply object-oriented thinking to this city-building process. Instead of starting from scratch and building every single component individually, you begin by identifying key “objects” or entities in your city: buildings, roads, parks, people, vehicles, and so on.

Each of these objects has its own properties and behaviors. For example, a building object might have properties like height, width, color, and number of floors, and behaviors like allowing people to enter or exit. A road object might have properties like length, width, material, and connections to other roads, and behaviors like allowing vehicles to travel from one point to another.

Now, instead of building everything from scratch, you create templates or blueprints for these objects. You define how each type of object should behave and what properties it should have. These templates serve as the basis for creating multiple instances of each object throughout your city.

With object-oriented thinking, you can then focus on arranging and interacting with these objects to create your city. You can easily create new buildings, roads, and other elements by using the predefined object templates and customizing them as needed. You can also define relationships between objects, such as a road connecting two buildings or a park serving as a common area for residents.

By thinking in objects, you can manage the complexity of your city more effectively. You can encapsulate related properties and behaviors within each object, making your code more modular, reusable, and easier to maintain. Plus, you can simulate real-world scenarios more accurately by modeling the interactions between different objects in your city.

prime number
Scroll to Top