What is the output of this program? (or, can it be compiled)?


In reference refers to the default input device, i.e. keyboard. Out



Download 1,04 Mb.
bet4/4
Sana22.06.2021
Hajmi1,04 Mb.
#73073
1   2   3   4
Bog'liq
BasicJavaTask5 homework

In reference refers to the default input device, i.e. keyboard.

  • Out and err refers to the default output device, i.e. console.



    • System.in: This is the standard input stream that is used to read characters from the keyboard or any other standard input device.

    • System.out: This is the standard output stream that is used to produce the result of a program on an output device like the computer screen.

    • Here is a list of the various print functions that we use to output statements:

    i) print(): This method in Java is used to display a text on the console. This text is passed as the parameter to this method in the form of String. This method prints the text on the console and the cursor remains at the end of the text at the console. The next printing takes place from just here.



    Syntax:

    System.out.print (parameter);

    ii) println(): This method in Java is also used to display a text on the console. It prints the text on the console and the cursor moves to the start of the next line at the console.

    The next printing takes place from the next line.

    Syntax:

    System.out.println(parameter);

    iii) printf(): This is the easiest of all methods as this is similar to printf in C. Note that System.out.print() and System.out.println() take a single argument, but printf() may take multiple arguments. This is used to format the output in Java.

    iv) System.err: This is the standard error stream that is used to output all the error data that a program might throw, on a computer screen or any standard output device.

    This stream also uses all the 3 above-mentioned functions to output the error data:

    print()


    println()

    printf()



    1. What is the output?

    String s = "Basic Java Course";

    int i = 1;

    while(i < s.length()){

    System.out.print(s.charAt(i));

    i += 2;

    }

    Ans: The output of the above program is shown below:






    1. Introduce yourself using Java source code. You can write your name, ID, or your origin, etc!

    Ans: My self-introduction using java code is shown below:





    Download 1,04 Mb.

    Do'stlaringiz bilan baham:
  • 1   2   3   4




    Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
    ma'muriyatiga murojaat qiling

    kiriting | ro'yxatdan o'tish
        Bosh sahifa
    юртда тантана
    Боғда битган
    Бугун юртда
    Эшитганлар жилманглар
    Эшитмадим деманглар
    битган бодомлар
    Yangiariq tumani
    qitish marakazi
    Raqamli texnologiyalar
    ilishida muhokamadan
    tasdiqqa tavsiya
    tavsiya etilgan
    iqtisodiyot kafedrasi
    steiermarkischen landesregierung
    asarlaringizni yuboring
    o'zingizning asarlaringizni
    Iltimos faqat
    faqat o'zingizning
    steierm rkischen
    landesregierung fachabteilung
    rkischen landesregierung
    hamshira loyihasi
    loyihasi mavsum
    faolyatining oqibatlari
    asosiy adabiyotlar
    fakulteti ahborot
    ahborot havfsizligi
    havfsizligi kafedrasi
    fanidan bo’yicha
    fakulteti iqtisodiyot
    boshqaruv fakulteti
    chiqarishda boshqaruv
    ishlab chiqarishda
    iqtisodiyot fakultet
    multiservis tarmoqlari
    fanidan asosiy
    Uzbek fanidan
    mavzulari potok
    asosidagi multiservis
    'aliyyil a'ziym
    billahil 'aliyyil
    illaa billahil
    quvvata illaa
    falah' deganida
    Kompyuter savodxonligi
    bo’yicha mustaqil
    'alal falah'
    Hayya 'alal
    'alas soloh
    Hayya 'alas
    mavsum boyicha


    yuklab olish