Halaman

Monday, July 20, 2020

Section 1 Quiz Java Programming 2019 Learner - English


Section 1
 (Answer all questions in this section)

The following code can be compiled, True/False?
byte b = 1;
b = b + 1;

 True

 False (*)


The following code can be compiled, True/False?
byte b = 1 + 1; 

 True (*)

 False

Class Object is the root of the Java class hierarchy. True or False?

 True (*)

 False
       
Which statement is a syntactically correct way to declare an Array?

 int[5] id={1,2,3,4,5};

 int i[1] id;

 int id[]; (*)

 int i[1];

Which of the following operators are relational operators?(Choose Two) 

   (Choose all correct answers)

 "+="

 "="

 "!=" (*)

 ">=" (*)

What is the output from the following code snippet?
public class Test {
public static void main(String[] args) {
  System.out.println(1 + 2 + "java" + 3);
}
} 

 The code will compile and print "6java"

 The code will compile and print "3java3" (*)

 The code does not compile.

 The code will compile and print "java3"

 The code will compile and print "12java3"

When you instantiate a subclass, the superclass constructor will be also invoked. True or False?

 True (*)

 False

Which two statements prevent a method from being overriden? (Choose Two)
   (Choose all correct answers)

 Static final void act() {} (*)

 Static void act() {}

 Final void act() {} (*)

 Void final act() {}

 Final abstract void act() {}

What is the output from the following code snippet?

String str1 = "java";

char[] c = {'j', 'a', 'v', 'a'};

System.out.println(str1.equals(c));

System.out.println(t == c);

 The code will compile and print "true, false"

 The code will compile and print "false,false"

 The code will compile and print "true true"

 The code will compile and print "false, true"

 The code does not compile. (*)

What is the output from the following code snippet?
int i=0,j=0;
i=++i;
j=i++;

System.out.println("i=" + i + " " + "j=" + j);

 The code does not compile.

 The code will compile and print "i=2 j=2"

 The code will compile and print "i=1 j=1"

 The code will compile and print "i=1 j=2"

 The code will compile and print "i=2 j=1" (*)

What is the output from the following code?
int x=0;
int y=5;
do{
   ++x;
   y--;
}while(x<3);
System.out.println(x + " " + y);

 2 2

3 3

 2 3

 3 2 (*)

Examine the partial class declaration below:
class Foo{
  public Foo(String s,int i ){
    this(i);
  }
  public Foo(int i){
  }



  public Foo(int i,int j){
  }
}
Which of following statements can not be used to create a instance of Foo?

 Foo f=new Foo(1);

 Foo f=new Foo("java",1);

 Foo f=new Foo(); (*)

 Foo f=new Foo(1,2);

You declare a method:
public void act(Student s){}
Which of following arguments can be passed into the method? (Choose Two)

   (Choose all correct answers)

 Interface

 Type of the subclass of Student (*)

 Type of Student class (*)

 Type of Object class

What is the output from the following code snippet?
String str1= "java";
String str2=new String("java");
System.out.println( str1==str2 );
System.out.println( str1==str2.intern() );

 The code will compile and print "true true"

 The code will compile and print "false true" (*)

 The code will compile and print "true false"

 The code does not compile.

 The code will compile and print "false false"

Which three are valid declarations for a float value? (Choose Three)
   (Choose all correct answers)

 float f = 0x345; (*)

 float f = -1; (*)

 float f = 2.0f; (*)

 float f = 1.0;

 float f = 3.0L;

No comments:

Post a Comment

Final Exam Java Programming 2019 Learner - English

Final Exam