The Java Part review question

Source: Internet
Author: User

What is multithreaded synchronization? How to implement multi-threaded synchronization?
Synchronous Multithreading (SMT) is a hardware multithreading technique capable of executing instructions from multiple threads within a CPU's clock cycle.

There are two ways to implement multithreading, namely, inheriting the thread class and implementing Runnable interface synchronization, there are two kinds of implementation, namely synchronized,wait and notify, thread basic concept, The basic state of a thread and the relationship between states a: a thread is an execution unit that executes a program's code during the execution of a program, and each program has at least one thread, the program itself. There are four types of threads in Java: Run, ready, suspend, end


write a binary lookup algorithm code.
Two-part lookup code
public class Halfsearch {
 public static int halfsearch (int a[], int x) {
  int mid, left, right ;
  left = 0;
  right = a.length-1;
   mid = (left + right)/2;
  while (A[mid]! = x) {
   if (x > A[mid]) {
    left = mid + 1;
   }
   else if (x < A[mid]) {
    right = mid-1;
   }
            mid= (left+right)/2;
 
  return mid;
 }
 public static void Main (string[] args) {
  int a[] = {1, 2, 3, 4, 5, 6,7,8,9,10};
  for (int i = 0; i < a.length; i++) {
   system.out.print (A[i] + " ");
 }
  System.out.println ();
  int s = 10;
  INT index = Halfsearch (A, s);
  SYSTEM.OUT.PRINTLN (S + "subscript in the array is  " + index);
 }
}


Code that implements a stack data structure in Java code.
<pre name= "code" class= "Java" >public class Stack<e> {

Java does not support generic arrays, if needed, use a Java-supplied container
Private object[] Stack;

Default initial size of the stack
private static final int init_size = 2;

Stack Top Index
private int index;

Public Stack () {
stack = new Object[init_size];
index =-1;
}

/**
* Construction Method
*
* @param initsize
* Initial size of stack
*/
Public Stack (int initsize) {
if (Initsize < 0) {
throw new IllegalArgumentException ();
}
stack = new Object[initsize];
index =-1;
}

/**
* Out of stack operation
*
* @return Stack Top Object
*/
Public synchronized E Pop () {
if (!isempty ()) {
E temp = peek ();
stack[index--] = null;
return temp;
}
return null;
}

/**
* In-Stack operation
*
* @param obj
* Objects waiting to be placed on the stack
*/
Public synchronized void push (E obj) {
if (Isfull ()) {
object[] temp = stack;
If the stack is full, create a stack that is twice times the current stack space
stack = new object[2 * Stack.length];
System.arraycopy (temp, 0, stack, 0, temp.length);
}
Stack[++index] = obj;
}

/**
* View top of Stack object
*
* @return Stack Top Object
*/
Public E Peek () {
if (!isempty ()) {
Return (E) Stack[index];
}
return null;
}

/**
* See if the stack is empty
*
* @return Returns True if the stack is empty, otherwise false
*/
public Boolean isEmpty () {
return index = =-1;
}

/**
* Check if the stack is full
*
* @return Returns True if the stack is full, false otherwise
*/
public Boolean isfull () {
return index >= stack.length-1;
}
}


What is the difference between JavaScript and jquery?
JavaScript is a scripting language, mainly used in the browser, to achieve the Web page of the Document object operation and some user interaction action processing.
JQuery is a code base for JavaScript (or habitually called a class library), which combines some of the features that are often used in JavaScript development to make it easier for developers to use directly without having to write large amounts of code in native JavaScript statements. Achieve consistent results across different browsers


Write down the JavaScript code that verifies that the content entered in the HTML text box is all numeric.
<input type= "text" id= "D1" onblur= "Chknumber (This)"/>
<script type= "Text/javascript"/>
function Chknumber (eletext)

{
var value =eletext.value;
var len =value.length;
for (vari=0;i<len;i++)
{
if (Value.charat (i) > "9" | | Value.charat (i) < "0")
{
Alert ("contains non-numeric characters");
Eletext.focus ();
Break
}
}
}
</script>


What is the difference between XHTML and HTML?
HTML is a basic Web page design language, XHTML is an XML-based labeling language
The most important differences are:
XHTML elements must be nested correctly.
XHTML elements must be closed.
XHTML tag names must be in lowercase letters.
The XHTML document must have a root element.

The Java Part review question

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.