Preview

02 - Your first Java Program

 1. Select one of the following options that best applies to you.

  I don't have a clue what's going on - haven't created anything yet

  I'm just doing the tests but have not done any coding yet.

  I have created my first Java program

  I have not yet created my first Java program

 2. In the following code, what is the name of the package?
package hello; 

public class HelloWorld {
	public static void main(String[] args) { 
		System.out.println("Hello World!");
	}
	String x = new String("hello");
}

 3. In the above example, 'Hello World' is the name of the ______.
We would recommend the following video if you need to brush up on your foundational knowledge.

 4. In Java, a class should be a noun and the first letter would be a capital letter.

  True

  False

 5. A class can be thought of as a blueprint or template for an object. Classes have ______ and properties inside them.

  maintainers

  colons

  methods

  constants

 6. Refer to the code in question 2. What is 'main'?

  It is a property

  It is a method inside the class HelloWorld

  It is a class inside a package

  It is a variable inside the method

 7. The more technical name for a class, method or property 'name' is an ______________.

  identifier

  meem

  compiler

  instance

 8. When a class, variable or method name consists of more than one word, in Java we use an upper case letter to symbolise the beginning of a new word e.g. MyClass. This is called:

  JustInCase

  CamelCase

  ElephantCase

  FoxCase

 9. Referring to the code in question 2, what is System.out.println("Hello World!");?

  A class inside the package

  A statement of code inside the method

  Bytecode before compilation

  A property inside the class

 10. How many members are present in the code in question 2?

  2

  3

  4

  1

 11. The following code refers to the creation of a member inside the class, more specifically, a ______________ that simply stores a value.
String x = new String("hello"); //created a new member

  object

  instance

  property

  method

 12. public is an ____________. Any class from any package may use the class with a public identifier.

  encapsulator

  access modifier

  middle point

  object creator

 13. By convention, it is a good idea to never indent anything that is inside curly braces. This is required for a language like python but it is best not applied in Java.

  TRUE

  FALSE

 14. With a few exceptions (e.g. creating a library or standalone module), every single java project needs a public method called _____.

 15. The main method will never be executed automatically when we execute or run our program. If we change 'main' to 'rain' and have no main method, the program will still run fine.

  True

  False

 16. In English, a dot indicates the end of a sentence. A dot in java (in this example) indicates that we want to execute or call the method 'drive' on the variable car.
 @Test
public voice shouldDrive(){
  car.drive(100);
}

  False

  True

 17. A _____ is used to indicate the end of a statement in java - a dot is alredy used for something else, so we can't use that!

  star

  quotation mark

  semi-colon

  comma

 18. In Java, a static member is a member of a class that isn?t associated with an instance of a class. Instead, the member belongs to the class itself.
Further notes: static is a keyword. If we declare any method as static,
 it is known as the static method. The core advantage of 
the static method is that there is no need to create an
 object to invoke the static method

  False

  True

 19. What is the output of the following program?
public class Simple{  
    public static void main(String args[]){  
     System.out.println("Hello Java");  
    }  
}  

 20. Look at line 2 of the code below. _____ is the return type of the method. It means it doesn't return any value.
public class Simple{  
    public static void main(String args[]){  
     System.out.println("Hello Java");  
    }  
}