GoConqr has a new look! Let us know what you think.

Quiz

Coffee001

James Fraley 4 questions

Take the quiz

Questions in this quiz (4)

  1. 1package com.protoeffect;

    public class Test {
    static int count = 0;
    int i = 0;

    public void changeCount(){
    while(i<5){
    i++;
    count++;
    }
    }
    }

    public class Main {
    public static void main(String[] args) {
    Test check1 = new Test();
    Test check2 = new Test();
    check1.changeCount();
    check2.changeCount();
    System.out.println(check1.count + " : " + check2.count);
    }
    }
    1. A10 : 10
    2. B5 : 5
    3. C5 : 10
    4. DCompilation fails
  2. 2package com.protoeffect;

    public class Main {
    public static void main(String[] args) {
    String product = "Pen";
    product.toLowerCase();
    product.concat(" BOX".toLowerCase());
    System.out.println(product.substring(4,6));
    }
    }
    1. Abox
    2. Bnbo
    3. Cbo
    4. Dnb
    5. EAn exception is thrown at runtime.
  3. 3Which three are advantages of the Java exception mechanism?
    1. AImproves the program structure because the error handling code is separated from the normal program function.
    2. BProvides a set of standard exceptions that covers all the possible errors.
    3. CImproves the program structure because the programmer can choose where to handle exceptions.
    4. DImproves the program structure because exceptions must be handled in the method in which they occurred.
    5. EAllows the creation of new exceptions that are tailored to the particular program being created.
  4. 4<PRE>
    package com.protoeffect;

    public class Person {
    String name;
    int age = 25;

    public Person(String name) {
    this(); //line n1
    setName(name);
    }

    public Person(String name, int age){
    Person(name); //line n2
    setAge(age);
    }

    //setter and getter methods go here

    public String show(){
    return name + " " + age + " " + number;
    }
    }

    package com.protoeffect;

    public class Main {

    public static void main(String[] args) {
    Person p1 = new Person("Jesse");
    Person p2 = new Person("Walter",52);
    System.out.println(p1.show());
    System.out.println(p2.show());
    }
    }
    </PRE>
    1. AJesse 25
      Waller 52
    2. BCompilation fails only at line n1
    3. CCompilation fails only at line n2
    4. DCompilation fails at both line n1 and line n2

Information

Description
Quiz on Coffee001, created by James Fraley on 25/01/2017.
Language
English
Views
0
Rating
No ratings yet
Rate this quiz
Rate this quiz

Feedback

What is it about?

What do you think of the new look?

How do you like it?