Java danuma bedaganna kamathi aya innawada?

h_abeysinghe

Well-known member
  • Sep 4, 2008
    12,096
    435
    83
    32
    toronto,canada
    Written Answers and Marks :D

    11.
    List TWO code conventions associated with comments.
    Marks: 2.0

    ANS:

    1. A comment block should be included before each class and method(except main method).
    2. Comments should not reiterate what is clear from the code.
    3. An introductory comment should begin a program.

    12.List ONE code convention related to indentation.
    Marks: 1.0

    ANS:
    1. Statements in a method should be indented.
    2. An open curly brace(bracket, { ) should be placed on the same line as the class or method declaration, and the closing curly brace (}) should be on a separate line and aligned with the class or method declaration.
    13.Identify FOUR violations of Code Conventions in the above application.
    Marks: 4.0

    Code:
    /**
     * PrintInternetRules.java
     * Name: WongPuter
     * Description: Displays student rules for accessing the Internet.
    /*
    
    public class PrintInternetRules
      public static void main(String[] args) {
        System.out.println("Internet Rules\n");
          System.out.println("1. Use school issued login and password.");
          System.out.println("2. Do not download any files.")
          system.out.println("3. Do not reveal personal information.");
      }
    }
    ANSWER

    1. Date is missing in the comment block.
    2. Class name should be a noun.
    3. The opening brace bracket ({) of main method should line up with the closing brace bracket (}).
    4. System.out.println("Internet Rules\n"); should line up with the rest of System.out.println.
    Correction:
    Code:
     /**
     * PrintInternetRules.java
     * Name: WongPuter
     *[COLOR=Red] Date: Feb 18, 2011[/COLOR]
     * Description: Displays student rules for accessing the Internet.
    */
    
    public class [COLOR=Red]InternetRules[/COLOR]
      public static void main(String[] args) 
    [COLOR=Red]  {[/COLOR]
          [COLOR=Red]System.out.println("Internet Rules\n");[/COLOR]
          System.out.println("1. Use school issued login and password.");
          System.out.println("2. Do not download any files.")
          system.out.println("3. Do not reveal personal information.");
      }
    }


    14.Identify FOUR errors in the above application.
    Marks: 4.0

    Code:
    /**
     * PrintInternetRules.java
     * Description: Displays student rules for accessing the Internet.
    /*
    
    public class PrintInternetRules
      public static void main(String[] args) {
        System.out.println("Internet Rules\n");
          System.out.println("1. Use school issued login and password.");
          System.out.println("2. Do not download any files.")
          system.out.println("3. Do not reveal personal information.");
      }
    }

    ANSWER


    1. The comment block should be closed with */ but not /*.
    2. A brace bracket is missing after the class declaration.
    3. A ; is missing at the end of System.out.println("2. Do not download any files.")
    4. "system" should be typed as "System"
    Correction:
    Code:
    /**
     * PrintInternetRules.java
     * Description: Displays student rules for accessing the Internet.
    [COLOR=Red] */[/COLOR]
    
    public class PrintInternetRules
    [COLOR=Red]{[/COLOR]
      public static void main(String[] args) {
        System.out.println("Internet Rules\n");
          System.out.println("1. Use school issued login and password.");
          System.out.println("2. Do not download any files.")[COLOR=Red];[/COLOR]
          [COLOR=Red]S[/COLOR]ystem.out.println("3. Do not reveal personal information.");
      }
    }
    :D
    meka apita dunne Online Quiz ekak widiyata pc eken karana :D so ekama copy karala damma ;)
     
    Last edited:

    h_abeysinghe

    Well-known member
  • Sep 4, 2008
    12,096
    435
    83
    32
    toronto,canada
    kauruth nadda help ekata ??
    hmm machn sorry uba ewapu pm ekatath mata reply danna amataka una :(:(
    mama nam machn ohoma ewa hadana danne nae:( eke tiyena eka balagena ne hadana one ::( eka podak amrui ekai
    descripion ekak tibba nam onna podak hari balana tibba :nerd:
    man guess karapu widiyata meke tiyene nam
    customer gen details aaran e customer regular customer kenek nam discount ekak denwa
    guest nam item eka denawa :D owage ekak thama man hithane nam
    hariyatama danne nae machn :no::no: meke inna anith members la nam dannawa athi samahara wita :yes: :D eyalagen comnts ei ne balamu ko :D
     

    Mal Baba

    Well-known member
  • Apr 26, 2009
    106,262
    5,596
    113
    Blob Storage
    www.37innovate.com
    menna katiyata podi Quiz ekak :D
    meka ape skul eke dunna 1st basic Quiz eka :D
    onna patan gannwa :D isselama MCQ 10k tiyenwa
    4k writing tiyenwa :D
    total marks=21
    balanako serama karala kiyak tiyeda kiyala, :yes: mama nam 21/21 gattha :D me post eke MCQ dala anith eke writen question 4 danam :D

    MCQ
    1.Which is another name for package?
    a. object
    b. library
    c. method
    d. string

    2.Which is a set of guidelines for writing an application?
    a. algorithm
    b. code conventions
    c. comments
    d. class

    3.Which statement displays Hello, world! on the screen?
    a. System.out.println("Hello, world!");
    b. system.println("Hello, world!");
    c. System.println('Hello, world!');
    d. System.out.println('Hello, world!');

    4.Which is used to enclose single or multiline comments?
    a. \* *\
    b. /* */
    c. // //
    d. \\ \\

    5.What effect does \n have when included in an output string?
    a. A \n is displayed in the output.
    b. A N is displayed in the output.
    c. A tab (8 spaces) is displayed in the output.
    d. Output is moved to the next line.

    6.What effect does \t have when included in an output string?
    a. A \t is displayed in the output.
    b. Output is moved to the next line.
    c. A T is displayed in the output.
    d. A tab (8 spaces) is displayed in the output.

    7.The main() method is defined as
    a. public static void main(string[] args)
    b. public static void Main(String[] args)
    c. public static void main(String[] args)
    d. public static main(String[] args)

    8.Which describes the output displayed by the statement:
    System.out.format("%-10s %10s %8s", "Item", "Quantity", "Cost\n");
    a. Item,Quantity, and Cost will be left aligned.
    b. Item will be left aligned, Quantity and Cost will be right aligned.
    c. Item, Quantity, and Cost will be right aligned.
    d. Item will be right aligned, Quantity and Cost will be left aligned.

    9.What does the following symbol indicate in a flow chart?
    Symbol_Oval.gif

    a. Process
    b. Start or End
    c. Input or Output
    d. Selection

    10.What does the following symbol indicate in a flow chart?
    Symbol_Rectangle.gif

    a. Start or End
    b. Process
    c. Selection
    d. Input or Output








    Flow Chart Ganan Tikak Hoyala Diyan Ko Machan
     

    NipunaDDDD

    Well-known member
  • Jan 16, 2009
    1,556
    120
    63
    මට java වල object oriented concepts (වස්තුමය නැබුරුතා සංකල්ප)
    සිංහලෙන් උදාහරන එක්ක කියල දෙන්න පුලුවන්ද?

    එහෙම නැත්තම් එහෙම තියන website එක්ක හරි දෙනවද?

    සේරම object oriented concepts ‍ටික තියනවනම් ගොඩක් හොදයි.

    මම Search කරල English ඒ‍ව ටිකක් කියවල ටිකක් තේරුම් ගත්තා.



    ‍බොහෝම ස්තූතියි.