<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bezawit E. on Medium]]></title>
        <description><![CDATA[Stories by Bezawit E. on Medium]]></description>
        <link>https://medium.com/@dagmbeza?source=rss-b86c8b6fae50------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*U1HvCPRn141RftIB</url>
            <title>Stories by Bezawit E. on Medium</title>
            <link>https://medium.com/@dagmbeza?source=rss-b86c8b6fae50------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:41:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dagmbeza/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding Flutter Widgets: Basic Building Blocks and Layout]]></title>
            <link>https://medium.com/@dagmbeza/understanding-flutter-widgets-basic-building-blocks-and-layout-08ed3ffeac1f?source=rss-b86c8b6fae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/08ed3ffeac1f</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-widget]]></category>
            <dc:creator><![CDATA[Bezawit E.]]></dc:creator>
            <pubDate>Fri, 27 Nov 2026 11:29:47 GMT</pubDate>
            <atom:updated>2026-11-27T11:29:47.837Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yH223jOaVKJUM2VUe8-VAQ.jpeg" /></figure><p>Everything is a widget. Text, images, icons, buttons, spacing, and even the overall structure of an application screen are built using widgets.<br>But learning Flutter is not about memorizing hundreds of widget names. It is about understanding what each widget does, how widgets work together, and how to use them to create beautiful and responsive user interfaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LAr0AN32hQpQnLeb7sGnWg.png" /></figure><h4>Basic Flutter Widgets</h4><h3>1. Text Widget</h3><p>The Text widget displays text on the screen and strictly expects a String.</p><p>Text(‘Company: ABC Technology’)<br>Text(‘Location: Addis Ababa’)<br>Text(‘CEO: Abebe’)<br>Text(‘Salary: 25,000 ETB’)</p><p>String name = ‘Samira’;<br>int likes = 128;</p><p>Text(‘Name: $author’), // Simple variable<br>Text(‘Total likes: ${likes + 1}’), // Math expression</p><p>TextStyle</p><p>style: Defines the overall appearance. <br>fontSize: Controls the size of the text.<br>fontWeight: Controls how bold the text appears.<br>color: Changes the text color.<br>textAlign: Controls text alignment.</p><p>Text(<br>‘App Developer’,<br>style: TextStyle(<br>fontSize: 42,<br>fontWeight: FontWeight.bold,<br>color: Colors.blue,<br>),<br>)</p><h3>2. Icon Widget</h3><p>Icon widget displays graphical symbols that communicate actions or information.</p><p>Flutter comes with more than a thousand ready icons. Show one with the Icon widget and a name from Icons:</p><p>Icon(Icons.home)</p><p>Icon(Icons.search)</p><p>Icon(Icons.settings)</p><p>Many icons come in several versions. Icons.star is a filled star, and Icons.star_border is only its outline. Icons are drawn like letters, so they stay sharp at any size.</p><p>An Icon takes a size: in pixels and a color:, right inside it:</p><p>Icon(Icons.wb_sunny, size: 80, color: Colors.orange)</p><p>Without them an icon is 24 pixels and takes the color of the text around it.</p><p>There is no TextStyle here: an Icon has its own size: and color:</p><p>Icon(</p><p>Icons.star,</p><p>size: 64,</p><p>color: Colors.amber)</p><p>sets an icon’s size and color.</p><p>Icon(Icons.favorite, size: 90, color: Colors.red),</p><p>Example:</p><pre>Widget build(BuildContext context) {<br>String classname = &quot;4th A&quot;;<br>return MaterialApp(<br>debugShowCheckedModeBanner: false,<br>home: Scaffold(<br>body: Center(<br>child: Column(<br>mainAxisAlignment: MainAxisAlignment.center,<br>children: [<br>Text(&quot;check $classname&quot;),<br>Icon(Icons.favorite, size: 60, color: Colors.red),<br>Icon(Icons.share, size: 60, color: Colors.blue),<br>Icon(Icons.location_on, size: 60, color: Colors.green),<br>], <br>),<br>),<br>),<br>);<br>}</pre><h3>3. Image Widget</h3><p>The Image widget displays pictures in your application.</p><p>Two ways: Image.network and Image.asset.</p><p>Network image: Loading an image from a URL</p><p>Image.network(<br>‘https://picsum.photos/id/10/300/200&#39;,<br>width: 100,<br>height: 100,<br>fit: BoxFit.cover,<br>),</p><p>The app downloads the picture while it runs, so it can appear a moment after the rest of the screen.</p><p>Loading a local image registered in pubspec.yaml</p><p>Create the folder assets/images and add images</p><p>flutter:<br> assets:<br> — assets/images/</p><p>terminal command</p><p>flutter pub get <br> Image.asset(<br> ‘assets/images/flutterLayout.png’,<br> width: 100,<br> height: 100,<br> fit: BoxFit.cover,<br> ),<br> Image.asset(<br> ‘assets/images/flutterimage.jpg’,<br> width: 100,<br> height: 100,<br> fit: BoxFit.cover,<br> ),</p><h3>4. SizedBox Widget</h3><p>A SizedBox draws nothing. It only takes up space: 20 pixels of height here.</p><p>In a Row, use SizedBox(width: 20) instead.</p><p>Which adds 12 pixels of space between two widgets in a Row?</p><p>SizedBox(height: 12)</p><p>Text(‘example ‘)</p><p>SizedBox(width: 12)</p><p>Text(‘example ‘)</p><h3>5. Layout Widgets</h3><p>Flutter provides layout widgets to help organize your interface.</p><p>Three important widgets to understand are Center, Row, and Column.</p><p>Center Widget<br>The Center widget positions its child in the center of the available space.</p><p>Center(<br> child: Text(‘Welcome ‘),<br>)</p><p>Column Widget<br>The Column widget arranges its children vertically, from top to bottom.</p><p>Column(<br> children: [<br> Text(‘Java Developer’),<br> Text(‘ABC Technology’),<br> Text(‘Addis Ababa’),<br> ],<br>)</p><p>Row Widget<br>The Row widget arranges its children horizontally, from left to right.</p><p>Row(<br>children: [<br>Text(‘Java Developer’),<br>Text(‘ABC Technology’),<br>Text(‘Addis Ababa’),<br>],<br>)</p><p>Main Axis and Cross Axis</p><p>To control the alignment and positioning of widgets.</p><p>For Row:</p><p>Main Axis: Horizontal. (Left Right) <br>Cross Axis: Vertical. (Top Bottom)</p><p>For Column:</p><p>Main Axis: Vertical.<br>Cross Axis: Horizontal.</p><h3>Quiz</h3><p>Which widget arranges children horizontally?</p><p>Column<br> <br>Center<br> <br>Row</p><p>What is the main axis of Column?</p><p>Horizontal<br> <br>Vertical<br> <br>Diagonal<br> <br>Which widget adds space around its child?</p><p>Padding<br> <br>Text<br> <br>Image</p><p>How will the text widgets be positioned?</p><p>A. Vertically centered and horizontally aligned to the right.</p><p>B. Horizontally centered and vertically aligned to the bottom.</p><p>C. Vertically aligned to the left.</p><p>D. Arranged horizontally from left to right.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=08ed3ffeac1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building UI in Flutter: Scaffold and Text]]></title>
            <link>https://medium.com/@dagmbeza/building-ui-in-flutter-scaffold-and-text-eb09d40e1c4f?source=rss-b86c8b6fae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb09d40e1c4f</guid>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Bezawit E.]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 12:00:23 GMT</pubDate>
            <atom:updated>2026-11-17T12:00:23.161Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*skgdYPPhiobwCsh99RsdvQ.jpeg" /></figure><p>In Flutter, everything is a widget. When you are just starting out, you don’t need to memorize dozens of complex components to build a real app screen. Almost every Material Design screen starts with just two essentials:</p><p>Scaffold provides the basic structure of a Material Design screen.<br>Text displays words, sentences, and other text content.</p><ol><li>Scaffold Widget</li></ol><p>The Scaffold widget provides the basic visual structure of a Material Design application screen.</p><p>Think of Scaffold as the foundation or framework of a screen. It gives us designated areas where we can place application content.</p><p>appBar: The top bar (AppBar) that holds your screen title.<br>body: The main area where your content lives.<br>backgroundColor: Changes the screen’s background color.<br>floatingActionButton: Adds a circular action button in the bottom-right corner.</p><p>bottomNavigationBar: Tabs at the bottom<br>A minimal Scaffold only needs a body</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*B5VREUBfUZf9SCevKHBu-g.jpeg" /></figure><pre>import &#39;package:flutter/material.dart&#39;;<br><br>void main() {<br>runApp(const MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>const MyApp({super.key});<br><br>// This widget is the root of your application.<br>@override<br>Widget build(BuildContext context) {<br>return MaterialApp(<br>debugShowCheckedModeBanner: false,<br>home: Scaffold(<br>backgroundColor: Colors.greenAccent,<br>appBar: AppBar(<br>title: Text(&#39;My Flutter App&#39;),<br>),<br>body: Center(<br>child: Text(&#39;Flutter tutorial&#39;),<br>),<br>));<br>}<br>}</pre><p>2. Text Widget</p><p>The Text widget displays a string of characters.</p><p>Flutter shows the string exactly as you wrote it. Capitals, spaces, and punctuation all matter:</p><p>Text(‘flutter tutorial’) // lowercase f<br>Text(‘Flutter tutorial’) // capital F and T<br>Text(‘Flutter tutorial’) // two spaces</p><p>Variables<br>Dart allows us to store text in variables and display it using the Text widget.</p><p>Example:</p><p>String studentName = ‘Abebe’;</p><p>Text(studentName)</p><p>Use string interpolation to combine text with variable values.</p><p>String name = ‘Abebe’;</p><p>Text(‘Welcome, $name’)</p><pre>Widget build(BuildContext context) {<br>String name = &quot;Flutter tutorial Variable&quot;;<br>return MaterialApp(<br>debugShowCheckedModeBanner: false,<br>home: Scaffold(<br>body: Center(<br>child: Text(&quot;Hello, $name&quot;),<br>),<br>));<br>}</pre><p>Quotes</p><p>A string starts and ends with a quote. That makes an apostrophe tricky: in ‘It’s’, Dart thinks the string ends after It, and the rest is not code it understands. The app does not even start.<br>There are two ways out. Put a backslash before the apostrophe, so Dart knows it is part of the string:<br>Text(‘It\’s raining’)<br>Or start and end the string with double quotes. Dart accepts both kinds, so inside double quotes an apostrophe is just a letter:<br>Text(“It’s raining”)</p><p>TextStyle</p><p>Controls font size, weight, and color.</p><p>textAlign: TextAlign.left, TextAlign.center, TextAlign.right</p><p>Common TextStyle properties:</p><p>fontSize — size in logical pixels<br>fontWeight — FontWeight.bold, FontWeight.w400, etc.<br>color — text color<br>fontStyle — FontStyle.italic for italics</p><p>Text(<br>style: TextStyle(<br>fontSize: 80,</p><p>fontWeight: FontWeight.bold,<br>fontStyle: FontStyle.italic,</p><p>color: Colors.green,<br>),<br>‘Hello Flutter’),</p><p>Colors in Hex</p><p>Designers often give colors as a hex code, like #6A1B9A: two digits for red, two for green, two for blue. In Flutter you write it as a Color:</p><p>color: Color(0xFF6A1B9A),</p><p>0x tells Dart a hex number follows. Then come two more digits before the color: FF means fully visible. 00 there would make the color completely see-through, so the text would vanish. After that come the six digits of the hex code.</p><p>Question</p><p>1/ Which of these shows Don’t stop?</p><p>A. Text(“Don’t stop”)</p><p>B. Text(‘Don’t stop’)</p><p>C. Text(Don’t stop)</p><p>2/ Which setting makes text bold?</p><p>A. fontWeight: FontWeight.bold</p><p>B. fontStyle: FontStyle.bold</p><p>C. bold: true</p><p>3/ Which Color is the hex code #FF9800, fully visible?</p><p>A. Color(‘#FF9800’)</p><p>B. Color(0xFFFF9800)</p><p>C. Color(0xFF9800)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb09d40e1c4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Services and Broadcast Receivers]]></title>
            <link>https://medium.com/@dagmbeza/android-services-and-broadcast-receivers-3abe6e3122fd?source=rss-b86c8b6fae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/3abe6e3122fd</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[services]]></category>
            <dc:creator><![CDATA[Bezawit E.]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 07:12:06 GMT</pubDate>
            <atom:updated>2026-11-17T07:12:06.295Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g47fYKT3pmuaVNsEuw8Q4A.png" /></figure><p><strong>What Are Android Services?</strong></p><p>An Android Service is an application component designed to perform operations without providing a user interface.</p><p>Unlike an Activity, which normally represents a screen that users interact with, a Service is designed to handle work that may continue when the user moves away from the application’s screen.</p><p>Example</p><p>A music application continues playing audio when the user opens another application.<br>A navigation application provides directions while the screen is not actively being used.<br>An application downloads a file while keeping the user informed about its progress.<br>An application synchronizes information with an online server.</p><p><strong>Why do we need Services?</strong></p><p>Imagine you are developing a music player. If music playback depended entirely on the Activity, the music might stop whenever the user left that screen.</p><p>A Service provides a component that can manage work independently of the Activity’s visible interface. A Service does not automatically run on a separate thread. By default, Service callbacks run on the application’s main thread. Developers must use an appropriate background execution mechanism for lengthy or blocking operations to avoid freezing the user interface.</p><p>Types of Android Services</p><p>Background Services<br>Foreground Services<br>Bound Services</p><p><strong>1/ Background Services</strong></p><p>A service that executes tasks silently in the background without direct user interaction or a visible UI/notification.</p><p>Examples <br>Syncing emails periodically, processing logs, or uploading non-urgent data. <br>Processing information in the background.<br>Performing internal application maintenance.<br>Handling work that does not require continuous user attention.</p><p>Modern Android versions restrict background service execution. Since Android 8.0 (API level 26), applications targeting newer Android versions face limits on starting and keeping ordinary background services running while the app is in the background.</p><p>For scheduled and deferrable background tasks, WorkManager is generally a better choice.</p><p>Strict background execution limits apply to save battery.<br>The system aggressively kills background services when the app leaves the foreground.<br> Use WorkManager for deferrable or scheduled background tasks.</p><p>For example, if an application needs to synchronize information periodically, WorkManager can schedule that work while considering device conditions and system restrictions.</p><p>Lifecycle</p><p>Started via startService().<br>Runs until explicitly stopped (stopSelf() / stopService()) or terminated by the OS.<br>Must be declared in AndroidManifest.xml</p><p><strong>2 Foreground Services</strong></p><p>A foreground service performs work that is noticeable to the user and should continue even when the user is not interacting directly with the application.</p><p>A foreground service must display a notification so that the user knows the application is performing an ongoing task.</p><p>Examples</p><p>Playing music.<br>Recording a workout.<br>Providing navigation directions.<br>Performing an eligible ongoing user-initiated operation.</p><p>Audio/music players, real-time GPS navigation, active fitness tracking, or ongoing file transfers.</p><p>For example, when you play music and switch to another application, playback can continue while a notification shows the current activity.</p><p>Foreground services receive higher process importance than ordinary background services, but they are not guaranteed to run forever. Android still applies restrictions and resource-management rules.</p><p>Lifecycle</p><p>Started using startForegroundService() and bound to a notification via startForeground(id, notification).<br>The app must display the notification within 5 seconds of starting the service, or Android throws an exception and crashes the app.<br>Requires FOREGROUND_SERVICE permission in AndroidManifest.xml (plus specific type permissions like location or media playback on newer APIs).</p><p><strong>3 Bound Services</strong><br>A bound service allows another application component to connect to it and communicate with it.</p><p>For example, an Activity might bind to a service to request information or control an operation.</p><p>A bound service generally remains active while one or more components are connected to it. When all clients unbind, the service can be destroyed if it is not also started.</p><h3>Background vs. Foreground Services</h3><p>User Visibility</p><p>Background Service: Invisible to the user</p><p>Foreground Service: User is aware through a notification</p><p>System Priority</p><p>Background Service: Low (easily killed under memory/battery pressure)</p><p>Foreground Service: High (protected from system termination)</p><p>Notification</p><p>Background Service: Not required</p><p>Foreground Service: Mandatory (must appear within 5 seconds)</p><p>OS Restrictions</p><p>Background Service: Heavily restricted since Android 8.0 (API 26)</p><p>Foreground Service: Permitted for active user-facing tasks</p><p>Main purpose</p><p>Background Service: Work that does not require continuous user awareness</p><p>Foreground Service: Ongoing work noticeable to the user</p><p>Best Use Case</p><p>Background Service: Short, silent, non-critical tasks</p><p>Foreground Service: Continuous, user-monitored tasks (e.g., music, GPS)</p><p>Examples</p><p>Background Service: Internal processing and maintenance</p><p>Foreground Service: Music playback and navigation</p><p>Question: Which type of services are needed?</p><p>1/ <strong>Downloading a large file</strong></p><p>If a user starts a large download and expects it to continue while using other applications</p><p>2/ <strong>Synchronizing application data</strong></p><p>If your application needs to synchronize data periodically</p><p>3/ <strong>Playing music</strong></p><p>If the user expects music to continue after leaving the music screen, a media playback</p><h3>What is a Broadcast Receiver?</h3><p>An event-driven component that allows an app to listen for and respond to system-wide or app-wide event announcements (Intent broadcasts).</p><p>Android broadcasts can communicate information about system events or application-specific events.</p><p>Common System Broadcasts:</p><p>Intent.ACTION_BOOT_COMPLETED — Device finished booting.<br>Intent.ACTION_BATTERY_LOW — Low battery condition.<br>Intent.ACTION_AIRPLANE_MODE_CHANGED — Airplane mode toggled on/off.<br>ConnectivityManager.CONNECTIVITY_ACTION (CONNECTIVITY_CHANGE) — Network/Wi-Fi state changed.<br>Intent.ACTION_DATE_CHANGED — System date changed.</p><p><strong>Types of Broadcast Receivers</strong></p><p><strong>1. Static (Manifest-Declared) Receivers</strong><br>A static receiver is declared in the application’s AndroidManifest.xml file.</p><p>Limitation: Since Android 8.0 (API 26), most implicit broadcasts cannot trigger static receivers due to background execution restrictions.</p><p>&lt;receiver<br> android:name=”.MyBroadcastReceiver”<br> android:exported=”false”&gt;</p><p>&lt;intent-filter&gt;<br> &lt;action android:name=”com.example.ACTION_UPDATE” /&gt;<br> &lt;/intent-filter&gt;</p><p>&lt;/receiver&gt;</p><p><strong>2 Dynamic (Context-Registered) Receivers</strong></p><p>A dynamic receiver is registered programmatically while the application is running.</p><p>Active only while the registering component (Activity or Service) is alive.<br>Must be unregistered via unregisterReceiver(receiver) in onStop() or onDestroy() to prevent memory leaks.</p><p>IntentFilter filter =<br> new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);</p><p>ContextCompat.registerReceiver(<br> this,<br> receiver,<br> filter,<br> ContextCompat.RECEIVER_NOT_EXPORTED<br>);</p><p><strong>Conclusion</strong></p><p>Android Services and Broadcast Receivers are important components for building applications that do more than display screens.</p><p>Services help applications perform ongoing operations, while Broadcast Receivers allow applications to respond to important events.</p><p>The distinction between background and foreground services is especially important. Use modern scheduling tools such as WorkManager for background work when appropriate, while foreground services are for ongoing operations users need.</p><p>Reference</p><p><a href="https://developer.android.com/develop/background-work/services?hl=en&amp;utm_source=chatgpt.com">https://developer.android.com/develop/background-work/services</a></p><p><a href="https://developer.android.com/develop/background-work/services/bound-services">Bound services overview | Background work | Android Developers</a></p><p><a href="https://developer.android.com/develop/background-work/services/bound-services">https://developer.android.com/develop/background-work/services/bound-services</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3abe6e3122fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Dart Programming Language]]></title>
            <link>https://medium.com/@dagmbeza/introduction-to-dart-programming-language-2ea2b1f2b7d1?source=rss-b86c8b6fae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ea2b1f2b7d1</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[dart-programming-language]]></category>
            <dc:creator><![CDATA[Bezawit E.]]></dc:creator>
            <pubDate>Tue, 03 Nov 2026 06:32:13 GMT</pubDate>
            <atom:updated>2026-11-03T06:32:13.701Z</atom:updated>
            <content:encoded><![CDATA[<p>Dart is an open-source programming language originally developed by Google. It is designed for both server-side and client-side development. The Dart SDK includes its compiler.</p><p>Dart is an object-oriented language and shares many similarities with Java.</p><p>Dart is widely used for creating single-page websites and web applications.</p><p>Examples of Dart applications include Google Pay and BMW</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBIXkxErvVFQYlj4F8L2nQ.png" /></figure><h3>First Dart Program</h3><p>Let’s start with the traditional Hello World program.</p><pre>void main() {<br>  print(&#39;Hello, World!&#39;);<br>}</pre><p>Command to run a Dart file</p><p>dart run filename.dart</p><p><strong>Output:</strong></p><pre>Hello, World!</pre><p>1. Comments in Dart<br>Comments are non-executable lines in code used to explain logic or leave notes for yourself and other developers.</p><p>// This is a single-line comment.</p><p>/*<br> This is a <br> multi-line comment.<br>*/</p><p>/// This is a documentation comment (used for generating code docs).</p><p>2. Input and Output (I/O)<br>To write interactive terminal programs or log data in Dart, you need to understand how to handle input and output.</p><p>Output (print): Displays text on the console screen.<br>Input (stdin.readLineSync()): Reads input entered by the user in the console (requires importing dart:io).<br>import ‘dart:io’;</p><p>void main() {<br> // Output<br> print(“Welcome to Flutter &amp; Dart!”);</p><p>// Input<br> stdout.write(“Enter your name: “);<br> String? name = stdin.readLineSync(); // Reads user input as String</p><p>print(“Hello, $name!”);<br>}</p><p>3. Variables and Data Types<br>Variables store information that your app can use and manipulate. Dart is strongly typed, meaning every variable has a specific data type.</p><p>Built-in Data Types:<br>int: Whole numbers (e.g., 25, -5)<br>double: Floating-point / decimal numbers (e.g., 3.14, 99.99)<br>String: Text data inside quotes (e.g., “Flutter”)<br>bool: Boolean values (true or false)<br>List: An ordered collection of items (Array)<br>Map: Key-value pairs (Dictionary)</p><p>void main() {<br> // Explicitly declared variables<br> int age = 20;<br> double temperature = 36.6;<br> String courseName = “Flutter &amp; Dart Fundamentals”;<br> bool isEnrolled = true;</p><p>// Dart can automatically infer types using ‘var’<br> var studentName = “Alex”; // Inferred as String</p><p>// Collections<br> List&lt;String&gt; skills = [“Dart”, “Flutter”, “Firebase”];<br> Map&lt;String, dynamic&gt; userProfile = {<br> “name”: “Alex”,<br> “score”: 95,<br> };</p><p>print(“Student $studentName is enrolled in $courseName.”);<br>}</p><p>4. Operators<br>Operators allow you to perform calculations, comparisons, and logical operations on data.</p><p>Common Operators:<br>Arithmetic: +, -, *, /, ~/ (integer division), % (remainder)<br>Relational/Comparison: == (equal to), != (not equal to), &gt;, &lt;, &gt;=, &lt;=<br>Logical: &amp;&amp; (AND), || (OR), ! (NOT)<br>Assignment: =, +=, -=, *=, /=<br>void main() {<br> int a = 10;<br> int b = 3;</p><p>print(“Addition: ${a + b}”); // 13<br> print(“Division: ${a / b}”); // 3.3333…<br> print(“Integer Div: ${a ~/ b}”); // 3<br> print(“Modulo: ${a % b}”); // 1</p><p>bool isAdult = true;<br> bool hasID = false;<br> print(“Allowed entry: ${isAdult &amp;&amp; hasID}”); // false<br>}</p><p>5. Understanding final, const, and static<br>Keywords in Dart help control how variable values can be modified, and memory is allocated.</p><p>Keyword<br>Description<br>Example / Best Use<br>final Set once at runtime; value cannot be changed after creation.<br>Storing data fetched from an API<br>const Set at compile-time; strictly immutable constant.<br>Hardcoded app colors, constant UI values<br>static<br>Class-level variable shared across all instances of a class.<br>App-wide global settings or counters<br>class AppConfig {<br> // Static variable belongs to the class, not instance objects<br> static String appVersion = “1.0.0”;<br>}</p><p>void main() {<br> final DateTime now = DateTime.now(); // Runtime constant<br> const double pi = 3.14159; // Compile-time constant</p><p>print(“Current Time: $now”);<br> print(“Pi Value: $pi”);<br> print(“App Version: ${AppConfig.appVersion}”);<br>}</p><p>6. Decision Making (Control Flow)<br>Decision-making structures execute specific blocks of code depending on whether conditions evaluate to true or false.</p><p>if else Statement<br>void main() {<br> int score = 85;</p><p>if (score &gt;= 90) {<br> print(“Grade: A”);<br> } else if (score &gt;= 80) {<br> print(“Grade: B”);<br> } else {<br> print(“Grade: C”);<br> }</p><p>// Ternary Operator (Shorthand for simple if-else)<br> String result = score &gt;= 50 ? “Pass” : “Fail”;<br> print(“Result: $result”);<br>}</p><p>switch case Statement<br>Ideal when evaluating a variable against multiple distinct scalar values.</p><p>void main() {<br> String userRole = “admin”;</p><p>switch (userRole) {<br> case “admin”:<br> print(“Full access granted.”);<br> break;<br> case “editor”:<br> print(“Edit access granted.”);<br> break;<br> default:<br> print(“View-only access.”);<br> }<br>}</p><p>7. Loops<br>Loops allow you to repeat a block of code multiple times.</p><p>A. for Loop<br>Used when you know how many times the loop should run beforehand.</p><p>void main() {<br> for (int i = 1; i &lt;= 3; i++) {<br> print(“Flutter Widget #$i”);<br> }</p><p>// For-in loop (Iterating through lists)<br> List&lt;String&gt; widgets = [“Text”, “Container”, “Column”];<br> for (var item in widgets) {<br> print(“Widget name: $item”);<br> }<br>}</p><p>B. while and do-while Loops<br>while: Checks the condition before executing the code block.<br>do-while: Executes the code block at least once before checking the condition.<br>void main() {<br> int count = 1;</p><p>while (count &lt;= 3) {<br> print(“Count is $count”);<br> count++;<br> }</p><p>int number = 5;<br> do {<br> print(“Runs at least once even if condition is false.”);<br> } while (number &lt; 3);<br>}</p><p>8. Functions<br>Functions are reusable blocks of code designed to perform a specific task. They make code modular, readable, and clean.</p><p>// Standard function with return type and parameters<br>int addNumbers(int num1, int num2) {<br> return num1 + num2;<br>}</p><p>// Arrow function syntax (shorthand for single-line returns)<br>double calculateTax(double price) =&gt; price * 0.15;</p><p>// Optional Named Parameters (heavily used in Flutter UI layout widgets!)<br>void greetUser({required String name, String greeting = “Welcome”}) {<br> print(“$greeting, $name!”);<br>}</p><p>void main() {<br> print(“Sum: ${addNumbers(5, 10)}”);<br> print(“Tax: \$${calculateTax(100.0)}”);</p><p>// Calling function with named parameters<br> greetUser(name: “Sarah”);<br> greetUser(name: “John”, greeting: “Hello”);<br>}</p><p>9. Classes and Object-Oriented Programming (OOP)<br>Dart is an Object-Oriented language. In Flutter, almost everything is an object instantiated from a class (such as Buttons, Colors, and Screens).</p><p>Creating a Class &amp; Object<br>class Student {<br> // Properties (Instance Variables)<br> String name;<br> int age;<br> String course;</p><p>// Constructor<br> Student(this.name, this.age, this.course);</p><p>// Method (Class Function)<br> void displayDetails() {<br> print(“Student Name: $name, Age: $age, Course: $course”);<br> }<br>}</p><p>void main() {<br> // Instantiating a Student object<br> Student student1 = Student(“Maya”, 22, “Mobile App Development”);</p><p>// Accessing methods<br> student1.displayDetails();<br>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ea2b1f2b7d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Install Flutter on Windows 10/11]]></title>
            <link>https://medium.com/@dagmbeza/how-to-install-flutter-on-windows-10-11-296b2da5b3ac?source=rss-b86c8b6fae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/296b2da5b3ac</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Bezawit E.]]></dc:creator>
            <pubDate>Tue, 27 Oct 2026 06:15:54 GMT</pubDate>
            <atom:updated>2026-10-27T06:15:54.473Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f7-AgEpy6tWLYZ7rbofJQQ.png" /></figure><p>Flutter is free, open-source, and compatible with existing code.</p><p>Due to its user-friendly interface and fairly simple yet to-the-point commands, it is utilized by companies and developers around the world.</p><p>Follow the steps below to install Flutter on Windows:</p><p>Requirements before installing the Flutter SDK and Android Studio</p><p>Operating system: 64-bit Windows 10 or 11</p><p>RAM: 16 GB recommended for Android Studio and an emulator</p><p>Free disk space: At least 20–30 GB is a practical starting allowance for the SDKs, tools, and one emulator</p><p>Internet: Required for downloads</p><p>Phone: Optional if you use an Android emulator</p><p>More memory and disk space make development smoother.</p><p><a href="https://docs.flutter.dev/install/quick?_gl">Set up and test drive Flutter</a></p><h3>Set up and test drive Flutter</h3><h3>Download prerequisite software</h3><p>For the smoothest Flutter setup, install the following tools first.</p><p>1/ Install Git for Windows</p><ol><li>Download and install the latest version of <a href="https://git-scm.com/downloads/win">Git for Windows</a>.</li><li>For help installing or troubleshooting Git, refer to the <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">Git documentation</a>.</li></ol><p>2/ Download and install Visual Studio Code</p><ol><li>To quickly install Flutter, then edit and debug your apps, <a href="https://code.visualstudio.com/docs/setup/setup-overview">install and set up Visual Studio Code</a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*q86upgx2OXpRiVNE.png" /></figure><p>3/ Install the extension in VS Code</p><ol><li>Flutter and Dart extension helps VS Code create projects, recognize Flutter code, provide suggestions, and run and debug apps.</li></ol><p>4/ Download and install the Flutter SDK</p><p><strong>Flutter SDK is the core tool for building a Flutter UI</strong><br>The Flutter SDK contains the tools needed to create Flutter applications.</p><p>installation of the Flutter Software development Kit (Flutter SDK)</p><p><strong>Download and install</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/0*hPyIImrWgy02tSWV.png" /></figure><p>5/ Check and edit environment variables for global system access</p><p><strong>Control Panel &gt; System and Security &gt; System &gt; Advanced System Settings &gt; Environment Variables</strong></p><p>manually so your computer recognizes Flutter commands from any terminal.</p><p>Press the Windows key, type Environment Variables, and select Edit the system environment variables.<br>In the window that pops up, click the Environment Variables… button at the bottom.<br>Under the “User variables” section, find the variable named Path, select it, and click Edit.<br>Click New and paste the exact folder path to where your Flutter SDK bin folder is located (for example: C:\flutter\bin).</p><p>Click OK on all windows to save your changes.<br>Crucial Step: Restart VS Code completely so it recognizes the newly added path.</p><p>6/ Analyze and check whether something is missing/has to be installed further. To do this, in the Command Prompt terminal, type ‘<strong>Flutter Doctor</strong>’ to check for other requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*A7sUQHAnnznri-KH.JPG" /></figure><p>7/ Choose where to run your Flutter app</p><p>Flutter can target multiple platforms.</p><p>You only need to configure the platform you want to use first.</p><p>Option A: Web browser (easiest starting point)</p><p>Install Google Chrome if you don’t already have it.</p><p>You can run your Flutter app in Chrome without configuring an Android emulator.<br>Best for learning Flutter with a relatively simple setup.<br> <br>Option B: Android emulator</p><p>Use Android Studio to create a virtual Android device.</p><p>Best for learning mobile app development.</p><p>Option C: Android phone</p><p>Connect a physical Android phone with USB debugging enabled.</p><p>8: Create your first Flutter project<br>Let’s create a simple app called my_first_app.</p><p>Create Your First Project<br>Now that your machine speaks Flutter, let’s build an app.</p><p>Option A: Open VS Code and open the Command Palette again (Ctrl + Shift + P).<br>Type Flutter: New Project and select it.<br>You will be asked which template you want to use.</p><p>Option B: VS Code terminal</p><p>You can also create the project by running these commands in the VS Code terminal:</p><p>flutter create my_first_app</p><p>“myApp” is not a valid Dart package name.</p><p>The name should be all lowercase, with underscores to separate words,<br>“just_like_this”.Use only basic Latin letters and Arabic digits: [a-z0–9_].Also, make<br>sure the name is a valid Dart identifier — that it doesn’t start with digits and isn’t<br>a reserved word.</p><p>Enter the new project folder:</p><p>cd my_first_app</p><p>Open it in VS Code</p><p>code .</p><p>9: Understand your Flutter project files<br>When your project opens, you will see a structure similar to this:</p><p>my_first_app/<br>android/</p><p>Android-specific project files.<br>lib/</p><p>The main folder for your Dart and Flutter code.<br>lib/main.dart</p><p>The main entry point of your Flutter app. You’ll work here frequently as a beginner.<br>pubspec.yaml</p><p>Contains project information, dependencies, assets, and other configuration.<br>test/</p><p>A place for automated tests.<br>For now, focus on lib/main.dart</p><p>10. Run your first Flutter app</p><p>flutter run</p><p>select a target device (e.g., Windows, Chrome, or Edge), type the number corresponding to your preferred browser (like 2 for Chrome) and press Enter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=296b2da5b3ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[File and Streams in java]]></title>
            <link>https://medium.com/@dagmbeza/file-and-streams-in-java-99fb9bba3a02?source=rss-b86c8b6fae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/99fb9bba3a02</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <dc:creator><![CDATA[Bezawit E.]]></dc:creator>
            <pubDate>Sun, 03 May 2026 10:06:40 GMT</pubDate>
            <atom:updated>2026-05-03T10:06:40.124Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*gygmDVQS_hImloJV.png" /></figure><p>Why is file handling required?</p><p>To store data permanently instead of keeping it only in memory.</p><p>To read and write data from/to files for later use.</p><p>To share data between different programs or systems.</p><p>To organize and manage large data efficiently.</p><h4>I/O classes</h4><p>I/O Streams are more flexible, work with text and binary data (like images, audio, PDFs).</p><p>I/O streams are the fundamental mechanism for handling input and output operations. They provide a uniform way to read data from various sources (files, network, memory) and write data to different destinations.</p><p>Types of Streams</p><p>Java I/O streams are categorized into two main types based on the type of data they handle:</p><p>Byte Streams and Character Streams</p><p>1/ Byte Streams</p><p>Work with raw binary data (like images, audio, and PDF files).</p><p>used to perform input and output of 8-bit bytes.</p><p>Examples: FileInputStream, FileOutputStream.</p><p>2/ Character Streams</p><p>Work with text (characters and strings). These streams automatically handle character encoding.</p><p>Examples: FileReader, FileWriter, BufferedReader, BufferedWriter.</p><h4>File and FileDialog objects</h4><p>File class</p><p>Represents a file or directory (does NOT read/write content).</p><p>FileDialog (GUI — AWT)</p><p>The java.awt.FileDialog class is a subclass of java.awt.Dialog used for choosing a file to open or save.</p><h4>Low-Level File I/O</h4><p>The package for Java I/O API is java.io.</p><p>A stream is a collection of data or a flow of data.</p><p>Reading data from an input source requires an input stream, and writing data to a target requires an output stream.</p><p>Low-Level File I/O (Byte-Oriented)</p><p>Works with bytes and used for binary files (images, videos)</p><p>classes: FileInputStream and FileOutputStream</p><p>Low-level file I/O for raw byte I/O, similar to System.in.read() and System.out.write()</p><p>InputStream — Abstract class whose subclasses read raw bytes</p><p>OutputStream — Abstract class whose subclasses write raw bytes</p><p>FileInputStream — reads raw bytes</p><p>FileOutputStream — writes raw bytes</p><h4>High-Level File I/O</h4><p>support text data through characters instead of bytes.</p><p>Character-oriented I/O: use FileReader/FileWriter for text data;</p><p>wrap in BufferedReader/BufferedWriter for efficiency.</p><p>Common high-level classes include</p><p>BufferedInputStream, BufferedOutputStream,</p><p>BufferedReader, BufferedWriter, PrintWriter,</p><p>DataInputStream and DataOutputStream.</p><h4>Object I/O</h4><p>ObjectInputStream/ObjectOutputStream classes can be used to read/write serializable objects.</p><p>DataInputStream/DataOutputStream enables you to perform I/O for primitive-type values and strings.</p><p>ObjectInputStream/ObjectOutputStream enables you to perform I/O for objects in addition to primitive-type values and strings.</p><p>Since ObjectInputStream/ObjectOutputStream contains all the functions of DataInputStream/DataOutputStream,</p><p>You can replace DataInputStream/DataOutputStream completely with ObjectInputStream/ObjectOutputStream.</p><h4>Random Access files</h4><p>RandomAccessFile class to allow data to be read from and written to at any location in the file.</p><p>A file that is opened using the RandomAccessFile class is known as a random-access file.</p><p>The RandomAccessFile class implements the DataInput and DataOutput interfaces,</p><p>Java.io.RandomAccessFile Class works like an array of byte storted in the File.</p><p>Declaration :</p><p>public class RandomAccessFile extends Object</p><p>implements DataOutput, DataInput, Closeable</p><p>Quiz</p><p>Which method can be used to delete a file?<br>A/ del()<br>B/ remove()<br>C/ clear()<br>D/ delete()</p><p>What does file handling in Java mainly help with?<br>A Executing programs faster<br>B Storing data permanently<br>C Increasing CPU speed<br>D Managing threads</p><p>Which package provides classes and streams for Input/Output operations in Java?<br>A java.util<br>B java.nio<br>C java.io<br>D java.lang</p><p>Which default stream is used to read input from the keyboard in Java?<br>A System.out<br>B System.err<br>C System.in<br>D InputStream</p><p>You must import the File Class to be able to delete files.</p><p>A True<br> B False</p><p>Challenges</p><p>1/ Write a Java program to read first Three lines from a file</p><p>2/ Write a java program to Get file size and file path</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99fb9bba3a02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[try catch finally throw throws keywords in Java exception handling]]></title>
            <link>https://medium.com/@dagmbeza/try-catch-finally-throw-throws-keywords-in-java-exception-handling-fd5199e6f667?source=rss-b86c8b6fae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd5199e6f667</guid>
            <category><![CDATA[keywords]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Bezawit E.]]></dc:creator>
            <pubDate>Thu, 30 Apr 2026 06:15:03 GMT</pubDate>
            <atom:updated>2026-04-30T06:15:03.532Z</atom:updated>
            <content:encoded><![CDATA[<p>Basic try-catch</p><p>The try block contains code that might throw an exception,</p><p>The catch block handles the exception if it occurs.</p><p>Example:</p><p>public class MyMain {</p><p>public static void main(String[] args) {</p><p>try {</p><p>int x = 2, y = 0, z;</p><p>z = x / y;</p><p>System.out.println(“Z=” + z);</p><p>} catch (ArithmeticException e) {</p><p>System.out.println(“ArithmeticException / by zero”);</p><p>}</p><p>try {</p><p>int[] arr = new int[2];</p><p>System.out.println(arr[3]);</p><p>} catch (ArrayIndexOutOfBoundsException e) {</p><p>System.out.println(“Index error”);</p><p>} catch (Exception e) {</p><p>System.out.println(“General error”);</p><p>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*z2aZuGPRiZSlnEzv.jpeg" /></figure><p>The throw statement</p><p>The throw statement allows you to create a custom error.</p><p>throw Keyword<br>The throw keyword is used to explicitly throw an exception from a method or any block of code. We can throw either checked or unchecked exception. The throw keyword is mainly used to throw custom exceptions.</p><p>Syntax:</p><p>throw Instance</p><p>Where instance is an object of type Throwable (or its subclasses, such as Exception).</p><p>Example:</p><p>throw new ArithmeticException(“/ by zero”);</p><p>throw statement is executed, the program flow immediately stops, and the nearest try block is checked for a matching catch block.</p><p>If a matching catch block is found, control is transferred to that block.<br>If no match is found, the default exception handler terminates the program.</p><p>Example</p><p>public static void main(String[] args) {</p><p>try {<br>divide(10, 0);<br>} catch (ArithmeticException e) {<br>System.out.println(e.getMessage());<br>}<br>}</p><p>static void divide(int a, int b) {<br>if (b == 0) {<br>throw new ArithmeticException(“Division by zero is not allowed.”);<br>}<br>System.out.println(a / b);<br>}<br>}</p><p>throws Keyword<br>throws is a keyword that is used in the signature of a method to indicate that this method might throw one of the listed type exceptions. The caller to these methods has to handle the exception using a try-catch block.</p><p>Syntax:</p><p>type method_name(parameters) throws exception_list</p><p>where exception_list is a comma separated list of all the exceptions which a method might throw.</p><p>If a method can throw a checked exception, the compiler requires it to be either handled using a try-catch block or declared using the throws keyword; otherwise, a compile-time error occurs.</p><p>The exception can be handled using a try-catch block.<br>The throws keyword can be used to declare the exception and delegate the handling responsibility to the caller (method or JVM).</p><p><strong>finally</strong></p><p><strong>User-defined exceptions</strong></p><p>A user-defined custom exception is an exception class created by the programmer to represent application-specific or business-specific error scenarios.</p><p>Examples of User-defined Exception:</p><p>Invalid bank transaction<br>Insufficient balance<br>Age not eligible for registration<br>Invalid login attempt</p><p>Steps to Create a User-Defined Exception:</p><p>Create a class that extends Exception or RuntimeException.<br>Define a constructor and call the superclass constructor.<br>Write the code that might generate the defined exception inside the try-catch block.<br>Use ‘throw’ to raise the exception.<br>Handle it using try-catch.</p><p>class CustomException extends Exception {<br>public CustomException(String message) {<br>super(message);<br>}<br>}</p><p>public class MyMain {<br>public static void main(String[] args) {<br>try {<br>validate(0);<br>System.out.println(“sucess”);<br>} catch (CustomException e) {<br>System.out.println(e.getMessage());<br>}<br>}</p><p>static void validate(int number) throws CustomException {<br>if (number &lt;= 0) {<br>throw new CustomException(“Number must be greater than zero.”);<br>}<br>}</p><p>Best Practices</p><p>Use Meaningful Messages: Always provide meaningful and descriptive messages</p><p>When throwing exceptions to make debugging easier.</p><p>Custom Exceptions: Create custom exceptions to represent specific error conditions in your application. This makes your code more readable and maintainable.</p><p>Avoid Overuse: Do not overuse exceptions for control flow. They should be used for exceptional conditions, not for regular conditional checks.</p><p>Quiz:</p><p>When an error occurs, Java will normally stop and generate an error message. The technical term for this is..</p><p>A/ Expected B/ Exception C/ Inception D/ Deception</p><p>Insert the missing parts to handle the error in the code below.</p><p>___{<br>int[] myNumbers = {1, 2, 3};<br>System.out.println(myNumbers[10]);<br>} ____(Exception e) {<br>System.out.println(“Something went wrong.”);<br>}</p><p>static void fun() throws IllegalAccessException<br>{<br>System.out.println(“Inside fun(). “);<br>throw new IllegalAccessException(“demo”);<br>}</p><p>public static void main(String args[])<br>{<br>try {<br>fun();<br>}<br>catch (IllegalAccessException e) {<br>System.out.println(“Caught in main.”);<br>}<br>}</p><p>What is the difference between throw and throws?<br>A throw is used to declare exceptions, throws is used to throw exceptions<br>B throws is used to declare exceptions, throw is used to throw exceptions<br>C Both are used to declare exceptions<br>D Both are used to throw exceptions</p><p>What happens when a method declares an exception using throws?<br>A The method handles the exception internally<br>B The caller must handle or declare the exception<br>C Java ignores the exception<br>D The method cannot be executed</p><p>Where can the throws keyword be used?<br>A/ Inside a loop<br>B/ Inside a catch block<br>C/ Inside a method body<br>D/ In a method signature</p><p>How many exceptions can be thrown using throw at a time?<br>A Multiple<br>B Only one<br>C Two<br>D Unlimited</p><p>Challenges</p><p>Write a Java program that reads a list of integers from the user and throws an exception if any numbers are duplicates.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd5199e6f667" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polymorphism in Java OOP: A Practical Guide with Real Examples]]></title>
            <link>https://medium.com/@dagmbeza/polymorphism-in-java-oop-a-practical-guide-with-real-examples-2b401be1dc76?source=rss-b86c8b6fae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b401be1dc76</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programing]]></category>
            <dc:creator><![CDATA[Bezawit E.]]></dc:creator>
            <pubDate>Sat, 25 Apr 2026 08:35:39 GMT</pubDate>
            <atom:updated>2026-04-25T08:35:39.869Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*ZJmekMRuXxHzhNAOfWhRyg.png" /></figure><p>Polymorphism means “many forms”, and it occurs when we have many classes that are related to each other by inheritance. it comes from the Greek words poly (many) and morph (forms).</p><p>Inheritance inherits attributes and methods from another class.</p><p>Polymorphism uses those methods to perform different tasks. This allows us to perform a single action in different ways.</p><p>It is useful for code reusability: reuse attributes and methods of an existing class when you create a new class.</p><p><strong>Multiple Behaviors:</strong> The same method can behave differently depending on the object that calls this method.</p><p><strong>Method Overriding:</strong> A child class can redefine a method of its parent class.</p><p><strong>Method Overloading:</strong> We can define multiple methods with the same name but different parameters.</p><p><strong>Runtime Decision:</strong> At runtime, Java determines which method to call depending on the object’s actual class.</p><p>Example</p><p>// Base class Person</p><p>class Person {</p><p>// Method that displays the</p><p>// role of a person</p><p>void role() { System.out.println(“I am a person.”); }</p><p>}</p><p>// Derived class Father that</p><p>// overrides the role method</p><p>class Father extends Person {</p><p>// Overridden method to show</p><p>// the role of a father</p><p>@Override void role()</p><p>{</p><p>System.out.println(“I am a father.”);</p><p>}</p><p>}</p><p>class Husband extends Person {</p><p>// Overridden method to show</p><p>// the role of a father</p><p>@Override void role()</p><p>{</p><p>System.out.println(“I am a husband.”);</p><p>}</p><p>}</p><p>public class Main {</p><p>public static void main(String[] args)</p><p>{</p><p>// Creating a reference of type Person</p><p>// but initializing it with Father class object</p><p>Person p=new Person();</p><p>Person f = new Father();</p><p>Person h=new Husband();</p><p>// overridden version in Father class</p><p>p.role();</p><p>f.role();</p><p>h.role();</p><p>}</p><p>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*gFtDEyaCqSaXVA6j.jpg" /></figure><p>Quiz</p><p>What is the key difference between compile-time and runtime polymorphism in Java?<br>A Compile-time polymorphism is implemented using method overriding, while runtime polymorphism is implemented using method overloading.<br>B Runtime polymorphism is faster than compile-time polymorphism.<br>C Compile-time polymorphism is determined during compilation, while runtime polymorphism is resolved at runtime.<br>D Compile-time polymorphism is achieved using interfaces.</p><p>Which of the following best demonstrates runtime polymorphism in Java?<br>A Calling an overloaded method from the same class<br>B Accessing private methods from subclasses<br>C Using static methods with the same name in parent and child classes<br>D Overriding a method in a subclass and calling it through a superclass reference</p><p>Which of the following is an example of compile-time polymorphism in Java?<br>A Method overloading.<br>B Method overriding.<br>C Inheritance.<br>D Interface implementation.</p><p>Challenges</p><p>Create a class Vehicle with a method called speedUp(). Create two subclasses, Car and Bicycle. Override the speedUp() method in each subclass to increase the vehicle’s speed differently.</p><p>Create a base class Shape with a method called calculateArea(). Create three subclasses: Circle, Rectangle, and Triangle. Override the calculateArea() method in each subclass to calculate and return the shape’s area.</p><p>Create a base class Animal with methods eat() and sound(). Create three subclasses: Lion, Tiger, and Panther. Override the eat() method in each subclass to describe what each animal eats. In addition, override the sound() method to make a specific sound for each animal.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b401be1dc76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exception Handling in Java]]></title>
            <link>https://medium.com/@dagmbeza/exception-handling-in-java-a131a6fd6c0a?source=rss-b86c8b6fae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/a131a6fd6c0a</guid>
            <category><![CDATA[programing]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Bezawit E.]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 07:12:03 GMT</pubDate>
            <atom:updated>2026-04-24T07:12:03.169Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*PRKeSAMY7Mae56dGdQrByA.png" /></figure><p>Exceptions to handle errors and other exceptional events. An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions.</p><p>Exception Handling is a mechanism used to handle both compile-time (checked) and runtime (unchecked) exceptions, allowing a program to continue execution smoothly even in the presence of errors.</p><p>Handles abnormal conditions that occur during program execution.<br>Helps maintain program stability by preventing unexpected termination.</p><p>Exception handling plays an important role in software development.</p><p><strong>What is an Exception?</strong><br>An expectation is an unexpected event that occurs while executing the program, which disturbs the normal flow of the code.</p><p><strong>The causes of exceptions</strong></p><p>Some of the major reasons why Exceptions occur</p><p>a) Invalid input by the user: entering a string when a number is expected</p><p>b) Physical limitations: Exceeding available memory or disk space</p><p>c) Device failure: Disk full, network timeout, printer offline</p><p>d) Error in coding: Accessing an array index out of bounds, calling a method on a null reference</p><p>e) Weak or no network connection</p><p>f) Opening an unavailable file</p><p>Examples</p><p>Division by zero → ArithmeticException<br>Invalid array index → ArrayIndexOutOfBoundsException<br>Null reference → NullPointerException<br>Invalid input → InputMismatchException<br>File handling issues → IOException</p><p>Example:</p><p>public class MyMain {</p><p>public static void main(String[] args) {</p><p>try {</p><p>int x = 2, y = 0, z;</p><p>z = x / y;</p><p>System.out.println(“Z=” + z);</p><p>} catch (ArithmeticException e) {</p><p>System.out.println(“ArithmeticException / by zero”);</p><p>}</p><p>The Throwable class hierarchy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*bxxC-UpPVlIup0C7.png" /></figure><h4>Handling of an exception</h4><p>Basic try-catch</p><p>The try block contains code that might throw an exception,</p><p>The catch block handles the exception if it occurs.</p><p>Example:</p><p>public class MyMain {</p><p>public static void main(String[] args) {</p><p>try {</p><p>int x = 2, y = 0, z;</p><p>z = x / y;</p><p>System.out.println(“Z=” + z);</p><p>} catch (ArithmeticException e) {</p><p>System.out.println(“ArithmeticException / by zero”);</p><p>}</p><p>What will be the output of the program?<br> <br>public class Test {<br> public static void main(String[] args) {<br> try {<br> int[] arr = new int[2];<br> System.out.println(arr[3]);<br> } catch (ArrayIndexOutOfBoundsException e) {<br> System.out.println(“Exception caught”);<br> } finally {<br> System.out.println(“Finally block executed”);<br> }<br> }<br>}<br> <br>A/ Exception caught<br>B/ Exception caught Finally block executed<br>C/ Finally block executed<br>D/ Compilation fails</p><p>Challenges</p><p>Create a method that takes a string as input and throws an exception if the string does not contain vowels.</p><p>Create a method that takes an integer as a parameter and throws an exception if the input is a string.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a131a6fd6c0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[super, this, and extends keywords in Java]]></title>
            <link>https://medium.com/@dagmbeza/super-this-and-extends-keywords-in-java-8c3cf0d7b700?source=rss-b86c8b6fae50------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c3cf0d7b700</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[bezawite]]></category>
            <dc:creator><![CDATA[Bezawit E.]]></dc:creator>
            <pubDate>Fri, 27 Mar 2026 10:11:05 GMT</pubDate>
            <atom:updated>2026-03-27T10:11:05.729Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="inheritance java example" src="https://cdn-images-1.medium.com/max/653/0*oiyodhuUhp1p4vNT.jpg" /></figure><p><strong>extends </strong>keyword in Java code enables inheritance through which child classes automatically obtain attributes and behaviors from parent classes.</p><p>The syntax for creating inheritance in Java is:</p><p>class Parent {</p><p>// Parent class code</p><p>}</p><p>class Child extends Parent {</p><p>// Child class inherits from Parent class</p><p>}</p><p>The Child class inherits all non-private members of the Parent class, including fields and methods.</p><p>example to inheritance:</p><p>class Animal {</p><p>void eat() {</p><p>System.out.println(“This animal eats food.”);</p><p>}</p><p>}</p><p>class Dog extends Animal {</p><p>void bark() {</p><p>System.out.println(“The dog barks.”);</p><p>}</p><p>}</p><p>public class TestInheritance {</p><p>public static void main(String[] args) {</p><p>Dog dog = new Dog();</p><p>dog.eat(); // Inherited from Animal class</p><p>dog.bark(); // Method defined in Dog class</p><p>}</p><p>}</p><p>The extends keyword is used when a class inherits from another class, enabling the reuse of fields and methods.</p><p>On the other hand, the <strong>implements </strong>keyword is used by a class to adhere to a particular interface, which means it must provide implementations for all abstract methods defined in the interface.</p><p>constructors are not inherited by subclasses, but they can be invoked using super(). The constructor of the superclass is called before the subclass’s constructor.</p><p><strong>super </strong>keyword is used to access methods of the parent class while <strong>this </strong>is used to access methods of the current class.</p><p><strong>this</strong> keyword is a reserved keyword and can’t use it as an identifier.</p><p>It is used to refer current class’s instance as well as static members.</p><p>It can be used in</p><p>to refer instance variable of current class</p><p>to invoke or initiate current class constructor</p><p>can be passed as an argument in the method call</p><p>can be passed as argument in the constructor call</p><p>can be used to return the current class instance</p><p>It must be the first statement in the constructor.</p><p>Example :</p><p>class Test {</p><p>// instance variable</p><p>int a = 10;</p><p>// static variable</p><p>static int b = 20;</p><p>void display()</p><p>{</p><p>// referring current class(i.e, class Test)</p><p>// instance variable(i.e, a)</p><p>this.a = 100;</p><p>System.out.println(a);</p><p>// referring current class(i.e, class Test)</p><p>// static variable(i.e, b)</p><p>this.b = 600;</p><p>System.out.println(b);</p><p>}</p><p>public static void main(String[] args)</p><p>{</p><p>// Uncomment this and see here you get</p><p>// Compile Time Error since cannot use</p><p>// ‘this’ in static context.</p><p>// this.a = 700;</p><p>new Test().display();</p><p>}</p><p>}</p><p><strong>super </strong>keyword is used in subclasses to access superclass members (attributes, constructors and methods).</p><p>Both this() and super() cannot be used together in the same constructor (only one can be the first line).</p><p>If a constructor does not call this(), Java automatically inserts super() if no explicit call is present.</p><p>use of super keyword is that it eliminates the confusion between the superclasses and subclasses that have methods with same name.</p><p>Uses of super keyword</p><p>To call methods of the superclass that is overridden in the subclass.</p><p>To access attributes (fields) of the superclass if both superclass and subclass have attributes with the same name.</p><p>To explicitly call superclass no-arg (default) or parameterized constructor from the subclass constructor.</p><p>Example</p><p>class Animal {</p><p>void eat() {</p><p>System.out.println(“Animal eats”);</p><p>}</p><p>}</p><p>class Dog extends Animal {</p><p>void eat() {</p><p>super.eat(); // Calls the eat method of the Animal class</p><p>System.out.println(“Dog eats”);</p><p>}</p><p>}</p><p>class Test {</p><p>public static void main(String[] args) {</p><p>Dog dog1 = new Dog();</p><p>dog1.printMessage();</p><p>}</p><p>class Animal {</p><p>// overridden method</p><p>public void display(){</p><p>System.out.println(“I am an animal”);</p><p>}</p><p>}</p><p>class Dog extends Animal {</p><p>// overriding method</p><p>@Override</p><p>public void display(){</p><p>System.out.println(“I am a dog”);</p><p>}</p><p>public void printMessage(){</p><p>// this calls overriding method</p><p>display();</p><p>// this calls overridden method</p><p>super.display();</p><p>}</p><p>}</p><p>class Test {</p><p>public static void main(String[] args) {</p><p>Dog dog1 = new Dog();</p><p>dog1.printMessage();</p><p>}</p><p>}</p><h4>Use of final with inheritance</h4><p>The final keyword can be applied to classes, methods, and variables to restrict modification in inheritance.</p><p>final Class</p><p>A final class cannot be extended (no subclass).</p><p>Used to prevent inheritance for security or design reasons.</p><p>final class A {</p><p>// class body</p><p>}</p><p>// class A extends B {} // Compilation error</p><p>final Method</p><p>A final method cannot be overridden in a subclass.</p><p>Useful to lock the implementation of a critical method.</p><p>final Variable</p><p>A final variable can be assigned only once (constant).</p><p>For instance variables, they must be initialized either at declaration or in every constructor.</p><p>Quiz</p><p>True/False</p><p>1/ this() is used to call a constructor in the parent class.</p><p>2/ A final method can be overridden.</p><p>MULTIPLE CHOICE</p><p>1/ Which keyword prevents inheritance?<br>A. static<br>B. final<br>C. private<br>D. abstract</p><p>2/What happens?</p><p>class A {<br>final void show() {<br>System.out.println(“Hello”);<br>}<br>}</p><p>class B extends A {<br>void show() {<br>System.out.println(“Hi”);<br>}<br>}<br> <br>A. Runs normally<br>B. Compile error<br>C. Runtime error<br>D. No output</p><p>Output or fix Error</p><p>class A {<br>A(int x) {<br>System.out.println(x);<br>}<br>}</p><p>class B extends A {<br>B() {<br>System.out.println(“B”);<br>}<br>}</p><p>public class Test {</p><p>public static void main(String[] args) {</p><p>B obj = new B();</p><p>}</p><p>}</p><p>Challenge</p><p>Write a program that creates a class hierarchy for employees of a company. The base class should be Employee, with subclasses Manager, Developer, and Programmer.</p><p>Each subclass should have properties such as name, address, salary, and job title. Implement methods for calculating bonuses, generating performance reports, and managing projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c3cf0d7b700" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>