zoukankan      html  css  js  c++  java
  • SSD3 MultipleChoice Quiz 3


    1. The return type for a method that returns nothing to its caller is    

    (a) false

    (b) void

    (c) null

    (d) not specified in the method definition

    Correct answer is   (b)

     

    2.    Which of the following statements about class variables in Java is not true?

    (a) Non-static methods in a class can access the class variable defined in the same class.

    (b) Class variables do not need the reference to the object of the instantiated class to access them.

    (c) Class variables require the modifier static in the declarations.

    (d) All objects have their own copy of the class variable defined in the instantiated class.

    Correct answer is   (d)

             3.   

             What is used to indicate that a method does not return a value? (a) the name of the class to which it belongs

    (b) the keyword static

    (c) the keyword void

    (d) the omission of the return type

     

             Correct answer is   (c)

             4.

    Consider the following Java program segment.

        import java.io.*;

                          

        public class Test {

                          

            public Test( ) {

                          

                System.out.println("default");

            }

                          

            public Test( int i ) {

                          

                System.out.println("non-default");

            }

                          

            public static void main(String[] args) {

                          

                Test t = new Test(2);

            }

        }

     

    Which of the following will be output during execution of the program segment?

    (a) The line of text "non-default"

    (b) The line of text "default"

    (c) The line of text "default" followed by the line of text "non-default"

    (d) The line of text "non-default" followed by the line of text "default"

     

             Correct answer is   (a)

             5.

    Which of the following statements about constructors in Java is true?

    (a) A class can define more than one constructor.

    (b) A constructor must be defined as static.

    (c) A constructor must be defined as public.

    (d) A class must define at least one constructor.

     

             Correct answer is   (a)

             6.   

             Which is the Java keyword used to denote a class method?

    (a) class

    (b) final

    (c) private

    (d) static

     

             Correct answer is   (d)

             7.   

    If the method int sum(int a, int b) is defined in a Java class C, which of the following methods cannot coexist as a different method in class C?

    (a) float sum(int x, float y)

    (b) int sum(float a, int b)

    (c) int sum(int x, int y)

    (d) int sum(int x, float y)

     

             Correct answer is   (c)

             8.   

             Which is a Java access modifier used to designate that a particular data field will not be inherited by a subclass?

    (a) private

    (b) final

    (c) protected

    (d) default

     

             Correct answer is   (a)

             9.   

             From within a child class, its parent class is referred to via the keyword

    (a) parent

    (b) base

    (c) this

    (d) super

     

             Correct answer is   (d)

             10.

             When a subclass defines an instance method with the same return type and signature as a method in its parent, the parent's method is said to be      

     

    (a) private

    (b) overridden

    (c) overloaded

    (d) hidden

     

             Correct answer is   (b)

             2.   

             If a class contains a constructor, that constructor will be invoked       

     

    (a) each time an object of that class is instantiated

    (b) once at the beginning of any program that uses that class

    (c) each time an object of that class goes out of scope

    (d) once the first time an object of that class is instantiated

     

             Correct answer is   (a)

             3.   

             The term class variable is a synonym for       

     

    (a) a read-only variable

    (b) a private data field

    (c) an instance variable

    (d) a static data field

     

             Correct answer is   (d)

             5.

    Which of the following categorizations can be applied to both the data fields and the methods in a Java class?

    (a) native and non-native

    (b) abstract and non-abstract

    (c) static and non-static

    (d) default and non-default

     

             Correct answer is   (c)

             9.   

    Consider the following Java class definitions.

     

        public class Object1 {

         

            protected String d(){

                return "Hi";

            }

        }

     

        public class Object2 extends Object1 {

               

            protected String d(){

                          

                return super.d();

            }

        }

     

    Which of the following statements is (are) true regarding the definitions?

       1. Class Object2 inherits from class Object1.

       2. Class Object2 overrides method d.

       3. Method d returns equivalent results when executed from either class.

    (a) I and III only

    (b) I, II, and III

    (c) I and II only

    (d) III only

     

             Correct answer is   (b)

     

  • 相关阅读:
    时间等待太重要!!!
    (引用 )自动化测试报告HTMLtestrunner
    (转载)selenium-webdriver(python)
    lr_convert_string_encoding()转码函数
    分步骤学习自动化测试
    (引用)web安全测试
    Monkey测试
    (学习网址)Python 自动化测试
    (引用) unittest测试驱动之执行测试(三)
    log4net日志组件
  • 原文地址:https://www.cnblogs.com/vivizhyy/p/3394917.html
Copyright © 2011-2022 走看看