• @BeforeAll Annotation in Junit

    JUnit 5 @BeforeAll annotation denotes a method that it is a lifecycle method. @BeforeAll is the replacement of @BeforeClass annotation in JUnit 4.

    1. @BeforeAll Annotation

    @BoforeAll is used show that  annotated method should be executed before all the @Test@RepeatedTest@ParameterizedTest, and @TestFactory methods in the current class.

    By default, the test methods will be executed in the same thread as @BeforeAll annotated method.

    • @BeforeAll annotated method MUST be a static method in the test class.
    public static void init(){
    	System.out.println("BeforeAll init() method called");

    Recommended posts :

    Mockito Annotations

  • Mockito Annotations – @Mock, @Spy, @InjectMocks and @Captor

    Mockito Annotations

    1. @Mock
    2. @InjectMocks
    3. @Captor
    4. @Spy

    1. @Mock Annotation

    The @Mock annotation is used to create and inject mocked instances. We do not create real objects, rather ask Mockito to create a mock for the class.

    The @Mock annotation is an alternative to Mockito.mock(classToMock). They both achieve the same result. Using @Mock is usually considered “cleaner and preferable

    Using the @Mock annotation –

    • allows shorthand creation of objects required for testing.
    • Using @Mock we can minimizes repetitive mock creation code.
    • Test class more readable with @Mock.
    • makes the verification error easier to read because field name is used to identify the mock.

    2. @InjectMocks Annotation

    In Mockito, we need to create the object of class to be tested and then insert its dependencies (mocked) to completely test the behavior. To do this, we use @InjectMocks annotation.

    @InjectMocks marks a field on which injection should be performed. Mockito will try to inject mocks only either by constructor injection, setter injection, or property injection – in this order. If any of the given injection strategies fail, then Mockito won’t report failure.

    3. @Captor Annotation

    The @Captor annotation is used to create an ArgumentCaptor instance which is used to capture method argument values for further assertions.

    Mockito verifies argument values using the equals() method of argument class.

    4. @Spy Annotation

    The @Spy annotation is used to create a real object and spy on that real object. A spy helps to call all the normal methods of the object while still tracking every interaction, just as we would with a mock.

    Initializing Mockito Annotations

    To initialize the above annotation test class should initialize the annotation using one of the following given ways:

    To initialize Mockito annotations with JUnit 5, we need to use  below MockitoExtention :

    public class ApplicationTest {

    To Initialize  JUnit 4, we can use either MockitoJUnitRunner or MockitoRule classes.

    public class ApplicationTest {
    public class ApplicationTest {
    	@Rule public MockitoRule rule = MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS);

    Recommended posts :

    @BeforeAll annotation

  • Top 25+ Java 8 Interview Questions and Answers for 2023

    In this exercise, we have given the Main Java 8 interview Questions and their answers with Code Models and detail Clarification:

    Q-1) List down Java 8 new features ?

    Answer: New features that are introduced in Java 8 are listed below:

    • Lambda Expressions
    • Functional Interface
    • Stream API
    • Method References
    • Optional Class
    • Default methods
    • Date API
    • Nashorn, JavaScript Engine

    Q-2) What is an optional class?

    Answer: Optional class is a special wrapper class introduced in Java 8 which is used to avoid NullPointerExceptions. This final class is present under java.util package. NullPointerExceptions occurs when we fail to perform the Null checks.

    Q-3) What are Functional Interfaces?

    Answer: Functional Interface is an interface that has only one abstract method. The implementation of these interfaces can be provided using a Lambda Expression which means that to use the Lambda Expression, you need to create a new functional interface or you can use the predefined functional interface of Java 8.

    @FunctionalInterface” Annotation is used for creating new functional interface.

    If we use @FunctionalInterface annotation and having more then one abstract method then it will show compile error .

    Q-4) What are the default methods?

    Answer: Default methods are the methods of the Interface which has a body. These methods, as the name suggests, use the default keywords. Default method mainly used for “Backward Compatibility” which means if JDK modifies any Interface (without default method) then the classes which implement this Interface will break.

    But if you add the default method in an Interface then you will be able to provide the default implementation. This won’t affect the implementing classes.


    public interface questions { 

           default void print() {



    Q-5) What are the main features of the Lambda Function?

    Answer: Main features of the Lambda Function are as follows:

    • A method that is defined as Lambda Expression can be passed as a parameter to another method.
    • A method can exist standalone without belonging to a class.
    • There is no need to declare the parameter type because the compiler can fetch the type from the parameter’s value.
    • There is no need to have parenthesis when we use a single parameter but can use parentheses when using multiple parameters .
    • If the body of expression has a single statement then there is no need to include curly braces.

    Q-6) What was wrong with the date and time before java8?

    Answer:  below are the drawbacks of the date and time before java8:

    • Java.util.Date is mutable and is not thread-safe whereas the new Java 8 Date and Time API are thread-safe.
    • Java 8 Date and Time API meets the ISO standards whereas the before java8 date and time were poorly designed.
    • It has introduced several API classes for a date like LocalDate, LocalTime, LocalDateTime, etc.
    • Java 8 Date and Time works faster than the old regime of date and time.

    Q-7) What is a SAM Interface?

    Answer: In Java 8 it introduced the concept of Functional Interface that can have only one abstract method. Since these Interfaces specify only one abstract method, they are sometimes called as SAM Interfaces. SAM stands for “Single Abstract Method”.

    Q-8) What is Method Reference?

    Answer: Method Reference is one of the new feature introduced in java8. This is used to refer to the method of functional interface. It can be used to replace Lambda Expression while referring to a method.

    For Example: If the Lambda Expression looks like

    num -> System.out.println(num)

    Then the corresponding Method Reference would be,


  • Quarkus framework and it’s advantages

    Quarkus is a framework similar to Spring Boot, but with an additional feature of delivering smaller artifacts with fast boot time, better resource utilization, and efficiency. It’s optimized for cloud, serverless, and containerized environments.

    The goal of Quarkus is to make java a leading platform in Kubernetes and serverless environment while offering developers to unified reactive and imperative programming model to optimally address distributed application architecture.

    Quarkus works on container first philosophy. This means that quarkus is optimized for low memory usage and fast startup times in following manner.

    1. First class support for Grall/SubstractVM
    2. Build time metadata processing
    3. reduction in reflection usage
    4. Native Image pre boot
    5. Unifies imperative and reactive
    6. Joy for developer as it is providing live reloading feature.
    7. It provide best breed of libraries which you can use.

    Quarkus compatibility

    Quarkus 3 continues (like Quarkus 2) to target minimal version of Java 11. The default recommendation for users will be to use Java 17.

    Maven version should be 3.6.2 and above version is supported.

    Recommended articles

    Java8 interview questions

  • Top Most Popular Types of Blogs in 2023

    Now a days people are mostly search for What are good topics to blog about?, What blog topics are most popular?, Which blog topic is best for earning? etc.

    There are more then 500 million active blogs on the Internet, accounting for one-third of all the websites published.

    You can create a blog to inspire, to educate, or to connect with others. But blogging is not just for your readers. It’s also for yourself. There’s a lot of content that comes with expressing yourself in new, digital, Media, social networking forms. Finally, when you start growing your readership, blogging can become a sustainable stream of revenue. There are plenty of creative ways to monetize your blog as it grows, from affiliate links to banner advertising and sponsored posts.

    Whichever your motivation, there’s one golden rule to follow: choose a topic you are deeply passionate about. After all, passion is infectious. The more engaged you are with your subject, the easier it will convey your ideas, opinions, and emotions—and embark your readers with you.

    To help you get started, I have listed the top most popular types of blogs, plus real user examples.

    Best types of blogs to create:

    1. Food blogs
    2. Travel blogs
    3. Health and fitness blogs
    4. Lifestyle blogs
    5. Fashion and beauty blogs
    6. Photography blogs
    7. Personal blogs
    8. DIY craft blogs
    9. Parenting blogs
    10. Music blogs
    11. Business blogs
    12. Art and design blogs
    13. Book and writing blogs
    14. Personal finance blogs
    15. Interior design blogs
    16. Sports blogs
    17. News blogs
    18. Movie blogs
    19. Religion blogs
    20. Political blogs

    Food Blogs :

  • Types of Network devices

    Network devices are called hardware devices that link computers, printers, faxes, and other electronic devices to the network. Such devices easily, safely, and correctly transfer data over one or other networks. Inter-network or intra-network devices may be available. Some devices, such as the NIC card or the connector RJ45, are mounted on the device, while others are network components such as a router, switch, etc. Let’s look more closely at some of these phones. The modem is a system that can send and receive data through phone or cable lines from a computer.

    The data stored on the device is digital, while a phone line or cable wire can transmit only analog data. Digital signal is converted to analog and vice versa, which is important in the modem. The modulator transforms digital data into analog. When the processor sends the data, the demodulator is translated into digital data.

    Different Types of Network Devices

    1. Access Point

    While a wired or wireless link is technological in an AP, it usually means a wireless device. An AP operates on the second OSI layer, the data link layer, and can either act as a bridge that connects a standard wireless network to wireless devices or as a router that transmits data to another access point. Wireless connectivity points (WAPs) are a device used to generate a wireless LAN (WLAN) transmitter and receiver. Access points are usually separate networked machines with an integrated antenna, transmitter, and adapter.

    In order to provide a link between WLAN and wired Ethernet Lan, APs are using wireless infrastructure network mode. They have several ports, which allow you to extend the network to support other customers. One or more APs may need to have full coverage, depending on the size of the network. APSAPs may also provide multiple ports that can be used to increase the network’s size, firewall capabilities , and the DHCP. So, we’re getting switch-based APs, DHCP servers, firewall, and router.

    2. Router

    Routers allow packets to be transmitted to their destinations by monitoring the sea of networking devices interconnected with different network topologies . Routers are smart devices and store data on the networks to which they are connected. Most routers can be adjusted as a firewall for packet filters and can use ACLs. Routers are also used to convert from LAN to WAN framing in conjunction with the network control unit/data service unit (CSU / DSU). Such routers are called boundary routers.

    Routers are your first protection line, and only the traffic approved by network administrators needs to pass. Routers are your first protection line, and only the traffic approved by network administrators needs to pass.

    3. Hub

    The hubs link various networking devices. A network also functions as amplification by amplifying signals that deteriorate over cables after long distances. A hub is the easiest in the network communication system family, a hub is the easiest, as it links LAN components with the same protocols. Digital or analog data can be used with a server as long as its configuration prepares for formatting the incoming data. Hubs do not process or address packets; they only send data packets to all connected devices. We send data packets. Hubs operate on the Open Systems Interconnection (OSI) physical layer. Two types of hubs exist: simple and multiple.

    There are two types of Hubs:

    1. Active Hub
    2. Passive Hub

    Active HUB: Those are hubs that can clean, raise and distribute the signal together with the network with their power supply. It is both a repeater and a cable hub. The total distance between nodes can be increased.

    Passive HUB: These are hubs that collect cable from active network nodes and electricity. These hubs relay signals to the grid without being cleaned and improved, nor can the distance between nodes be increased.

    4. Bridge

    Bridges link two or more hosts or network segments. Bridge processing and transfer of frames between the various bridge links are the key roles in the network architecture. For the transmission of images, you use Media Access Control (MAC) hardware. Bridges can transmit the data or block the crossing by looking at the devices’ MAC addresses connected to each line. It is also possible to connect two physical LANs with a wider theoretical LAN with bridges. Bridges only function on OSI layers Physical and Data Link. Bridge are used for dividing large networks into smaller sections through the placement between two segments of the physical network and data flow management between the two.

    Bridges are in many respects like hubs, like linking LAN components to the same protocols. Yet bridges, known as frames, filter the incoming data packets to addresses before transmission. The bridge does not modify the format or content of the incoming data when it filters the data packets with the aid of a dynamic bridge table; the bridge filters and forwarded frames in the network. The initially empty bridge table preserves each LAN computer’s LAN address and each bridge interface’s addresses that link the LAN to the other LANs.

    5. Gateway

    The transportation and session layers of the OSI Model usually work in gateways. There are many guidelines and specifications for different vendors on the transport layer and above; gateways manage these. The connection between networking technologies, such as OSI and Transmission Control Protocol / Internet Protocols, such as TCP/IP, is supported by the gateway. Gateways link, thus, two or more self-contained networks with their own algorithms, protocols, topology, domain name system and policy, and network administration. Gateways handle all routing functions and more. In fact, an added translation router is a gateway. A protocol converter is called the feature that translates between different network technologies.

    6. Switch

    Switches have a smarter job than hubs in general. A switch improves the capacity of the network. The switch keeps limited information on routing nodes in the internal network and provides links to systems such as hubs or routers. Normally LAN beaches are linked by switches. Switches will usually read incoming packets ‘ hardware addresses to transfer them to their respective destinations. Switches improve the Network’s effectiveness over hubs or routers because of the flexibility of the digital circuit. Switches also improve network protection since network control makes digital circuits easier to investigate.

    You can see a switch as a system that combines some of the best routers and hubs. A switch can operate on the interface Data Link or the OSI model’s network layer. A multi-layer switch can be worked in both layers, so both a switch and a router can work. A high-performance switch adopting the same routing procedures as routers is a multilayer switch. DDoS may attack switches; flood controls can be used to prevent malicious traffic from stopping the switch. The Switch port’s protection is crucial to make sure that all unused ports are deactivated, and DHCP, ARP, and MAC Address Filtering are used to ensure stable switches.

    7. Modem

    Digital signals are transmitted through analog phone lines using modems (modulator demodulators). The modem converts digital signals into analog signals of various frequencies and transmits them to a modem at the receiver location. The receiving modem turns the other way and provides a digital output to a device, normally a computer, connected to a modem. In most cases, digital data is transmitted via the RS-232 standard interface to or from a serial line modem. Most cable operators use modems as final terminals to locate and remember their homes and personal clients, and many phone companies provide DSL services. All physical and data link layers are operating on modems.

    8. Brouter

    The bridging router is also the device that combines bridge and router features. It can be used on the data connection layer or the network layer. It can route packets across networks as a router, function as a bridge, and filter network traffic in the local area.

    Recommended post

    Read more..

  • What is Network and Types of Networks

    What is networks

    A network consists of two or more computers that are linked in order to share resources (such as printers and CDs), exchange files, or allow electronic communications.

    In other words A network is a collection of computers, servers, mainframes, network devices, peripherals, or other devices connected to allow data sharing. 

    Types of Networks

    The Network’s size can vary from connecting two computers inside a small room to lakhs of computers across the world. Different types of networks are

    1. Personal Area Network (PAN)
    2. Local Area Network (LAN)
    3. Metropolitan Area Network (MAN)
    4. Wide Area Network (WAN)
    5. Storage Area Network (SAN)
    6. System Area Network
    7. Enterprise Private Network (EPN)
    8. Virtual Private Network (VPN)
    9. Internet

    Advantages of Networks :

    • Enables centralized applications hosting/data storage and users accessing it through LAN, MAN, WAN in a secure way.
    • Results in considerable cost saving thro centralized administration.
    • Provides Real-time information to users.
    • Ensures data integrity.
    • Enables business transactions, net banking across any geography.
    • Optimizes software license usage and resource utilization.
    • Provides a collaboration platform for employees and reduces travel cost.

    Disadvantages of Networks :

    • Vulnerability to cyber-attacks due to the exposure of the network to the outside world.
    • Set up cost is huge.
    • Sensitive Data need to be encrypted and protected through the farewell.
    • The administration of networks poses a challenge due to their size and spread.

    Recommended Articles

    Types of network devices

  • What is domain and types of domain

    What is Domain?

    Let’s start with what the domain name of the website is. The domain name is the unique name that appears after the @ sign in email addresses, and after www. in web addresses. The domain name would thus be abcdxyz.com for the URL: https:/www.abcdxyz.com / hosting/.  The domain constitutes the IP address of the desktop or website. A registered domain name is unique to you and can not be used for anyone since it works like a street address in the physical world on the website.

    Domains are categorized into three parts generic domains, country domains and inverse domains, where generic domains define registered hosts according to their generic behavior’s, country domains use two characters country abbreviation, inverse domain maps address to map.

    Domain name types :

    Below are the different domain types, which are as follows.

    1) Top-Level Domain

    • .net
    • .edu
    • .org
    • .com
    • .mil
    • .gov

     1) .net

    Network shorthand was developed specifically for institutions participating in-network systems such as a web service provider or an infrastructure firm. As with .com, the restrictions were never upheld to limit.net to networking purposes, and it was one of the most popular top-class fields, and many saw it as close to the top-class domain.com.

    2) .edu

    .edu was produced for educational organizations by shorthand for education. While the TLD.edu was designed for universities worldwide, only instructional canters in America were linked to it. Schools in other nations use .edu together with their national domain, which is discussed in the next chapter below.

    3) .org

    .org was developed for Nonprofits, shorthand for the organization. As we saw with the other domains at the top, these intentions were often not maintained or implemented over time. Today, the company’s non-profits, profit enterprises, schools, and communities are used as high-level domain.

    4) .com

    The first high-level domain in popular use was for business shorthand, .com. Whilst .com was originally developed for use by businesses, this was not restricted strictly. .com was the most common type of high-level domain for companies, websites, and emails by the mid-1990s.

    5) .mil

    Military shorthand,.mil was specifically developed for the US military. This limitation is still maintained as opposed to other top-level domain kinds. In combination with the .mil TLD, it is common for .mil to use second and third-level domains.

    6) .gov

    Shorthand was restricted for the government, like .mil to federal government agencies only and only staff use. Today,.gov has been used in the town, cities, area, cities, counties and Native American tribes by government agencies.

    2) Generic Top-Level Domain (GTLD)

    Generic top-level domains work as a top-level domain category in the DNS. At present, there are 21 top-level generic domains within the root zone, the best level of the structure of the domain name scheme. Although over 1,500 gTLDs are used, the majority of these 21 constitute domain names of all types.

    Four subcategories are included:

    1. (.com, .info, .net, .org ) Domains that are generally applicable.

    2. ( .pro, .biz, .name) This domain is generally used for specific reason or purpose.

    3) Second Level Domain

    Domains of the second level are domains that follow top levels within the DNS hierarchy. Nike is the second-class domain of the top.com domain, for instance, in Nike.com. The name of a company or seller that registered a domain name with a registrar is often the second-level domain. For prospective clients, the brand name, business name or project name is the identifier.

    4) Third Level Domain

    Domains in the third stage are obviously secondary domains within the DNS hierarchy. It is to the left of the SLD and is often known as the subdomain. Larger enterprises often use third-level areas as identifiers to differentiate between different departments. “www” is the most frequent third-level domain in general.

    Read more…

    Recommended Articles :

    Web hosting and Type of web hosting

    WordAds vs AdSense: Which one to pick for your website?

  • UAE extends visa restriction on Pakistan, humiliated Pakistan says no visa ban in place

    One more embarrassment for Pakistan; United Arab Emirates (UAE), where large number of Pakistanis relocate for work opportunities , now stretched out a current travel ban to 24 cities of Pakistan. The visa ban was before on 22 areas, and it has now been expanded to 24 cities,

    The Pakistani cities which have been included for ban:

    • Abbotabad, Dera Ismail Khan, Quetta, Khoshab, Muzaffargarh, Sargodha, Attock, Dera Ismail Khan, Kasur, Kurram agency, Nawabshah, Sheikhpura, Bajaur agency, Hangu, Kohat, Larkana, Para Chinar, Skardu, Chakwal, Hunza and Kotl

    The UAE government needed to fall back on this activity to control the begging on the streets of UAE.

    It was noticed that an big number of travelers from Pakistan, who visit the UAE for work, at last wind up begging on the roads when they neglect to track down business. This builds the responsibility of the UAE organization, as asking is a wrongdoing in Dubai and individuals are completely requested to not engage bums.

    Begging is a crime in UAE:
    The UAE has severe regulations against begging. The police in Dubai and Abu Dhabi on various events have launched anti-begging campaigns and also warn people against giving anything to poor people.

    Article 475, 476 and 477 of the UAE Reformatory Code condemns asking and any individual who is begging is punishable with imprisonment and a fine.

    Read more…

  • The 10 most peaceful nations (countries) on the planet

    Global Peace Index

    Each year, countries are ranked on the Global Peace Index (GPI), a composite measure of peacefulness according to the levels of safety and security in their society, involvement in local and international conflict, and their degree of militarization, among other things.

    The Institute for Economics and Peace develops the GPI by measuring a total of 23 indicators, including nuclear and heavy weapons, incarceration rate, homicide rate, political instability, and violent demonstrations.

    1. Iceland

    Iceland remains the most peaceful country in the world. It has held this position since 2008. One factor that puts Iceland so high on the Peace Index is that it has no army, navy, or air force.

    2. New Zealand

    New Zealand is the most peaceful country in the Asia-Pacific region and the second most peaceful country overall in the 2022 GPI. New Zealand is the most peaceful country in the Asia-Pacific region and the second most peaceful country overall in the 2022 GPI.

    3. Ireland

    Ireland is ranked as the third most peaceful country in the world and second most peaceful country in Europe (2022 GPI). Peacefulness improved by .019% with major improvements across the ‘Safety and Security’ and ‘militarization’ domains.

    4. Denmark

    Denmark recorded improvements in the ‘safety and security’ domain in 2022. However, it dropped one spot compared to last year, when it was ranked 3rd most peaceful country in the world.

    5. Austria

    Overall peacefulness in Austria improved by 0.018% making it the 5th most peaceful country in the world. The country ranks high in social stability and security and low on militarization.

    6. Portugal

    Portugal has one of the lowest crime rates and is the 6th most peaceful country in the world. However, it dropped two spots compared to 2021, when it came 4th in the GPI.

    7. Slovenia

    Slovenia’s overall GPI score also deteriorated, having dropped two spots from last year. However, it comes 7th in the 2022 GPI. The wealthiest economy of former Yugoslavia, Slovenia has one of the lowest crime rates.

    8. Czech Republic

    The Czech Republic improved in both the ‘militarization’ and ‘safety and security’ domains, making it the 8th most peaceful country in the world in 2022.

    9. Singapore

    Singapore moved a step higher from the 2021 Global Peace Index rankings and is now ranked the 9th most peaceful country. It remains the second most peaceful nation in the Asia-Pacific region for the third consecutive year.

    Singapore improved significantly in the ‘Militarization’ domain, with large improvements particularly in ‘nuclear and heavy weapons’ as well as in ‘weapon export’ between 2021 and 2022.

    10. Japan

    Japan reclaimed it’s position in the top 10 most peaceful countries on the 2022 Global Peace Index. The country improved significantly in the ‘militarization’ domain with large improvements particularly in the ‘nuclear and heavy weapons’

    Read More…