Posts

Showing posts from March, 2024

Java Program Question - MNC - Technical Interview

                Here we are going to see a very Interesting and Complicated Java Programming Questions, which is asking in literally all MNC's Technical Interview's Input : Array -- { 5,1,8,-5,-1,6,2,-2,45,-55,-9,-89,9 } Output :  Array -- { -89 -55 -9 9 -5 5 -2 2 -1 1 6 8 45 } Program :  package com.array; public class SortingArray { public static void main ( String [] args ) { int [] arr = { 5 , 1 , 8 ,- 5 ,- 1 , 6 , 2 ,- 2 , 45 ,- 55 ,- 9 ,- 89 , 9 }; for ( int a : arr ) { System . out . print ( a + " " ); } System . out . println (); for ( int i = 0 ; i < arr . length ; i ++) { for ( int j = i ; j < arr . length ; j ++) { if ( arr [ i ]> arr [ j ]) { int temp = arr [ i ]; arr [ i ] = arr [ j ]; arr [ j ] = temp ; } } } for ( int i = 0 ; i < arr . length ; i ++) {            ...

Lazy Loading in Angular 17 - Standalone - Routing

                Here, we are going to see how to implement Lazy Loading in Angular 17 with standalone components. For that we need to do some configuration in our Component.ts file in which component we using routerLink attribute. Step - 1 : Create the routes we need to call and also our lazy loading component Syntax for Lazy load :           export const routes: Route = [                { path: 'path-name', loadComponent: () => import(' path-of-the-lazy-loading-component ').then(d                               => d.lazy-load-component-name) },          ] import { Route } from '@angular/router' ; import { FirstcomponentComponent } from './firstcomponent/firstcomponent.component' ; export const routes : Route [] = [   { path : 'first' ...

Observables & Promises in Angular 17 - Standalone - UI/UX

Observables and Promises :                Observables and Promises are both used for handling asynchronous operations in JavaScript, but they have different approaches and use cases.  Promises :                Promises were introduced in ES6 (ECMAScript 2015) and provide a way to handle asynchronous operations in a more structured and composable manner than traditional callback functions. A Promise represents the eventual completion (or failure) of an asynchronous operation and its resulting value. Promises have a few advantages over callbacks: They provide a cleaner and more readable syntax. They can be chained together using .then() and .catch() methods. They handle errors more effectively with the .catch() method. Observables :                 Observables, on the other other hand, are part of the RxJS (Reactive Extensions for JavaScript) li...

HostListener in Angular 17 | Standalone | Listening Events

Image
HostListener   :          This helps us to handle events more easily and one of the best thing about the Hostlistener is we can handle lost of events. Here is an example of how to use @HostListener :             Now we are create a HostListener for listening how many times the user click's our website.  Step - 1 :          We need to create method with functionality for what process we are going to execute when the event triggers.           clickCount = 0 ;    onHostClick ( ) {    this . clickCount ++ ;    } Step - 2 :          Use the @HostListener decorator for listen to the events trigger and we need to pass one argument to this decorator of which event we are listening. Like this           @ HostListener ( 'click' )    onHostClick ( ) { ...