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

Quiz

Week 5 Inheritance, Polymorphism, and Interfaces

Troy Bowlin 4 questions Updated 11 Oct 2016

Take the quiz

Questions in this quiz (4)

  1. 1A class that is NOT abstract is said to be?
    1. Aconcrete
    2. Bprivate
    3. Cprotected
    4. Dpolymorphic
  2. 2Suppose a class has public visibility and defines a protected method.
    Which of the following statements is correct?
    1. AThis method is only accessible from inside the class itself and from inside all subclasses.
    2. BIn a class, you cannot declare methods with a lower visibility than the visibility of the class in which it is defined.
    3. CFrom within protected methods you do not have access to public methods.
    4. DThis method is accessible from within the class itself and from within all classes defined in the same package as the class itself.
  3. 3In the following code, which method is the constructor?
    public class theDemo{
    in val 1'
    int val2;
    public int Demo1(){
    val1 = 1;
    }
    public int Demo2(){
    val2 = 2;
    }
    public void the Demo(){
    val1 = 0;
    val2 = 0;
    }
    public void showDemo(){
    System.out.println(val1);
    }
    }
    1. ADemo1()
    2. BDemo2()
    3. CtheDemo()
    4. DshowDemo()
  4. 4Consider the following code. What will the output of the code be?
    import java.io.*;
    public class myStuff
    {
    static int num1 = 0;
    int num2;
    public static void main(String a{}) throws Exception
    {
    mystuff s1 = new myStuff();
    s1.num1 = 5;
    s1.num2 = 10;
    myStuff s2 = new myStuff();
    s2.num1 = 15;
    s2.num2 = 15;
    System.out.println("s1 num1=" +s1.num1+ " num2=" +s1.num2+" s2num1=" +s2.num1+" num2=" +s2.num2);
    }
    }
    1. As1 num1= 15 num2=10 s2 num1=15 num2=15
    2. Blkj

Information

Description
Quiz on Week 5 Inheritance, Polymorphism, and Interfaces, created by Troy Bowlin on 10/10/2016.
Language
English
Views
1
History
Created on 10 Oct 2016 · updated on 11 Oct 2016
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?