Discover java programming interviews exposed, include the articles, news, trends, analysis and practical advice about java programming interviews exposed on alibabacloud.com
4.1. Introduction to object-oriented programmingobject-oriented Programming, or OOP for short, was the dominant programming paradigm these days, having replaced T He "structured," procedural programming techniques that were developed in the 1970s. Since Java is object-oriented, and you had to be familiar with the OOP t
generation in the challenge algorithmB. Random number generation of verification codesC. Randomly selected routesD. Web App session identifiers8. A code that uses Zipinputstream to decompress the compressed file, fill in the appropriate keywords at [1] isPublic Randomaccessfile OpenFile (Java.io.File f) {[1] java.io.File copy = new Java.io.File (F.getpath ());Askuserpermission (Copy.getpath ());// ...Return (Randomaccessfile) accesscontroller.doprivileged (new Privilegedaction () {Public Object
principleSocket (socket)To learn the transfer protocol, you must first understand the socketTo network transmission there must be two endpoints, the two endpoints want to communicate, you must connect, the endpoint can be understood as the socketSockets are a mechanism for network service deliveryBoth ends of the communication must have a socket to communicateNetwork communication is actually the communication between socketsData is transmitted via IO between two socketsSo network
Java programming implements code sharing for solving eight silver coins and eight silver coins
1. Introduction
I have encountered such a question in an algorithm competition at the university. Now I want to share it with you: There are currently eight silver coins abcdefgh, one of which is known to be counterfeit coins, its weight is different from the real currency, but I do not know whether it is lighter
construct methods in this class that have and allow only the first line of code in the method body to appearThe variable defined in the normal (instance) method must be appended with the initial value (not giving you no error when you do not call it)If you don't give an error when you callstatic modifierYou can modify----static variable (class variable) class name on a variable. Static variable nameCan be decorated on a normal method--static method (class method) class name. static method NameC
2. Thread security 2.1 What is thread-safeWhen multiple threads are accessed, the program can be " correct ", which is thread-safe.An object that has no status (a class that can be understood as having no fields) must be thread safe.2.2 atomicityIn a typical case, the i++ in a multithreaded state is not secure. Because i++ is actually implemented in a number of steps, the execution of multiple threads can be confusing to each other.Race condition (Race Conditions)Threads and threads need to depe
according to the part, and each part is assigned to the designated person to do it;The end is to assemble all the finished parts, which is a bicycle;In this way, the bicycle, maintainability and extensibility are stronger than the process-oriented thinking;The only drawback is that the upfront investment time is a little longer;Java object-oriented three major features;Encapsulation: We can class, the class has methods, properties, can encapsulate a
parameters is those that appear in the method hea Der.A. TrueB. FalseSummary: The formal parameter is inside the method head, the argument is the parameter inside the method.9.Assume The class Bird has a static methodfly (). If B is a Bird, then to invoke fly, you could do Bird.fly ();.A. TrueB. FalseSummary: Static methods are all shared.10.The goal of testing is toA. Ensure the software has no errorsB. Find syntax errorsC. Find logical AND Run-time errorsD. Evaluate how well the software meet
Through this week's study, I learned the concept of Java object-oriented programming, object-oriented program is composed of objects, each object contains a specific function and implementation of the user exposed, there is a custom standard object, the main learning content is: Use predefined, user-defined, object construction , the use of methods, and reference
class, it is always inherited. All classes in Java come from the root class object. In the inheritance process, you need to declare that the new class is similar to the old class. This declaration is implemented by writing the keyword extends followed by the base class name, before the left curly brace of the class body. When you do this, all the fields and methods in the base class are automatically obtained.1), initialize the base class. Inheritanc
Network modelOSI (open System Interconnection) Open Systems Interconnect: Reference ModelTcp / ipNetwork communication elementsIP AddressPort numberTransport protocolNetwork Reference ModelBasic concepts of the seven-layer OSI model to understandInternetwork protocol: Includes IP protocol, ICMP protocol, ARP protocol, RARP protocol. Transport Layer Protocol: TCP protocol, UDP protocol. Application layer protocol: FTP, Telnet, SMTP, HTTP, RIP, NFS, DNS.To really achieve network communication, fir
("Good"); } }; } classEventSource { Public voidRegisterlistener (EventListener listener) {}} Public StaticSafelistener newinstance (EventSource source) {Safelistener safe=NewSafelistener (); Source.registerlistener (Safe.listener); returnsafe; }}Conclusion One: When a registered event listener hears an event occurring, a new thread is enabled to perform the related thing. (This we manually started a thread in the code simulation, when no listener registration, the boot threa
request and sent together to the browser (but a large number of requests are wasted).Workaround 2, long pollingThe server responds to the browser only when it sends data (if the browser has new data to send before the server responds, the browser must create a new parallel request, or terminate the current request; TCP and HTTP specify the connection timeout; HTTP has a forced connection limit).Workaround 3, chunked encodingThe server can respond to requests without declaring the content length
Java concurrent programming test (3)Generate more alternate operations
Because errors in concurrent code are generally low-probability events, you need to execute these errors multiple times during testing. However, some methods can increase the probability of discovering these errors, as mentioned above, in a multi-processor system, if the number of processors is less than the number of active threads, the
,account to,int amount) {from.setbalance (from.getbalance ()-amount ); if (Random.nextint (>threshold) {Thread.yield ();} To.setbalance (To.getbalance () +amount);}Performance TestingPerformance testing should conform to the current application scenario, ideally reflecting the actual usage of the object being tested in the application.The second goal is to adjust the various limits based on experience values, such as the number of threads, cache capacity, and so on, which are dependent on the pl
See the old Luo Luo Shenyang's interview, can't help but admire, very young, I thought and yonghao a level of age, is also seen is not the beginning of high school programming one of the Daniel, after the interview, found that Lao Luo is also step by step people. Don't say what is difficult to do, do not, you have not to try, nor to insist.If you can ' t fly so run,if you can ' t run then walk, if you can ' t walk then crawl,butWhatever you do,you has
make the method final only if you want to explicitly block the method from being overwritten.
Declaring a method cannot be overridden by a quilt class.The private method is implicitly specified as final, and if the method defined in the subclass is the same as a private method signature in the base class, the method of the subclass is overloaded instead of overriding the base class method.The final method is similar to the private method, except that private can only be accessed within the
In this paper, the difference between jdk1.4,jdk1.5 and jdk1.6 in Java programming is analyzed with examples. Share to everyone for your reference, specific as follows:
Simply put:1.4 and 1.5 The biggest difference is two, one is 1.5 generics, another 1.5 can automatically encapsulate the eight basic data types of the package data type , that is, Integer a = 4 This 1.4 is not possible. the difference betwe
implementation, and in real programming, because the various specific policy implementation classes inevitably exist between some of the same logic, in order to avoid duplicate code, we often use abstract classes to serve as the role of strategy, in the package of common code, so, in many application scenarios, In the policy mode, you will generally see the shadow of the template method pattern.structure of the policy patternEncapsulation class: Also
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.