Common face questions for Java programmers

Source: Internet
Author: User

First, basic simple answer

1. What is the difference between super () and this ()?

Super () calls the non-parametric constructor method of the parent class, and the This () call itself class without a parameter constructor method.

2. Scope public,protected,private, and what is the difference when not writing?

Public publicly decorated variables that can be accessed in other classes

Protected protect the same bun class visit

Private privately only This class accesses

Do not write package access

3. How do I jump out of the current multiple nested loops in Java?

Break;continue jumps out of the current loop;

4. Can a ". Java" source file contain more than one class (not an inner class)? What are the restrictions?

There can only be a public class, this file name must be named with the public class name

5. What are the options for sorting?

Insert sort, swap sort, merge sort, select Sort.

6. What is the difference between overload and override?

Overloading: Compile-time polymorphism, the same class two methods with the same name, the parameter list is different (type, number), the return value can be different or different

Rewrite: Run-time polymorphic, in two classes the subclass subclass of the parent class overrides the same method as the parent class, and the subclass's access permissions cannot be smaller than the parent class.

7. What are the characteristics of the final category?

Can no longer be inherited

Method cannot be overridden

Variable static

8. What is the difference between & and &&?

Bitwise operations, logical operations

Logical operation Short-circuit

9. What is a GC? Why do you have a GC?

Garbage collector

No method call garbage collector is displayed, recommended garbage collector cleanup, object not referenced, cleaned with garbage collector

10.math.round (11.5) equals how much? How much does Math.Round (-11.5) equal?

12,-11

Second, junior secondary level simple answer

11. What is the reflection mechanism of a class?

Get the interface through the class name of the class, instantiate this class, both Hibernate and spring are useful to the reflection mechanism of the class, the proxy pattern uses the reflection mechanism

12. What are the three processes for getting class?

GetClass ();. Class;class.fornam ();

13. Say some of the commonly used classes, packages, interfaces, please give 5?

Class: Stream FileInputStream

Package: IO util net javax AWT

Interface: InputStream outputstream list Map Read Write

14. What is the difference between a static variable and an instance variable?

Static variables are instantiated by class name, object access, loading time instantiation, instance variable accessed by object, and new object.

Local variables are used in methods and method blocks, and instance variables can be used throughout the object

What is the difference between 15.String and StringBuffer?

String Creation Object content is immutable

The content created by StringBuffer is mutable

16. What is the role of the collection?

Save objects can be of the same type or can be of different types, providing additional deletions to modify the query, saved in memory

List,set, does the map inherit from the collection interface?

Listset inheritance

Is 18.String the most basic type of data?

Not a basic data type byte char int long double Floatboolean short

Can a Chinese character be stored in a 19.char variable?

Save Unicode to save Chinese characters

20. Start a thread with run () or start ()?

Start ();

Run () put the executed code inside

Third, intermediate simple answer

What is the difference between 21.sleep () and wait ()?

Sleep to the time to wake up

Waiting to wake up

22.JDBC How do transactions work?

Set JDBC Auto-commit false to open transactions after multiple transactions commit exception rollback rollback

How do I access the database in 23.Java?

Register driver Get Connectionmanage

Obtained by Connectionmanage (requires connection string user name password) Connection

Connection Get Statement Execution statement

Execution closes the connection at the end of the loop (inverted off)

What is the role of 24.class.forname?

An instance object of a class is created from the class name, which is typically registered by JDBC.

What is the difference between Stringand StringBuffer?

What is the difference between 26.forward and redirect?

Request Forwarding

REDIRECT URLs can change different requests

27. How do I implement a custom servlet?

Extendshttpservlet implementation of Doget Dopost method

Registering a servlet

What is the life cycle of 28.Servlet?

Instance init () created by class loader

Dogetdopost

Destroy destruction

29.JSP is a servlet correct?

Yes, JSP translates into servlet class compilation loading

What are the built-in objects for 30.JSP?

Requestreponse PageContext Application Session exception out

Iv. Advanced Simple answer questions

What is the difference between the two implementations of 31.include?

Common face questions for Java programmers

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.