Frequently Asked Java Program 01: Swap Two Numbers | 5 Ways of swapping Numbers

Поделиться
HTML-код
  • Опубликовано: 26 янв 2025

Комментарии • 197

  • @fault_less
    @fault_less Год назад +10

    Although I already met swapping values lots of times, It was interesting to watch other ways of this process, I’m impressed. Thanks for the video!

  • @Aabara_ka_dabara
    @Aabara_ka_dabara Год назад +15

    ::learning new ways of swapping from your videos. lil correction, at 11:49 extra zero should be put on the left side , then result will come as 30.

  • @Abcdddd2023
    @Abcdddd2023 4 года назад +164

    Frequently asked Java Programs (Series):
    1. Swap two Number
    2. Reverse a Number
    3. Reverse a String
    4. Palindrome Number
    5. Palindrome String
    6. Count number of Digits in a Number
    7. Count number of even and odd digits
    8. Count sum of digits in a number
    9. Find largest of 3 numbers
    10. Generate Fibonacci Series
    11. Check given number is Prime or Not
    12. Generate Random number
    13. Factorial of a number
    14. Find Sum of Elements in Array
    15. Print Even & Odd numbers from an Array
    16. Check the Equality of two Arrays
    17. Missing number in an Array
    18. Minimum & Maximum values in Array
    19. Duplicate Elements in Array
    20. Searching an Element in Array (Liner Search)
    22. Searching an Element in Array (Binary Search)
    23. Sort Elements in Array (Bubble Sort)
    24. Sort Elements in Array (Built-In Sort)
    25. Remove Junk or Special Characters in String
    26. Remove White Spaces in String
    27. Count occurrences of a character in a String
    28. Count Words in a String
    29. Reverse each word in a String
    30. Read Data from a Text File
    31. Write Data into a Text File

  • @kakashi99908
    @kakashi99908 Год назад +6

    Although 4:04 is simple math it really shows you problem solving skills and thinking outside the box. Once you can come up with these solutions on your own you are one big step along the coding way!

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @abhishekbehera2193
    @abhishekbehera2193 Месяц назад

    1:36 Using third variable
    3:18 Using + and - Operators
    5:23 Using * and / Operators
    8:22 Using Bitwise XOR(^) Operator
    14:22 In a Single Statement

  • @someguy459
    @someguy459 Год назад +6

    The last one is so clever I will use it from now on great video!

    • @sdetpavan
      @sdetpavan  Год назад +1

      Glad you liked it!

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @ubaboomika9247
    @ubaboomika9247 2 года назад +9

    Thank you so much sir. Your video made me get placed in a Multicoreware product company 💯❤️✌️

  • @shoaibjack
    @shoaibjack 3 года назад +65

    Hi, just want to point out that the XOR operation you did is wrong even if answer is right.. you can't put -/0 in end! It will change the value of binary number and in XOR if bit are same result is 0 not 1..
    it should be as follows -
    10 -> 1010 = 01010
    20 -> 10100=10100
    -------------------------------
    11110
    XOR Logic is simple if bits are same result is 0.
    Anyways great series. 🤚

  • @rohitraut5015
    @rohitraut5015 Год назад +7

    It's very impressive series that i have seen. I don't have words to explain about this series. Thanks a lot❤

  • @kennyi1200
    @kennyi1200 3 года назад +2

    Cool ...Swapping in one statement makes sense ))

  • @sainathbonala9738
    @sainathbonala9738 Год назад +3

    Thank you so much for your explanation sir. Easy to understand and easy to analyze also,even non-programmer also should understand easy way of your explanation sir.

  • @srinivasg2458
    @srinivasg2458 Год назад +2

    your training is silpmly like a wow....thanks

    • @sdetpavan
      @sdetpavan  Год назад +1

      My pleasure!

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @2anshumansehgal
    @2anshumansehgal 5 лет назад +21

    thank you sir..please make all JAVA related programming interview questions.

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @RiyaW97
    @RiyaW97 2 года назад +15

    Great playlist Sir😀 I got a job switch just going through your playlist. Thank u so much!

    • @nishantsharma6435
      @nishantsharma6435 2 года назад +2

      Hey riya, Mostly you follow which playlist i have done java now im doing collection framework next what should i do follow within few days i have interview also i want to crack that interview??

    • @fero___3005
      @fero___3005 2 года назад

      U mean 30 carat 20 ???? Please ^ = carat

    • @John12685
      @John12685 2 года назад

      @@nishantsharma6435 Which career u r willing to join? Is it SQA??

    • @nishantsharma6435
      @nishantsharma6435 2 года назад

      @@John12685 hey tayyab I'm looking for project engineer role?

    • @John12685
      @John12685 2 года назад

      @@nishantsharma6435 U mean software development?

  • @shaikdilkhushsyedbabasaifu3361
    @shaikdilkhushsyedbabasaifu3361 10 месяцев назад +1

    i knew three ways of doing this program of swap two numbers i didnt know we can use exor and that single statement. But the logic was good, it works well but which has less time complexity is it logic 1 and logic two????

  • @abhishekjaiswal6951
    @abhishekjaiswal6951 Год назад

    11:09 if both are equals it return 0 but you say return 1 in xor operation

  • @srsoftwares2184
    @srsoftwares2184 4 года назад +8

    Super sir... Keep doing more programs like this.. The main key in this video is explaining skills and different logics...thank you very much..

  • @BhoomikaD-r4l
    @BhoomikaD-r4l 9 месяцев назад +1

    15:50 if assignment operator operates from right to left then after (a=b) , the a+b= will be 40 right? why we have to take it as 10 again??

    • @premcaf
      @premcaf 21 день назад +1

      i too have the same doubt. may be when it is happening in the same line. it wont work like that.

  • @sachinkharwar3164
    @sachinkharwar3164 3 года назад +32

    Thanks for the easy explanation but the logic of calculating XOR is not Right. please make corrections.

  • @TheAIGadgetGuru
    @TheAIGadgetGuru 5 месяцев назад +3

    Hello sir your explaination is best, please create videos on pattern questions pleasseee🙃

  • @RajeshVerma-rs9rp
    @RajeshVerma-rs9rp 4 года назад +6

    Hi Pawan, Thanks for all your videos on FAQ. I think expression in last logic is still evaluated from Left to Right e.g. 10+20-(20). If a=b is executed first then both variables a and b will have same value 20 and expression will result in (20+20-20). Thanks

    • @poojachandavar1762
      @poojachandavar1762 3 года назад

      then should is be like b = (a+b)-(a=b);

    • @fero___3005
      @fero___3005 2 года назад

      U mean 30 carat 20 ???? Please ^ = carat

  • @duggirambabu7792
    @duggirambabu7792 2 года назад +1

    Your explanation is wrong at 11:04 to 11:07
    The correct is *if both bits are same it returns 0 otherwise it returns 1.*
    a = 10 = 01010
    b = 20 = 10100
    a = a^b = 01010 ^ 10100 = 11110 = 30
    b = a^b = 11110 ^ 10100 = 01010 = 10
    a = a^b = 11110 ^ 01010 = 10100 = 20
    I like logic 4 & 5.
    I appreciate you...

  • @RamyHaramy
    @RamyHaramy 2 года назад +3

    You are an excellent teacher, I am really impressed!

  • @ShubhamAgarwal2
    @ShubhamAgarwal2 5 лет назад +12

    You did one mistake at 11:00 . When both are same Output should be Zero.

  • @kirant2849
    @kirant2849 5 лет назад +1

    Wow.. these many ways to do SWAP?....really good to know different ways..Your way of teaching/explaining really really awesome

    • @sdetpavan
      @sdetpavan  5 лет назад +5

      Thank you so much for your feedback. Please share my videos with your friends or colleagues.

    • @fero___3005
      @fero___3005 2 года назад

      @@sdetpavan U mean 30 carat 20 ???? Please ^ = carat

  • @arpitac9481
    @arpitac9481 2 года назад +1

    The most easiest explanation heard ever 💥💥🤗🤗

  • @digambarkalse7993
    @digambarkalse7993 Год назад +2

    Sir you are doing amazing job 👏.
    Hats of to you Sir ❤.

  • @GOPIKRISHNAN21
    @GOPIKRISHNAN21 2 года назад +1

    can you explain this question please sir
    Secure Vault is a lock manufacturing company, they are not doing so great. Recent crime
    statistics show that this company's lock is behind most of the successful robberies. They are
    not making distinct keys for all locks. A lock with key number 10 can be opened with all the
    other 1,2,5 numbered keys. Cops asked you to write a program for finding similar keys so
    that people can be alerted and they can change their lock.
    Input format: the input contains the single integer n.
    input constraints: 1

  • @pritiwadhera2260
    @pritiwadhera2260 11 месяцев назад +8

    Watching 3 hour before exam 😂
    Thankyou sir 🙏🙏

    • @sdetpavan
      @sdetpavan  11 месяцев назад

      Welcome

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @pavithrans7992
    @pavithrans7992 3 года назад +10

    Really it's amazing explanation😍 sir plz can u upload the STRING, ARRAYS, MATRIX and CONVERSATION programs.

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @VavalapurapuMeghana
    @VavalapurapuMeghana 5 месяцев назад

    Thanks for your clarity explanation sir thank you so much 😁

  • @nonegirl112
    @nonegirl112 Год назад +1

    Thank you sir very nice explanation

  • @lochanaananddussa7815
    @lochanaananddussa7815 9 месяцев назад

    Hi, just wanted to check if this logic can be used to swap the numbers?
    int a, b; a = 10; b = 20; a+=10; b-=10;
    Please confirm.

  • @GOPIKRISHNAN21
    @GOPIKRISHNAN21 2 года назад +1

    sir your way of teaching is very good. The way you explain the program is so nice.

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @shubhamshende9995
    @shubhamshende9995 Год назад +1

    Amazing 🎉

  • @chintuyadav4270
    @chintuyadav4270 4 года назад +3

    U r great sir loved it👍👍

  • @rajkoli8150
    @rajkoli8150 2 года назад +1

    hello sir how toi write this program this is my interview question from IBM ...........Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum, The function should find all triplets in the array that sum up to the target sum and print all the triplets. The numbers in each triptlet should be ordered in ascending order, and the triplets themselves should be ordered in ascending order with respect to the numbers triplets.
    If no three number sum, the function should return an empty array.
    Input = [8,10,-2,49,14]
    Target sum : 57
    Output: [[10,-2,49]]

  • @omkaravghade9732
    @omkaravghade9732 4 месяца назад

    USEFUL👍👍

  • @simhadrisuresh8630
    @simhadrisuresh8630 11 месяцев назад

    Hi sir any pdf available whole programs and java course in your class

  • @immuind2009
    @immuind2009 4 года назад +2

    hello sir can you tell me how to slove the problem "= cnnot resolve the veriable "d
    shows in java

  • @virajladvikar9184
    @virajladvikar9184 2 года назад

    int a=10, b=20;

    sir ,it is correct or not
    int x = a>b? a : b ;
    System.out.println("a"+x);
    int y = a

  • @cherylthai101
    @cherylthai101 3 года назад +2

    thank you, this is very helpful information

  • @rutujamohite1755
    @rutujamohite1755 2 года назад +1

    thnq so much sir for providing such an amezing platform to us

    • @sdetpavan
      @sdetpavan  2 года назад

      Welcome

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @arpitsrivastava9610
    @arpitsrivastava9610 11 месяцев назад

    11:11 u complete made us confused. You can not take a 0 at last .and 0+1 will give you 1 or vice versa in xor . Although the result is correct but u explained wrong.

  • @khybersial6171
    @khybersial6171 2 года назад +1

    love and respect from Afghanistan.

  • @XYz-cp9he
    @XYz-cp9he Год назад

    Sir in last apprach a+b - (a=b) .. when we assigning the value of b to a then a variable will be updated in program then while coming to a+b is should be actually 20 + 20 naa🥲🥲..

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @gaddamgodhavari7766
    @gaddamgodhavari7766 2 года назад

    While explaining binary, 0 should come first, and xor operation you explained wrong(Time11:22)

  • @Bashashaik-gb5lq
    @Bashashaik-gb5lq Месяц назад

    Sir, XOR operations you did in wrong way please correct it or trim the video, the ZERO should be added on the left side

  • @maheshmyadari.3746
    @maheshmyadari.3746 Год назад

    Sir it shows " module java is not found" in the output of the program...?? What is the problem sir..!??

  • @KalpanaBattula-g1q
    @KalpanaBattula-g1q 3 месяца назад +1

    Thank you so much sir 🙏

  • @amitsillarkar2609
    @amitsillarkar2609 2 года назад +1

    wow Sir thank you
    remembering the math days formula😍

    • @sdetpavan
      @sdetpavan  2 года назад +1

      You are most welcome

  • @shivasai5604
    @shivasai5604 Год назад +2

    sir this 30 problems are enough for a manual tester to get a job with two years of experience could u please reply to my comment sir

  • @the_aspirants2024
    @the_aspirants2024 9 месяцев назад

    Sir apne XOR me both equal hai to 0 bataye diagram me or coding me both equal h to 1 count kiye , nhi smjhe? Koe mistake hua? Ya mujhe smjh ni aaya

  • @photobydeva1046
    @photobydeva1046 2 года назад +1

    Well teacher sir...

  • @anilgund9827
    @anilgund9827 2 года назад +1

    thank you very much sir for these lectures these are very useful for us

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @boopathyn6079
    @boopathyn6079 3 года назад +1

    I like the last logic. Thanks

  • @sridhardega7540
    @sridhardega7540 5 лет назад +1

    Sir very nice explanation please do all possible programs in Java for interview

  • @benjicanones1454
    @benjicanones1454 Год назад +1

    Superb!

  • @rizwanmamun5554
    @rizwanmamun5554 Год назад

    last one is dope 🔥🔥🔥

  • @KrisuParikh
    @KrisuParikh 27 дней назад

    got new approach

  • @gauri992
    @gauri992 3 года назад +2

    ur the best sir

  • @banalasai7643
    @banalasai7643 3 года назад +1

    Thank you sir, it's an useful information.

  • @AbhishekSingh-fk9yf
    @AbhishekSingh-fk9yf 3 года назад

    Which ide you are using.

  • @SurajSingh-sy9kr
    @SurajSingh-sy9kr 2 года назад +1

    amazing sir helpful videos

  • @sachinbangera-qy8sc
    @sachinbangera-qy8sc Год назад

    Hi Sir, please add problem regarding to Permutation of Numbers in Java

  • @vighneshsunil3986
    @vighneshsunil3986 3 года назад +1

    u r lit Sir. Respect

  • @M0LHA
    @M0LHA Год назад

    That's nuts. I would never ask such a stupid question in an interview.

  • @MyChannel-ik2kc
    @MyChannel-ik2kc 4 года назад +2

    You showed in the X-OR table 0 0 becomes 0 and 1 1 becomes 0 but in the explanation u told opposite.

    • @eshwarpatil4302
      @eshwarpatil4302 4 года назад +1

      The "dash" is at start and not at last. Sir's mistake.

  • @roopadolli1910
    @roopadolli1910 5 лет назад +3

    Nice sir.. Please cover all programs related to string..

  • @kummarisudhamani3706
    @kummarisudhamani3706 7 месяцев назад

    Single statement doesn't give the output sir

  • @jafarbasha4394
    @jafarbasha4394 4 года назад +1

    Tnq sir... Nice teaching

  • @gokulv377
    @gokulv377 11 месяцев назад

    sir what is the use of "+a+" "+b
    i could not understand this concept

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

    • @Aniket-o5h
      @Aniket-o5h Месяц назад

      For printing the multiple variables at a time in one statement, we have to concanate in between both variables so we can make a space also when printing these variables.

  • @senthilmuruganr234
    @senthilmuruganr234 3 года назад +1

    Excellent sir

  • @naveenks2135
    @naveenks2135 4 года назад +2

    Thank you a lot for this videos

  • @ito6787
    @ito6787 2 года назад

    My 4 key doesn't work, it just types 23 or pressed 2 and 3 very quickly, I'm so lost! Is there a fix to that?

  • @gayathri-8-i6s
    @gayathri-8-i6s 2 года назад

    Can anyone explain on a^b such that a equal to 10 and b equal to 20 , as he told oppositely

  • @Paplu4949
    @Paplu4949 6 месяцев назад

    Thank you sir Ji

  • @deepthimopuru6314
    @deepthimopuru6314 5 лет назад +3

    thanks for you videos

  • @mayurramteke2499
    @mayurramteke2499 4 года назад +1

    I like it!!🙏

  • @developerinprogress9382
    @developerinprogress9382 4 года назад

    very good approach to lure all the people who thought programming was boring

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @naveensrinivasan6731
    @naveensrinivasan6731 9 месяцев назад

    RESPECTED SIR,I NEED RECURSION VIDEO IN JAVA PLEASE IMMEDIATELY UPLOAD.I CANT UNDERSTAND OTHER'S PLEASE HELP ME SOON.

  • @avinashravte2188
    @avinashravte2188 2 года назад

    Can you WAP for , if input is demo and expected output is deemmmoooo

  • @Aaqibkhan-oy9fr
    @Aaqibkhan-oy9fr 2 года назад +1

    Thank you so much sir

  • @chandandas188
    @chandandas188 4 года назад

    Sir if you dont mind Can you please share your Git link with these programming

  • @rajeshrao5099
    @rajeshrao5099 4 года назад

    Can you please share programs in your comments section?

  • @kvelez
    @kvelez Год назад +1

    XOR was amazing.

  • @praveenkumarbiswasroy3927
    @praveenkumarbiswasroy3927 4 года назад

    Thank u sir for all the videos... Sir please explain us how to convert number to word format... Please sir....

    • @testingshastra
      @testingshastra 10 месяцев назад

      ruclips.net/video/ZGzt3XtaJ-g/видео.html

  • @karanmahadik1096
    @karanmahadik1096 2 года назад +1

    Thanks brother

  • @VividAura123
    @VividAura123 2 года назад +1

    last method is awesome

  • @fero___3005
    @fero___3005 2 года назад

    U mean 30 carat 20 ???? Please ^ = carat

  • @harikam1766
    @harikam1766 Год назад

    Why you in a for +a +b

  • @ranjinidpiyengar
    @ranjinidpiyengar 2 года назад +1

    Hello sir... your teaching is amazing...I am struggling to write a code for a java program...can you please help me out
    WAP to read value to an array except multiple of three position.
    Where multiples of three position will have sum of previous two values
    a[0] = 1
    a[1] = 2
    a[2] ///Skip dont read; values should be 3 = 2 + 1
    a[3] = 5
    a[4] = 6
    a[5] ///Skip dont read; values should be 11 = 6 + 5
    a[6] = 1
    a[7] = 1
    a[8] ///Skip dont read; values should be 2 = 1 + 1

    • @syedzabi3747
      @syedzabi3747 2 года назад

      here is a code i kw its been a long any way
      public class Main {
      public static void main(String[] args) {
      int[] a = new int[]{1, 2, 0, 5, 6, 0, 1, 1, 0};
      for (int i = 2; i < a.length; i += 3) {
      a[i] = a[i-1] + a[i-2];
      }
      System.out.println(Arrays.toString(a));
      }
      }

  • @sharanyabhiram3601
    @sharanyabhiram3601 10 месяцев назад

    I have one java programming question to solve
    I give Input as 5
    And type random binary numbers as input
    1
    0
    1
    1
    1
    My output should convert that binary number to decimal number 23

  • @saswatasaha9519
    @saswatasaha9519 10 месяцев назад

    sir please mention the time and space complexity

  • @hemantpatro956
    @hemantpatro956 Год назад

    Its too nice

  • @elturky2356
    @elturky2356 Год назад

    صلي علي النبي❤

  • @johnnyjohn9134
    @johnnyjohn9134 5 лет назад

    Sire You are a great teacher!!! Thank You for all your work! Cod bless You!

  • @ColorOfTheSky_
    @ColorOfTheSky_ 10 месяцев назад

    what is that noise 11 minute

  • @smrutichandrasekaran4090
    @smrutichandrasekaran4090 Год назад

    Screen is not clear

  • @vishnupriya739
    @vishnupriya739 3 года назад +1

    very satisfied