java practice exam

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

Practice and considerations for Java knowledge methods

1.1 Practice of methods1.1.1 Method exercises to get a larger of two data1.1.2 Case Code IVpackage com.itheima_01;import java.util.Scanner;/* * 需求:键盘录入两个数据,返回两个数中的较大值 * * 两个明确: * 返回值类型:int * 参数列表:int a,int b */public class MethodTest {// 返回两个数中的较大值public static int getMax(int a, int b) {if (a > b) {return a;} else {return b;}}public static void main(String[] args) {//创建对象Scanner sc = new Scanner(System.in);//接收数据System.out.println("请输入第一个数据:");int x =

Java Theory and Practice: block memory leakage with weak references

Java Theory and Practice: Use Weak references to block memory leaks-Linux general technology-Linux programming and kernel information. The following is a detailed description. Although Java™In theory, a program written in a language does not have a "memory leak", but sometimes objects are not garbage collected after they are no longer part of the logic state of t

Java Open Source Practice (1)--Environment configuration

Java Open Source Practice 1--environment Configuration Wuder The software required for deploy under Window System: The following software is executed under window Jdk5.0 Download Address: http://java.sun.com/j2se/1.5.0/download.jsp Jdk-1_5_0_01-windows-i586-p.exe Jboss4.01 Download Address: http://prdownloads.sourceforge.net/jboss/ Jboss-4.0.1sp11.zip Mysql4.1 Download Address: http://dev.mysql.c

Java Theory and Practice: dealing with Interruptedexception

Snap to it and then how to deal with it?Many Java™ language methods, such as Thread.sleep() and Object.wait() , can be thrown InterruptedException . You cannot ignore this exception because it is a check exception (checked exception). But what should be done about it? In Java theory and practice this month, the concurrency expert Brian Goetz will explain Interrup

Java Theory and Practice: using Volatile variables correctly

Http://www.ibm.com/developerworks/cn/java/j-jtp06197.htmlThe Java™ language contains two intrinsic synchronization mechanisms: synchronous blocks (or methods) and volatile variables. Both of these mechanisms are proposed to achieve the security of code threads. Where volatile variables are less synchronous (but sometimes simpler and less expensive), and their use is more error-prone. In this period of

Java Theory and Practice: using Volatile variables correctly

Guidelines for using volatile variablesThe Java™ language contains two intrinsic synchronization mechanisms: synchronous blocks (or methods) and volatile variables. Both of these mechanisms are proposed to achieve the security of code threads. Where volatile variables are less synchronous (but sometimes simpler and less expensive), and their use is more error-prone. In this period of Java theory and

Java HDU a+b for Input-output Practice (III)

A+b for Input-output Practice (III)Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)Total submission (s): 113961 Accepted Submission (s): 60127Problem Descriptionyour task is to Calculate A + B.Inputinput contains multiple test cases. Each test case contains a pair of integers a and B, one pair of integers per line. A test case contai

"Java Concurrency Programming Practice" Digest

. volatilevariables are not cached in registers or in places that are not visible to other processors, so the volatile most recently written value is always returned when a variable of type is read.volatileYou should use variables only if they simplify the implementation of your code and validate your synchronization policies. If you need to make complex judgments about visibility when validating correctness, do not use volatile variables. volatilethe correct use of variables includes:

Java Threading Practice Select City

{@Override Public voidrun () { for(inti=1;i) {Random R=NewRandom (); intN=r.nextint (1000); Try{thread.sleep (n); } Catch(interruptedexception e) {e.printstacktrace (); } System.out.println ("I first" +i+ "Want to go:" +Thread.CurrentThread (). GetName ()); if(i==10) {System.out.println ("To Go is:" +Thread.CurrentThread (). GetName ()); System.exit (0); } } } Public Static voidMain (string[] args) {Thread th=NewThread (NewTest7 ()); Th.setname (Beijing); Thread Th1=NewThr

Java application little practice, kitten

PackageLianxiti; Public classCat {PrivateString name; PrivateString color; Private intAge ; PublicString GetName () {returnname; } Public voidsetName (String name) { This. name=name; } PublicString GetColor () {returncolor; } Public voidsetcolor (String color) { This. color=color; } Public intGetage () {returnAge ; } Public voidSetage (intAge ) { This. Age =Age ; } //Behavior//Display Name Public voidShowName () {System.out.println ("The cat's name is:" +

Java practice using code to determine the beginning and end of a string

String str = "ASDFGHJKL"; String str1= "ASD"; //Index comparison by first letter if(Str.indexof ("asd") = = 0) {System.out.println ("True"); } String str2= "JKL"; if(Str.lastindexof ("jkl") = = Str.length ()-str2.length ()) {System.out.println ("True"); } //to compare by intercepting a stringSystem.out.println ((str.substring (0, Str1.length ())). Equals (STR1)); System.out.println (Str.substring (Str.length ()-Str2.length ())). Equals (STR2));

[Java concurrent programming practice] ----- "J. U. C": CLH queue lock

[Java concurrent programming practice] ----- "J. U. C": CLH queue lock CLH queue is a queue that maintains a group of threads strictly in FIFO mode in AQS. He is able to ensure that there is no hunger and strict first-come Service Fairness. It is a CLH queue node: The node QNode in the clh queue contains a locked field. This field indicates whether the node needs to obtain the lock. If it is set to true

Java Fundamentals IO Stream (practice)

(Object obj) {if(! (objinstanceofStudent))Throw NewRuntimeException ("not a student."); Student stu= (Student) obj;if( This. Zongreturn 1;Else if( This. Zong==stu.zong)return This. Name.compareto (Stu.name);return-1; }}class studentinfoutil{ Public StaticSetgetstudents()throwsIOException {BufferedReader bur=NewBufferedReader (NewInputStreamReader (system.in)); String line=NULL; SetNewTreeset while((Line=bur.readline ())! =NULL) {if(Line.equals ("Over")) Break; String[] Info=line.split ("

Java-gui Practice example, QQ login interface

"Implementation Interface"AnalysisThe whole with default borderlayout (border layout), divided into upper and lower, respectively, with three JPanel storage;On: A picture, with JLabel;Under: Three buttons JButtonMiddle: Stored with a jtabbedpane (tab)Each option is a GridLayout (grid layout)Four JLabel, one JTextField, one jpassword, one JButton, two jcheckbox (check box)CodePackage Start;import java.awt.*;//must be introduced in two packages import Javax.swing.*;//public class Main extends jfra

Algorithm note _105: Blue Bridge cup practice algorithm to improve God's problem five minutes (Java)

, the minimum value of the vector in the corresponding query interval. Sample Input7 41-1-4 8 1 2-70 01 34 50 6Sample Output1-41-7Sample DescriptionThe first query [0,0] means min{a[0]}=min{1}=1The second query [1,3] means min{a[1],a[2],a[3]}=min{-1,-4,8}=-4The third query [4,5] means min{a[4],a[5]}=min{1,2}=1the fourth query [0,6] means querying the entire vector, seeking min{a[0..6]}=min{1,-1,-4,8,1,2,-7}=-7data size and conventions12 Solutions The specific code is as follows:ImportJava.util.S

Blue Bridge Cup Basics Practice Java 01-string-in-a-binary conversion

=NewString[32];4 for(inti = 0; i ) {5Strings[i] = integer.tobinarystring (i);//decimal conversion to 2 binary6 //0 in front of numbers not enough 5 digits7 if(strings[i].length () = = 1) {//1-digit number8Strings[i] = "0000" +Strings[i];9}Else if(Strings[i].length () ==2) {TenStrings[i] = "000" +Strings[i]; One}Else if(Strings[i].length () ==3) { AStrings[i] = "00" +Strings[i]; -}Else if(Strings[i].length () ==4) { -Strings[i] = "0" +Strings[i]; the}Else{ -Strings[i] =Stri

Algorithm note _098: Blue Bridge cup practice algorithm to improve the shield God and the bar necklace (Java)

=NewScanner (system.in); intn =In.nextint (); intm =In.nextint (); VectorNewVector(); for(inti = 0;i ) List.add (In.nextint ()); for(inti = 0;i ) {String operation=In.next (); if(Operation.equals ("ADD")) { intP =In.nextint (); intQ =In.nextint (); intj =List.indexof (P); List.add (J, Q); } Else if(Operation.equals ("DEL")) { intP =In.nextint (); intj =List.indexof (P); List.remove (j); }} System.out.println (List.size ()); for

Algorithm note _077: Blue Bridge cup practice K good number (Java)

the 3-digit number is in num case Public voidPrintresult (intKintL) { for(inti = 0;i ) dp[1][i] = 1;//target number lowest bitInitialize to 0~k-1 in turn, with each number appearing only once for(inti = 2;i //the position of the number, the highest bit is L, the lowest bit is 1 for(intj = 0;j ) { for(intF = 0;f ) { if(F-1! = J F + 1! =j) {Dp[i][j]+ = Dp[i-1][f]; DP[I][J]%=MoD; } } } } intsu

Java Conditional Statement Practice

){System.out.println (year+ "is a leap year");}Else{System.out.println (year+ "Not a leap year");}*//*SYSTEM.OUT.PRINTLN ("Input Gender: Height: Weight:");//Determine whether the figure is standardScanner sc = new Scanner (system.in);String sex = Sc.nextline ();Double height = sc.nextdouble ();Double weight = sc.nextdouble ();Double Biao;if (Sex.equals ("male")){Biao = height-100;if (biao-3{System.out.println ("good");}else if (biao-3>height){System.out.println ("thin");}Else{System.out.println

Java Practice Questions: solving a two-time equation, judging leap years, judging the standard body, three numbers to take the maximum value

standard weightNote:The meaning of the standard body weight: Height-weight (kg) and 100 (110) Subtract, the difference is more than 3 is thin, less than 3 is overweight, between 3 and 3 is the standard. Scanner sc=new Scanner (system.in); System.out.println ("Please enter gender (male or female):"); String Sex=sc.next (); System.out.println ("Please enter height:"); int height=sc.nextint (); System.out.println ("Please enter weight (kg):"), int weight=sc.nextint (), int a=height-

Total Pages: 15 1 .... 8 9 10 11 12 .... 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.