Quiz
Week 5 Inheritance, Polymorphism, and Interfaces
Fragen in diesem Quiz (4)
1A class that is NOT abstract is said to be?
- Aconcrete
- Bprivate
- Cprotected
- Dpolymorphic
2Suppose a class has public visibility and defines a protected method.
Which of the following statements is correct?- AThis method is only accessible from inside the class itself and from inside all subclasses.
- BIn a class, you cannot declare methods with a lower visibility than the visibility of the class in which it is defined.
- CFrom within protected methods you do not have access to public methods.
- DThis method is accessible from within the class itself and from within all classes defined in the same package as the class itself.
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);
}
}- ADemo1()
- BDemo2()
- CtheDemo()
- DshowDemo()
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);
}
}- As1 num1= 15 num2=10 s2 num1=15 num2=15
- Blkj
Informationen
- Beschreibung
- Quiz am Week 5 Inheritance, Polymorphism, and Interfaces, erstellt von Troy Bowlin am 10/10/2016.
- Autor
- Troy Bowlin
- Sprache
- English
- Aufrufe
- 1
- Verlauf
- Erstellt am 10 Okt 2016 · aktualisiert am 11 Okt 2016
- Bewertung
- Noch keine Bewertungen Bewerte dieses Quiz