java practice exam

Alibabacloud.com offers a wide variety of articles about java practice exam, easily find your java practice exam information here online.

Java Network Practice One

PackageNetwork;Importjava.io.IOException;ImportJava.io.PrintWriter;ImportJava.io.Writer;ImportJava.net.Socket;ImportJava.util.Scanner; Public classClisockettest { Public voidTest () {Try { while(true) {Socket Socket=NewSocket ("192.168.1.2", 8888); Writer W=NewPrintWriter (Socket.getoutputstream ()); Scanner Scaner=NewScanner (system.in); W.write (Scaner.nextline ()); System.out.println ("entered the book."); W.flush (); W.close ()

Java Practice---11

!!!"); }} Public classLL { Public Static voidMain (string[] args) {single S=NULL; S=single.getinstance (); S.print (); }}Package Cn.lyh;classperson{PrivateString name; Private Static intcount; PublicPerson () {count++; This. Name = "NONAME-" +count; } PublicPerson (String name) { This. Name =name; } PublicString GetInfo () {return"Name:" + This. Name; }} Public classly{ Public Static voidMain (string[] args) {System.out.println (NewPerson (). GetInfo ()); System.out.println (NewPers

Java Practice Source code on the keyboard randomly input n numbers in the list to output its results from large to small!

/** Randomly enter n numbers on the keyboard to the list to output their results from large to small*/public class Test01 {public static void Main (string[] args) {List list1=new ArrayList ();Integer cnt=0;for (int i=0;i{List1.add (Cnt.parseint (Args[i]))//string converted to integer and deposited in List1}System.out.println (List1);Collections.sort (List1);//the sort () natural sort method that invokes the tool class;Collections.reverse (List1);//tool class inversion function reverse ();SYSTEM.

Java Theory and Practice: using Volatile variables correctly

Volatile variables in the Java language can be thought of as "light", and synchronized synchronized volatile variables require less coding and run-time overhead than blocks, but only part of the functionality that they can implement synchronized . This article describes several patterns for using volatile variables effectively, and highlights several scenarios where volatile variables are not appropriate.The lock provides two main features: Mutual exc

Java Threading and concurrency programming Practice----synchronizer (countdown latch)

The synchronized keyword provided by Java provides thread-synchronous access to critical sections. Because it is difficult to synchronized basedThe synchronization code is written correctly, and the Concurrency tool class provides an advanced Synchronizer. Countdown latch (countdown latch), Sync screen(cyclic barrier), switch (exchanger), Semaphore (semaphore), and Phaser Synchronizer. The following mainIntroduce the countdown latch.The countdown latc

The Java Practice Certificate number composition rule is that the first 4 are to represent provinces and regions to prepare a procedure to determine whether a person is a Wuhan person and its gender through the ID number.

17th digit represents the gender (odd for men). Write a procedure that determines whether a person is a Wuhan person and its gender through the ID number. */String str= "420103199801010312"; if(str.substring (0, 4). Equals ("4201") {System.out.println ("This man is from Wuhan, Hubei province. "); }Else{System.out.println ("This man is not from Wuhan, Hubei. "); } intSex=17; if(Str.charat (sex-1)%2==1) {System.out.println ("This man is male. "); }Else{System.out.println ("

Java Practice---14

=date;Wuyi } the PublicY (String name,string class,string date) { - This. Name =name; Wu This. Class =Class; - This. Date =date; About } $ PublicY () { - Super(); - } - A @Override + PublicString toString () { the return"Student [name=" + name + "]"; - } $ Public AbstractString speak (); the the } the Importjava.sql.Date; the@SuppressWarnings ("Unused") - Public classHextendsy{ in PrivateString matter; the PublicH (String name,string class,string date,stri

Java-preliminary Understanding-Common Object API (Collection framework-linkedlist Collection-Practice stack and queue)

-defined tool class, the previous example can be used in a different way.The late 1.6 release also provides a number of new methods in the Linklist linked list structure. As shown in.The functions of these methods and the existing methods are the same, but there are some differences, the upgrade is for a reason.The difference needs to know which method is clearly used when developing.GetFirst method has a feature, if there is nothing in the list, call the method, there is no thing. It throws an

JAVA Connection MongoDB Practice (1) __java

Due to business needs, the company recently transferred part of the data to the MongoDB database. After deploying the MongoDB database with the corporate DBA, we started our Java Connection MongoDB practice Before you start, recommend two IDE tools to connect to your database 1.rockmongo-on-windows-v0.0.2 (only run successfully in Firefox browser) 2. Robomongo (in 32 machine XP system will not start) Mong

Ansible roles Practice-Installing Java

1, Tasks/main.yml ----Name:mkdir Necessary Directory File:path=/usr/java/state=directory mode=0755 -Name:unzip JDK unarchive:src={{Jdk_package_name}} dest=/usr/java/ -Name:set Envlineinfile:dest={{Env_file}} insertafter={{item.position}} line={{Item.value}} state=presentWith_items:-{position:eof,value: "\ n"}-{position:eof,value: "Export java_home=/usr/

Java: Practice Supermarket stores

Java: Practice Supermarket storesRelated to: large commodity, specific goods (in the case of books), store categoryGoods,book,Supermart,Product Class Goods:Public interface Goods {//Commodity class public String getName ();p ublic int getcount ();p ublic float GetPrice ();}Book:Note: The replication hashcode, and equals is to implement the Delete buttonPackage Abc;public class Book implements Goods {private

Java Theory and Practice: Security construction techniques

The Java language provides flexible, seemingly simple threading capabilities that make it easy to use multithreading in your applications. However, concurrent programming in Java applications is more complex than it seems: in Java programs, there are subtle (and perhaps not subtle) ways to create data contention (race) and concurrency problems. In this

Kotlin Learning and Practice (ix) Lambda and Java functional interfaces with receivers

lambda instead of anonymous class parameters in Koltin, the compiler translates the final lambda auto-compilation into a runnable instance passed to the methodVal javatest = Javacalltest () fun Testlambdacalljava () { javatest.postponecomputation (+) { println ( $) } //The following shows that creating an anonymous object can also achieve the effect Javatest.postponecomputation (object:runnable { override Fun Run () { println ("452") } )}* Here's

Planned Java Practice Project

To exercise your Java coding capabilities, plan to do three more complete projects, namely:1.OA System Wisdom Podcast Soup Sunshine Edition;2. The e-shop is also the teacher's name of the Preach Wisdom podcast forgotten;3.BBS Academy Horse Soldiers;This group of essays is to follow up on the progress of these three projects, to document the problems encountered during the practice, the solutions, and the ex

Code Practice--java-4-String __ajax

practice = 2.5f; System.out.println ("I spend every day" + Booktime + "hour reading;" + Practice + "hours on the Machine"); } String manipulation-Get string length public class Test {public static void Main (string[] args) { String s = "We are students"; System.out.println ("Length of string is:" + s.length ()); } String manipulation-Gets the index position of the specif

Java Theory and Practice: building a better HashMap

Concurrenthashmap is part of Doug Lea's Util.concurrent package, which offers a higher degree of concurrency than Hashtable or synchronizedmap. Also, for most successful get () operations, it tries to avoid a complete lock, and the result is a very good throughput for concurrent applications. This month, Briangoetz carefully analyzed the code of the Concurrenthashmap and explored how Doug Lea achieved such a remarkable result without losing thread safety. In the July issue of

Java Theory and Practice: Where has your decimal point gone?

Many programmers do not use fixed-point or floating-point numbers throughout their development careers, with the possible exception being used occasionally in timing tests or benchmarking programs. The Java language and class libraries support two types of ―ieee 754 floating-point (float and double, wrapper class (wrapper class) for float and double), and arbitrary-precision decimals (java.math.BigDecimal). In this month's

Java-net.sf.json's put, accumulate, element practice and questions

this and put??? Well, it would call accumulate??? System.out.println ("object:" + object.tostring ()); }}Console Print Results:jsonObject: {"one":"first"}jsonObject: {"one":"first","two":"second"}jsonObject: {"one":"first","two":"cover"}jsonObject: {"two":"cover"}jsonObj: {"Servers":[null,"Tomcat"],"Codes":["Java","JavaScript"]}object: {"price":"1000"}Questions: net.sf.json.element :Put a key/value pair in the JSONObject. If the va

The principle and practice of Java Concurrent Programming 13: The principle and use of the atomic class provided by JDK

(!compareandset (prev, next)); return prev; }Public final Boolean compareandset (int expect, int update) { Return Unsafe.compareandswapint (this, valueoffset, expect, update);}Among them, Compareandswap is the abbreviation of CAs. Returns True if Prev and next are not equal. Otherwise, returns false. Finally, it is done through unsafe.The code above indicates that if Compareandset returns True, the while condition is false, exiting the loop and returning the Prev value. If Comparea

Java theory and Practice: blocking memory leaks with weak references---reprint

named, which expungeStaleEntries() Map is called in most operations, which removes all invalid references in the reference queue and deletes the associated mappings. expungeStaleEntries()a possible implementation is shown in Listing 7. The type used to store the key-value mappings is Entry extended WeakReference , so when the expungeStaleEntries() next invalid weak reference is requested, it gets one Entry . It is more efficient to use a reference queue instead of a regular scan of the content,

Total Pages: 15 1 .... 11 12 13 14 15 Go to: Go

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.