Basic Java Knowledge

Source: Internet
Author: User

Default Single selection

1 in Java, the following description of the constructor is correct ().

A) class must display the definition constructor

B) The return type of the constructor is void

C) Constructors and classes have the same name and cannot take any arguments

D) A class can define multiple constructors

2. The following object-oriented features are (). (Two items found)

A) overloading

B) rewrite

C) package

D) Inheritance

3. polymorphic manifestations are ()

A) rewrite

B) Abstract

C) Inheritance

D) Encapsulation

4. The following description of overloads is incorrect ()

A) method overloads can only occur inside a class

B) Construction methods cannot be overloaded

C) overloading requires method name is the same, parameter list is different

D) The return value type of the method is not a condition for differentiating method overloads

5 The following program runs as a result ()

  class person {

Public Person () {

System. out. println ("This is a person");

}

}

Public class Teacher extends person {

Private String name = "Tom";

Public Teacher () {

System. out. println ("This is a person");

Super ();

}

Public Static void Main (string[] args) {

Teacher Teacher = new Teacher ();

System. out. println (this. name);

}

}

A) This was a person

This is a teacher

Tom

B) This is a teacher

This was a person

Tom

C) Run Error

D) There are two errors in compiling

6 when using the super and the This keyword, the following description is correct ()

A) using super () in the subclass construction method to display the constructor method that calls the parent class, super () must be written in the first row of the subclass construction method, otherwise the compilation does not pass

B) Super () and this () do not have to be placed within the first line of the constructor method

C) This () and super () can appear in one constructor at a time

D) This () and super () can be used in a static environment, including static methods and static statement blocks

7 The following description of the inheritance is wrong ()

A) Inheritance in Java allows a subclass to inherit multiple parent classes

B) The parent class is more generic and the subclass more specific

C) Inheritance in Java has a transitive nature

D) Recursive invocation of a constructor method in a parent class when instantiating a subclass

8 The following interface describes the error of having ()

A) The interface does not provide a construction method

B) methods in the interface by default using public, abstract decoration

C) properties in the interface default to public, static, final decoration

D) interface does not allow multiple inheritance

9 The following description error has ()

A) Abstract can modify classes, interfaces, methods

B) Abstract modified classes are primarily used for inherited

C) abstract can modify variables

D) An abstract modified class whose subclasses can also be abstract-modified

10 The following about the final keyword saying wrong is () (two items)

A) final is a modifier in Java that can be decorated with classes, interfaces, abstract classes, methods, and properties

B) The final modified class must not be inherited

C) The final modified method cannot be overloaded

D) Final modified variables are not allowed to be re-assigned

11 access modifier scoped from large to small yes ()

A) Private-default-protected-public

B) public-default-protected-private

C) Private-protected-default-public

D) public-protected-default-private

12. The following code runs the result is ()

public class TestException {

public int Add (int a, int b) {

try {

return a + B;

} catch (Exception e) {

SYSTEM.OUT.PRINTLN ("catch statement block");

} finally {

SYSTEM.OUT.PRINTLN ("finally statement block");

}

return 0;

}

public static void Main (string[] args) {

TestException demo = new TestException ();

System.out.println ("and is:" + demo.add (9, 34));

}

}

A) Compile exception

B) finally statement block and yes: 43

C) and yes: the finally statement block

D) Catch statement block and yes: 43

return 0;

}

13 according to the following code,

String s = null;

The nullpointerexception exception will be thrown with (). [Two items]

A) if ((S!=null) & (S.length () >0))

B) if ((S!=null) & & (S.length () >0))

C) if ((S==null) | (S.length () ==0))

D) if ((s==null) | | | (S.length () ==0))

14 in Java, for a description of the HashMap class, the following description is incorrect ().

A) HashMap save data using key/worthwhile form

B) HashMap can guarantee the order of the elements

C) HashMap allows NULL to be used as a key

D) HashMap allows NULL to be used as a value

The collection classes in Java include ArrayList, LinkedList, HashMap, and so on, and the following about the collection class describes the error () (select an item)

A) ArrayList and LinkedList both implement the list interface

B) ArrayList access speed is faster than LinkedList

C) when adding and removing elements, the ArrayList performance is better

D) HashMap implements the map interface, which allows any type of key and value object, and allows NULL to be used as a key or value

16 in Java, the () class provides the location of the local file system and basic operations on a file or directory and its attributes.

A) FileInputStream

B) FileReader

C) FileWriter

D) File

Simple question:

If you have two classes A, B (note not interface), you want to use the functionality of these two classes at the same time, then how would you write this class C?

Talk about your understanding of abstract classes and interfaces

Basic Java Knowledge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.