End of Lesson ExercisesΒΆ

Answer the following questions on a piece of paper to fully understand the lesson content. Some questions might require you to research further.

  1. Convert this code on one line to the proper format of multiple lines.

    1
    public class OneLiner{public static void main(String[] args){System.out.println("This is a one liner!");}}
    
  2. Convert this K&R indentation to Allman indentation.

    1
    2
    3
    4
    5
    6
    7
    public class Indentation {
       public static void main(String[] args) {
          System.out.println("Some");
          System.out.println("Random");
          System.out.println("Text");
       }
    }
    
  3. Find the names for 5 other indentation styles.

  4. Space out the expressions here properly.

    1
    System.out.println(10+10+2*4/6%50*22-100);
    
  5. Comment out line 5 and 7 of the code below.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    public class Indentation
    {
       public static void main(String[] args)
       {
          System.out.println("Thats");
          System.out.println("Random");
          System.out.println("Stuff");
          System.out.println(":)");
       }
    }
    
  6. Find and give a description of 8 tags from Javadoc comments.

  7. Describe all three types of errors.

  8. Find more examples of errors online and how the errors were fixed.