GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Quiz

07 Avulso

Wong Fei Hung 9 Fragen

Quiz starten

Fragen in diesem Quiz (9)

  1. 1What will be the result ofattempting to compile and run the following program?
    class TestClass{
    public static void main( String args[ ] ) {
    boolean b = false;
    int i = 1;
    do{
    i++ ;
    } while ( b = ! b) ;
    System. out. println( i ) ;
    }
    }
    1. AThe code will fail to compile, 'while' has an invalid condition expression.
    2. BIt will compile but will throw an exception at runtime.
    3. CIt will print 3.
    4. DIt will go in an infinite loop.
    5. EIt will print 1.
  2. 2What will the following code print?
    boolean flag = true;
    if( flag = false) {
    System. out. println( " 1" ) ;
    } else if( flag) {
    System. out. println( " 2" ) ;
    } else if( ! flag) {
    System. out. println( " 3" ) ;
    } else System. out. println( " 4" ) ;
    1. A1
    2. B2
    3. C3
    4. D4
    5. ECompilation error.
  3. 3Which ofthe following are valid at line 1?
    public class X{
    //line 1: insert code here.
    }
    1. AString s;
    2. BString s = 'asdf';
    3. CString s = 'a';
    4. DString s = this.toString();
    5. EString s = asdf;
  4. 4Given the following class definition:
    class A{
    protected int i;
    A( int i) { this. i = i; }
    }/
    / 1 : Insert code here
    Which ofthe following would be a valid class that can be inserted at //1 ?
    1. Aclass B { }
    2. Bclass B extends A { }
    3. Cclass B extends A { B( ) { System. out. println( " i = " + i) ; } }
    4. Dclass B { B( ) { } }
  5. 5What will the following program print?
    class LoopTest{
    public static void main( String args[ ] ) {
    int counter = 0;
    outer:
    for ( int i = 0; i < 3; i++) {
    middle:
    for ( int j = 0; j < 3; j ++) {
    inner:
    for ( int k = 0; k < 3; k++) {
    if ( k - j > 0) {
    break middle;
    }c
    ounter++;
    }
    }
    }S
    ystem. out. println( counter) ;
    }
    }
    1. A2
    2. B3
    3. C6
    4. D7
    5. E9
  6. 6What letters, and in what order, will be printed when the following program is
    compiled and run?
    public class FinallyTest{
    public static void main( String args[ ] ) throws Exception{
    try{
    m1( ) ;
    System. out. println( " A" ) ;
    }f
    inally{
    System. out. println( " B" ) ;
    }S
    ystem. out. println( " C" ) ;
    }p
    ublic static void m1( ) throws Exception { throw new Exception( ) ; }
    }
    1. A. It will print C and B, in that order.
    2. BIt will print A and B, in that order.
    3. CIt will print B and throw Exception.
    4. DIt will print A, B and C in that order.
    5. ECompile time error.
  7. 7class OverloadingTest{
    void m1( int x) {
    System. out. println( " m1 int" ) ;
    }v
    oid m1( double x) {
    System. out. println( " m1 double" ) ;
    }v
    oid m1( String x) {
    System. out. println( " m1 String" ) ;
    }
    }p
    ublic class TestClass {
    public static void main( String[ ] args) throws Exception {
    OverloadingTest ot = new OverloadingTest( ) ;
    ot. m1( 1. 0) ;
    }
    }Wha
    t will be the output?
    1. AIt will fail to compile.
    2. Bm1 int
    3. Cm1 double
    4. Dm1 String
  8. 8Given:
    class Square {
    private double side = 0;
    String color;
    public Square( double length) {
    this. side = length;
    }p
    ublic double getSide( ) { return side; }
    public void setSide( double side) { this. side = side; }
    }p
    ublic class TestClass {
    public static void main( String[ ] args) throws Exception {
    Square mysq = new Square( 10) ;
    mysq. color = " red" ;
    //set mysq' s side to 20
    }
    }Whi
    ch ofthe following statements will set mysq's side to 20?
    1. Amysq. side = 20;
    2. Bmysq = new Square( 20) ;
    3. Cmysq. setSide( 20) ;
    4. Dside = 20;
    5. ESquare. mysql. side = 20;
  9. 9What will be the result ofattempting to compile and run the following code?
    public class PromotionTest{
    public static void main( String args[ ] ) {
    int i = 5;
    float f = 5. 5f;
    double d = 3. 8;
    char c = ' a' ;
    if ( i == f) c++;
    if ( ( ( int) ( f + d) ) == ( ( int) f + ( int) d) ) c += 2;
    System. out. println( c) ;
    }
    }
    1. AThe code will fail to compile.
    2. BIt will print d.
    3. CIt will print c.
    4. DIt will print b.
    5. EIt will print a.

Informationen

Beschreibung
Exam Mock EthuWare -OCA-SE-7-I Quiz am 07 Avulso, erstellt von Wong Fei Hung am 30/07/2017.
Sprache
Português
Aufrufe
0
Bewertung
Noch keine Bewertungen
Bewerte dieses Quiz
Bewerte dieses Quiz

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck