Interview Questions for some famous big companies-java

Source: Internet
Author: User
Tags websphere application server
Source: one-way read http://www.yiludu.cn
I. Basic Java knowledge
1. What are the differences between the basic data types in Java and whether the String type is the basic data type.
Integer literals, Floating-point literals, character literals, Boolean literal, String iteral.
String is not a basic data type
2. String operations:
Write a method to reverse the string, for example, input abc and output CBA.
Public static String reverse (String s ){
Int length = s. length ();
StringBuffer result = new StringBuffer (length );
For (int I = length-1; I> = 0; I --)
Result. append (s. charAt (I ));
Return result. toString ();
}
Write a method to replace the string, for example, input bbbwlirbbb and output bbbhhtccc.
3. Conversion Between Data Types
How to convert numeric characters to numbers (Integer, Double)
How to convert a number to a character
How to remove the first two decimal places and rounding them out.
4. Date and Time
How to Get year, month, day, hour, minute, second
Date dat = new Date ();
Dat. getYear (); dat. getMonth (); dat. getDay (); dat. getHours ();...
How to get the number of milliseconds from January 1, 1970 to the present
Long now = dat. getTime ();
How to obtain a date is the last day of the month
How to format a date
DateFormate df = DateFormate. getInstance ();
Df. Format (dat );
5. arrays and collections
6. file and directory (I/O) Operations
How to list all files in a directory
How to list all subdirectories in a directory
Determine whether a file or directory exists
How to read and write files
7. Implementation of Java polymorphism (inheritance, overloading, and overwriting)
8. encoding conversion, how to convert the GB2312 encoded string to the ISO-8859-1 encoded string.
9. Steps for accessing the database in Java, the difference between Statement and PreparedStatement.
10. Identify possible errors in the following code and explain the cause:
Ii. JSP & Servlet Technology
1. Describe the differences between JSP and Servlet, their commonalities, and their respective application scopes.
2. What processing should I do when processing HTML tags in Web development and filter those characters (<> &"")
3. How to read client requests, access CGI variables, and determine the actual path of a JSP file in Jsp.
4. describe the functions of cookies and sessions, the differences and their respective application scopes, and the working principle of sessions.
5. List the methods in which Jsp contains external files. What is the difference between the two.
6. Describe the role and application scope of errorPage in Jsp.
7. describes how to use JavaBeans in Jsp.
8. A brief introduction to the tag library of JSP
9. How to Implement request forwarding in Jsp and Servlet.
Iii. J2EE knowledge
1. Introduce the differences between J2EE, J2SE, and J2SE.
2. Is J2EE a technology or a platform that provides those technologies.
3. What is Application Server? What functions and advantages does it have.
4. Briefly introduce the advantages and Principles of the connection pool.
5. Functions of Web. xml
4. Others
1. Web security considerations (Form Verification, browser Basic verification, application security, SSL, code considerations)
2. Briefly introduce the MVC you know.
3. Briefly introduce the XML.
4. Documents and coding specifications
5. Paging and efficiency considerations in Java.
6. A brief introduction to structs.

Find out the following program errors.
Class Test {
Private String par1;
Private String par2;
Test (){
}

Public static void main (String [] arg ){
Int;
If (){
System. out. println ("par1 =" + par1 );
} Else {
System. out. println ("par2 =" + par2 );
}
}
}

========================================

Public class Test
{
Public static int a = 5;
Public static void main (String [] args)
{
Test test = new Test ();
Test = null;
System. out. println (test. );
}
}
The answer is 5. a is a static variable. It does not depend on the object, even if it is null.

J2EE beginners need to understand

I. background of J2EE
1. Requirements for enterprise-level application frameworks

In many enterprise-level applications, such as database connection, mail service, and transaction processing, these modules are common enterprise requirement modules. If these modules are completed by developers every time they are re-developed, this will cause issues such as long development cycle and code availability. As a result, many large companies have developed their own general module services. These service software series are collectively referred to as middleware.

2. For general purpose, a standard must be put forward. Otherwise, the general purpose cannot be achieved.

Based on the above requirements, many companies have developed their own middleware, but their communication with users is different, as a result, users cannot assemble different middleware from different companies to serve themselves. This leads to bottlenecks. Therefore, the standard concept is proposed. In fact, J2EE is a series of standards based on JAVA technology.

Note: The Explanation of the middleware lies between the operating system and higher-level applications. The function is to isolate the application running environment from the operating system, so that application developers do not have to worry about more system problems, but directly focus on the application's ability to solve problems. The container concept we will talk about later is a kind of middleware.

2. Glossary
Container: acts as the role of Middleware

WEB Container: provides an environment for the application components (JSP and SERVLET) in the container, so that JSP and SERVLET can directly interact with the environment variable interfaces in the container, so that you do not have to pay attention to other system problems. It is mainly implemented by WEB servers. For example, TOMCAT, WEBLOGIC, and WEBSPHERE. The interface provided by the container strictly complies with the web application standard in J2EE specifications. We call the WEB server that complies with the above standards the WEB Container in J2EE.

EJB container: Enterprise java bean container. More industry-specific characteristics. It provides various management functions for the component EJB running in it. As long as the EJB meeting the J2EE specification is put into the container, it will be managed efficiently by the container immediately. In addition, system-level services can be obtained through ready-made interfaces. For example, mail service and transaction management.

WEB containers and EJB containers are basically the same in principle. The more difference is the isolated external environment. WEB containers mostly deal with HTTP-based requests. The EJB container is not. It deals more with databases and other services. However, they all implement interactions with the outside world to reduce the burden on applications. For example, SERVLET does not need to care about HTTP details, but directly reference the environment variable session, request, and response. EJB does not need to care about database connection speed and various transaction control, which is directly completed by containers.

RMI/IIOP: Remote method call/internet object request mediation protocol, which is mainly used to call services remotely. For example, if a program runs on a remote computer that provides the Stock Analysis Service, we can directly call it on a local computer. Of course, this requires certain specifications to communicate between heterogeneous systems. RMI is unique to JAVA.

JNDI: JAVA Naming directory service. The main function is to provide a directory system that allows applications from other places to leave their own indexes on it to quickly find and locate distributed applications.

JMS: JAVA Message Service. Communication between applications. Including point-to-point and broadcast.

JAVAMAIL: JAVA mail service. Provides mail storage and transmission functions. He is the core of the mail function in JAVA programming. EXCHANGE development kit in equivalent MS.

JTA: JAVA transaction service. Provides various distributed transaction services. An application only needs to call the interfaces it provides.

JAF: JAVA security authentication framework. Provides some security control frameworks. Developers can implement their own personalized security control policies through various deployment and customization.

EAI: Enterprise Application Integration. Is a concept that involves many technologies. J2EE is a good integration implementation.

Iii. Advantages of J2EE
1. Outstanding platform independence based on JAVA Technology

2. Open Standards many large companies have implemented application servers that support this specification. Such as BEA, IBM, and ORACLE.

3. Provide professional general software services.

4. provides an excellent enterprise-level application framework, laying the foundation for rapid and high-quality development

Iv. Status quo
J2EE is an enterprise-level application specification developed by SUN. The current maximum version is 1.4. The APPLICATION servers supporting J2EE include ibm websphere application server, bea weblogic server, JBOSS, oracle application server, and sun one application server.

Learn 30 Basic concepts of Java

Java Overview:
Currently, Java is mainly used in middleware development (middleware)-to process communication technologies between clients and servers. Early practices have proved that Java is not suitable for pc application development, its development has gradually become the development of handheld devices, internet information stations, and on-board computers. different from other languages, Java provides platform independence during program running, which means identical code can be used on windows, solaris, and linux operating systems. java syntax is similar to C ++ syntax. C ++/C programmers can easily master it, and Java is completely object-oriented, A good GC (Garbage Collector) mechanism is proposed to prevent memory overflow.

The Java White Paper presents 11 key features of the Java language.

(1) Easy: Java syntax is relatively simple than C ++, and Java enables software to run on very small machines, the basic explanation is that the size supported by the class library is about 40 kb. To increase the size of the basic standard library and thread-supported memory, a kb increase is required.

(2) distributed: Java has a very powerful library of routines for TCP/IP protocol families. Java applications can access remote objects through the network through URLs. Due to the emergence of servlet mechanisms, java programming is very efficient. Many large web servers now support servlet.

(3) OO: Object-oriented Design is a programming technology that focuses on the interfaces of objects and objects. its object-oriented model is different from that of C ++ in terms of Multi-inheritance processing and the original class model of Java.

(4) Robustness: Java adopts a safe pointer model to reduce the possibility of overwrite memory and data crash.

(5) Security: Java is used to design networks and distributed systems, which brings about new security problems. Java can be used to build anti-virus and anti-attack systems. it turns out that Java is better at anti-virus.

(6) Neutral architecture: Java compiles and generates an architecture. The neutral target file format can be executed on many processors. The Javabytecode generated by the compiler implements this feature, this bytecode can be interpreted and executed on any machine.

(7) Portability: Java has strict rules on the size and algorithms of basic data structure types, so the portability is good.

(8) multithreading: The process of processing multithreading in Java is very simple. in Java, the implementation of Multithreading is handed over to the underlying operating system or thread program. Therefore, multithreading is one of the popular reasons for Java as a server development language.

(9) Applet and servlet: a program that can be executed on a webpage is called Applet. Many Java browsers are required, while applet supports dynamic web pages, which cannot be implemented in many other languages.

Basic concepts:

1. the only link in OOP is what the interface of the object is. Just like a computer vendor, no matter what the internal structure of the power supply is, it only depends on whether it can provide electricity to you, that is, as long as you know can or not rather than how and why. all programs are composed of certain attributes and behavior objects. Different objects are accessed through function calls, And all communication between objects is done through method calls, by encapsulating object data, the reuse rate is greatly improved.

2. The most important idea in OOP is the class. The class is the blueprint of the template, and an object is constructed from the class, that is, an instance of the class is created)

3. encapsulation: it refers to the implementation process of combining data and behavior in a package) and hiding data from object users. The data in an object is called its instance field)

4. Extend a class to get a new class called inheritance, and all the classes are extended by the Object root Super class. The root Super class will be introduced below.

5. Three main features of the object

Behavior --- describe what this object can do.

State --- reflection of an object when the object applies a method.

Identity --- the identifier for distinguishing from other similar behavior objects.

Each object has a unique indentity, which affects each other.

6. Relationships between classes:

Use-a: dependency

Has-a: Aggregation relationship

Is-a: inheritance relationship -- for example, Class A inherits class B. At this time, Class A not only has class B's methods, but also its own methods. (personality exists in commonalities)

7. constructor for constructing objects: constructor is a special method for constructing and initializing objects.

For example, the Data constructor is called Data.

New Data () --- construct a new object and initialize the current time.

Data happyday = new

Data () --- assign an object to a variable happyday so that the object can be used multiple times. The variables and object variables to be declared here are different. the value returned by new is a reference.

Constructor features: constructor can have 0, one or more parameters

The constructor and class have the same name.

A class can have multiple Constructors

The constructor does not return values.

The constructor is always used with the new operator.

8. Overload: when multiple methods have the same name and contain different parameters, the overload occurs. The compiler must select the method to call.

9. package Java allows one or more classes to be collected together into a group called a package to facilitate task organization. The standard Java library is divided into many packages. java. lang java. util java, net, etc. The packages are all hierarchical java packages within the java and javax package layers.

10. inheritance: allows you to create new classes based on existing classes. When you inherit an existing class, you reuse the methods and fields of this class, you can also add new methods and fields in the new class.

11. extension class: the extension class fully embodies the inheritance relationship of is-a. Form: class (subclass) extends (base class ).

12. Polymorphism: in java, object variables are polymorphism. java does not support multi-inheritance.

13. dynamic binding: Call the object method mechanism.

(1) The Compiler checks the object declaration type and method name.

(2) The Compiler checks the parameter types of method calls.

(3) static binding: if the method type is priavte static final, the compiler will know exactly which method to call.

(4) When a program is running and dynamic binding is used to call a method, the virtual machine must call the method version that matches the actual type of the object pointed to by x.

(5) dynamic binding: it is an important feature that enables programs to be scalable without the need to re-compile existing code.

14. final class: to prevent others from generating new classes from your class, this class cannot be expanded.

15. Dynamic calling takes longer than static calling,

16. abstract class: specifies that the class of one or more abstract methods must be defined as abstract: public abstract string getDescripition

17. Every class in Java is extended from the Object class.

18. the equal and toString methods in the object class. equal is used to test whether an object is equal to another object. toString returns a string representing the object. Almost every class will reload the method to return the correct representation of the current state. (The toString method is a very important method)

19. general programming: all values of any class type can be replaced by variables of the object class.

20. array list: ArrayList dynamic array list. It is a class library defined in the java. uitl package and can automatically adjust the array size.

21. the getclass method in the class object class returns an instance of the ckass type. When the program starts, the class contained in the main method will be loaded, and the VM will load all the classes it needs, each loaded class must load the class it needs.

22. the class provides powerful functional reflection for programming programs that can dynamically manipulate java code. This function is especially useful for JavaBeans. Using Reflection Java can support tools that VB programmers are used. programs capable of analyzing class capabilities are called reflectors. Java provides this function package called Java. lang. the reflect reflection mechanism is very powerful.

1. Ability to analyze classes at runtime.

2. Check the object of the class at runtime.

3. Implement Generic Array code.

4. Provides method objects.

This mechanism mainly targets tool providers rather than applications and programs.

The most important part of the reflection mechanism is to allow you to check the structure of the class. The APIs used include:

Java. lang. reflect. Field returned Field.

Java. reflect. Method return Method.

Java. lang. reflect. Constructor return parameters.

Method pointer: java does not have a method pointer. If you pass the method address to another method, you can call it later, and the interface is a better solution.

23. Interface describes what a class should do without specifying how to do it. A class can implement one or more interfaces.

24. The interface is not a class, but a set of specifications for the class that meets the interface requirements. If an interface is implemented, two steps are required:

1. Declare the specified interface to be implemented by the class.

2. Define all methods in the interface.

To declare a class to implement an interface, you must use the implements keyword class actionB implements Comparable. Its actionb must provide the CompareTo method. The interface is not a class and cannot be instantiated with new.

25. A class has only one superclass, but a class can implement multiple interfaces. Cloneable, an important interface in Java

26. Interface and callback. A common programming mode is the callback mode. In this mode, you can specify the method of the callback object when a specific time occurs. Example: ActionListener interface listening.

Similar APIs include java. swing. JOptionPane.

Java. swing. Timer

Java. awt. Tookit

27. object clone: the clone method is a protection method for objects, which means that your code cannot simply call it.

28. Internal class: the definition of an internal class is defined in another internal class

The reason is: 1. An internal class object can access the implementation of the object that creates it, including private data

2. For other classes in the same package, internal classes can be hidden.

3. Anonymous internal classes can easily define callbacks.

4. Use internal classes to easily write event drivers.

29. proxy: 1. Specify the interface to require all code 2. All methods defined by the object class (toString equals)

30. data Type: Java is a language that emphasizes the type. Each variable must first declare that it is of the type. java has a total of eight basic types. four types are Integer type, two types are floating point type, and one is character type. They are used for Unicode encoding characters and Boolean characters.

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.