在线观看1024国产,亚洲精品国产综合野狼,欧美自拍清纯日韩一区二区三区,欧美 亚洲 国产 高潮

<dfn id="u8moo"><source id="u8moo"></source></dfn>
  • <dd id="u8moo"><s id="u8moo"></s></dd><menu id="u8moo"></menu><dd id="u8moo"></dd>
    
    
    <ul id="u8moo"></ul>
    <ul id="u8moo"><acronym id="u8moo"></acronym></ul>
  • <strike id="u8moo"><noscript id="u8moo"></noscript></strike>
  • <dd id="u8moo"></dd>
  • java基礎(chǔ)面試題完整版

    時(shí)間:2022-07-13 15:51:11 面試 我要投稿
    • 相關(guān)推薦

    java基礎(chǔ)面試題(2012完整版)

    141、JAVA 多線程編程。 用 JAVA 寫一個(gè)多線程程序,如寫四個(gè)線程,二個(gè)加 1,二個(gè)對(duì)一

    java基礎(chǔ)面試題(2012完整版)

    個(gè)變量減一,輸出。

    希望大家補(bǔ)上,謝謝

    142、可能會(huì)讓你寫一段 Jdbc連Oracle 的程序,并實(shí)現(xiàn)數(shù)據(jù)查詢.

    答:程序如下:

    package hello.ant;

    import java.sql.*;

    public class jdbc

    {

    String dbUrl="jdbc:oracle:thin:@127.0.0.1:1521:orcl";

    String theUser="admin";

    String thepw="manager";

    Connection c=null;

    Statement conn;

    ResultSet rs=null;

    public jdbc()

    {

    try{

    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

    c = DriverManager.getConnection(dbUrl,theUser,thepw); conn=c.createStatement();

    }catch(Exception e){

    e.printStackTrace();

    }

    }

    public boolean executeUpdate(String sql)

    {

    ---------- 16 ----------

    *** JAVA面試題.txt ***

    try

    {

    conn.executeUpdate(sql);

    return true;

    }

    catch (SQLException e)

    {

    e.printStackTrace();

    return false;

    }

    }

    public ResultSet executeQuery(String sql)

    {

    rs=null;

    try

    {

    rs=conn.executeQuery(sql);

    }

    catch (SQLException e)

    {

    e.printStackTrace();

    }

    return rs;

    }

    public void close()

    {

    try

    { conn.close();

    c.close();

    }

    catch (Exception e)

    {

    e.printStackTrace();

    }

    }

    public static void main(String[] args)

    {

    ResultSet rs;

    jdbc conn = new jdbc();

    rs=conn.executeQuery("select * from test");

    try{

    while (rs.next())

    {

    System.out.println(rs.getString("id"));

    System.out.println(rs.getString("name"));

    }

    }catch(Exception e)

    {

    e.printStackTrace();

    }

    }

    }

    143、ORACLE 大數(shù)據(jù)量下的分頁解決方法。一般用截取 ID方法,還有是三層嵌套方法。

    答:一種分頁方法

    <%< b="">

    int i=1;

    int numpages=14;

    String pages = request.getparameter("page") ;

    int currentpage = 1;

    currentpage=(pages==null)?(1):{Integer.parseInt(pages)}

    sql = "select count(*) from tables";

    ResultSet rs = DBLink.executeQuery(sql) ;

    while(rs.next()) i = rs.getInt(1) ;

    int intpageCount=1;

    intpageCount=(i%numpages==0)?(i/numpages):(i/numpages+1);

    int nextpage ;

    int uppage;

    nextpage = currentpage+1; if (nextpage>=intpageCount) nextpage=intpageCount;

    uppage = currentpage-1;

    if (uppage<=1) uppage=1;

    ---------- 17 ----------

    *** JAVA面試題.txt ***

    rs.close();

    sql="select * from tables";

    rs=DBLink.executeQuery(sql);

    i=0;

    while((i

    %>

    //輸出內(nèi)容

    //輸出翻頁連接

    合計(jì):<%=currentpage%>/<%=intpagecount%>

    上一頁

    <%< b="">

    for(int j=1;j<=intpagecount;j++){< b="">

    if(currentpage!=j){

    %>

    <%< b="">

    }else{

    out.println(j);

    }

    }

    %>

    最后頁

    144、用 jdom解析xml 文件時(shí)如何解決中文問題?如何解析?

    答:看如下代碼,用編碼方式加以解決

    package test;

    import java.io.*;

    public class DOMTest

    {

    private String inFile = "c:\\people.xml";

    private String outFile = "c:\\people.xml";

    public static void main(String args[])

    {

    new DOMTest();

    }

    public DOMTest()

    {

    try

    {

    javax.xml.parsers.DocumentBuilder builder =

    javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();

    org.w3c.dom.Document doc = builder.newDocument();

    org.w3c.dom.Element root = doc.createElement_x("老師");

    org.w3c.dom.Element wang = doc.createElement_x("王");

    org.w3c.dom.Element liu = doc.createElement_x("劉");

    wang.appendChild(doc.createTextNode("我是王老師"));

    root.appendChild(wang);

    doc.appendChild(root);

    javax.xml.transform.Transformer transformer =

    javax.xml.transform.TransformerFactory.newInstance().newTransformer();

    transformer.setOutputproperty(javax.xml.transform.OutputKeys.ENCODING, "gb2312");

    transformer.setOutputproperty(javax.xml.transform.OutputKeys.INDENT, "yes");

    transformer.transform(new javax.xml.transform.dom.DOMSource(doc),

    new

    javax.xml.transform.stream.StreamResult(outFile));

    ---------- 18 ----------

    *** JAVA面試題.txt ***

    }

    catch (Exception e)

    {

    System.out.println (e.getMessage());

    }

    }

    }

    145、編程用JAVA 解析 XML 的方式.

    答:用 SAX方式解析XML,XML文件如下:

    王小明

    信息學(xué)院

    6258113

    男,1955 年生,博士,95 年調(diào)入海南大學(xué)

    事件回調(diào)類SAXHandler.java

    import java.io.*;

    import java.util.Hashtable;

    import org.xml.sax.*;

    public class SAXHandler extends HandlerBase

    {

    private Hashtable table = new Hashtable(); private String currentElement = null;

    private String currentValue = null;

    public void setTable(Hashtable table)

    {

    this.table = table;

    }

    public Hashtable getTable()

    {

    return table;

    }

    public void startElement(String tag, AttributeList attrs)

    throws SAXException

    {

    currentElement = tag;

    }

    public void characters(char[] ch, int start, int length)

    throws SAXException

    {

    currentValue = new String(ch, start, length);

    }

    public void endElement(String name) throws SAXException

    {

    if (currentElement.equals(name))

    table.put(currentElement, currentValue);

    }

    } JSp內(nèi)容顯示源碼,SaxXml.jsp:

    剖析XML文件people.xml

    <%@ page errorpage="Errpage.jsp"

    contentType="text/html;charset=GB2312" %>

    <%@ page="" import="java.io.*">

    <%@ page="" import="java.util.Hashtable">

    <%@ page="" import="org.w3c.dom.*">

    <%@ page="" import="org.xml.sax.*">

    <%@ page="" import="javax.xml.parsers.SAXparserFactory">

    <%@ page="" import="javax.xml.parsers.SAXparser">

    <%@ page="" import="SAXHandler">

    <%< b="">

    File file = new File("c:\\people.xml");

    FileReader reader = new FileReader(file);

    parser parser;

    SAXparserFactory spf = SAXparserFactory.newInstance();

    SAXparser sp = spf.newSAXparser();

    SAXHandler handler = new SAXHandler();

    sp.parse(new InputSource(reader), handler);

    ---------- 19 ----------

    *** JAVA面試題.txt ***

    Hashtable hashTable = handler.getTable();

    out.println("


    教師信息表");

    out.println("


    姓名" + "

    " +

    (String)hashTable.get(new String("name")) + "");

    out.println("


    學(xué)院" + "

    " +

    (String)hashTable.get(new String("college"))+"");

    out.println("


    電話" + "

    " +

    (String)hashTable.get(new String("telephone&

    【java基礎(chǔ)面試題完整版】相關(guān)文章:

    java 基礎(chǔ)面試題07-11

    Java面試題07-12

    JAVA題庫:JAVA面試題目整理07-11

    java面試題五07-11

    華為Java面試題07-11

    華為的JAVA面試題07-11

    求java面試題07-11

    華為公司 java人員面試題07-11

    華為全套面試題(基礎(chǔ)版)07-11

    一道Java面試題,題目如下07-11