当前位置: 首页 > news >正文

常州网站制作案例域名是什么样式的

常州网站制作案例,域名是什么样式的,学习软件大全,东莞手机网站模板​笔记汇总:《Java面向对象程序设计》学习笔记 这些题其实都非常滴简单,相信大伙能够立刻就秒了吧😎 文章目录 题目答案 题目 以下程序要求从键盘输入一个整数, 判别该整数为几位数, 并且输出结果, 请将下…

​笔记汇总:《Java面向对象程序设计》学习笔记

这些题其实都非常滴简单,相信大伙能够立刻就秒了吧😎

文章目录

  • 题目
  • 答案

题目

  1. 以下程序要求从键盘输入一个整数, 判别该整数为几位数, 并且输出结果, 请将下面的程序填写完整。
public class Blank1 {public static void main(String[] args) throws IOException {Scanner sc = new Scanner(____(1)____);int count = 0, t;int x = sc.nextInt();sc.close();t = x;while (t != 0) {count++;____(2)____;}System.out.println(x + "是" + count + "位数");}
}

  1. 在下面的程序中使用方法重载分别实现了两个和三个整数的相加,请将下面的程序填写完整。
class AddOver {public ____(3)____ {return a + b;}public int add(int a, int b, int c) {return a + b + c;}
}class Blank2 {public static void main(String[] args) {AddOver a = ____(4)____;System.out.println(a.add(1, 2));System.out.println(a.add(1, 2, 3));}
}

  1. 构造一个类来描述一个点,该类的构成包括点的x和y两个坐标,以及一些对点进行的操作,包括:取得点的坐标值,利用另一个点对当前点的坐标进行赋值,请将下面的程序填写完整。
class Point {int x, y;public ____(5)____(int x, int y) {this.x = x;this.y = y;}public Point getPoint() {Point temp = new Point(0, 0);temp.x = x;temp.y = y;return ____(6)____;}public void setPoint(____(7)____) {this.x = s.x;this.y = s.y;}
}public class Blank3 {public static void main(String[] args) {Point a = new Point(3, 4);Point b = new Point(0, 0);b = a.getPoint();Point c = new Point(0, 0);c.setPoint(b);}
}

  1. 下面的程序完成从 D:\Hello.txt 读取文本并显示在屏幕上,请将下面的程序填写完整。
public class Blank4 {public static void main(String[] args) {String fileName = "D:/Hello.txt", line;try {BufferedReader in = new BufferedReader(____(8)____);line = in.readLine();while (____(9)____) {System.out.println(line);line = ____(10)____;}in.close();} catch (Exception e) {System.out.println("Problem reading " + fileName);}}
}

  1. 下面的程序通过方法调用从包含 7 个学号的数组中随机抽取一个学号并输出显示,请将下面的程序填写完整。
public class Ex1 {public ____(11)____ String getXh() {String[] xhs = {"1","2","3","4","5","6","7"};int index = ____(12)____; // 生成 0 ~ 6 之间的随机数return xhs[index];}public static void main(String[] args) {System.out.println("随机抽取的学号为: " + ____(13)____);}
}

  1. 下面的程序定义了一个线程 TimeThread ,该线程每隔 1 秒钟输出显示一次当前系统时间,在 main 方法中使用 TimeThread 类创建 3 个新线程,并启动这些线程,请将下面的程序填写完整。
import java.util.Date;class TimeThread implements ____(14)____ {public void run() {while (true) {Date currentTime = new Date();try {____(15)____; // 休眠1秒钟} catch (Exception e) {System.out.println(e.toString());}System.out.println(Thread.currentThread().getName() + ":" + currentTime);}}
}public class Ex2 {public static void main(String[] args) {String[] names = { "first", "second", "third" };TimeThread myThread = new TimeThread();for (int i = 0; i < 3; i++) {Thread thread = new Thread(myThread, names[i]);____(16)____; // 启动线程}}
}

  1. 下面的程序对“百鸡百钱”问题进行了求解,公鸡每只 3 元,母鸡每只 5 元,小鸡 3 只 1 元,用 100 元钱买 100 只鸡,公鸡、母鸡、小鸡应各买多少?请将程序填写完整。
public class Ex3 {public static void main(String[] args) {int a, b, c;for (a = 0; ____(17)____; a++) {for (b = 0; ____(18)____; b++) {c = 100 - a - b;if ((3 * a + 5 * b + c / 3 == 100) && (____(19)____)) {System.out.println("公鸡:" + a + " 母鸡:" + b + " 小鸡:" + c);}}}}
}

  1. 下面的程序使用 BufferedWriter 类在 D:\Hello.txt 文件中写入 10 万个数并输出所用的时间,请将程序填写完整。
public class Ex4 {public static void main(String[] args) throws IOException {long t = System.currentTimeMillis();BufferedWriter fw = new BufferedWriter(____(20)____);for (int i = 1; i <= 100000; i++) {____(21)____(i + "\n");}fw.close();t = System.currentTimeMillis() - t;System.out.println("Time elapsed: " + t + "ms");}
}

  1. 根据程序注释提示将下面的程序填写完整。
public class StringExample {public static void main(String[] args) {String s1 = new String("2012");String s2 = new String("100.50");int x = ____(21)____; // 将 s1 转换为 int 类型double y = ____(22)____; // 将 s2 转换为 double 类型double z = x + y;String s3 = ____(23)____; // 将 z 转换为字符串StringBuffer sbr = new StringBuffer("Thingking");String s4 = new String("in Java");____(24)____; // 将 s4 连接在 sbr 的后面System.out.println(sbr.toString()); // 显示为 Thingking in Java}
}

  1. 下面的程序是采用冒泡法对数组元素按小到大的顺序排序,请将程序填写完整。
public class ArraySort {public static void main(String[] args) {int[] a = new int[] { 21, 34, 211, 15, 92, 68, 89, 794, 11, 863 };int temp;for (int i = 0; i < 10; i++) {for (int j = 0; j < ____(26)____; j++) {if(a[j] > a[j + 1]) {temp = a[j];____(27)____;____(28)____;}}}for (int i = 0; i < a.length; i++) {System.out.println(a[i] + " ");}}
}

  1. “同构数”是指这样的整数:它恰好出现在其平方数的右端,例如 5 和 6 就是同构数。请编写一程序找出 10 ~ 999 之间的同构数,并输出显示。
public class TGS {public static void main(String[] args) {for (int i = 10; i <= 999; i++) {if (____(29)____ || ____(30)____) {System.out.println(i);}}}
}

  1. 编程求出 1-100 之间偶数的和。
public class Exam1 {public static void main(String[] args) {____(31)____; // 定义整型变量 sumfor (int i = 2; i <=100;) {sum += i;____(32)____;}System.out.println("1-100 之间偶数的和是:" + sum);}
}

  1. 完成求 n ! 的程序
public class Exam2 {static void factorial(int n) {long m = 1;for (int x = 1; x <= n; ____(33)____) {____(34)____;System.out.println(x + "!=" + m);}}public static void main(String[] args) {factorial(9);}
}

  1. 下面的程序定义了一个线程 PrintThread ,该线程打印输出 1~100 之间所有 3 的倍数,每输出一个数,休眠 1500 毫秒,在 main 方法中创建了该线程的一个实例,并启动该线程。请将下面的程序填写完整。
class PrintThread extends ____(35)____ {public PrintThread(String str) {____(36)____; // 调用父类的构造方法}public void run() {for (int i = 1; i <= 100; i++) {if (i % 3 == 0) {System.out.println(this.getName() + ": " + i);}try {____(37)____; // 休眠 1500 毫秒} catch (Exception e) {System.out.println(e.toString());}}}
}public class Exam5 {public static void main(String[] args) {PrintThread myThread = new PrintThread("PrintThread");____(38)____; // 启动线程}
}

  1. 中国有句俗语“三天打鱼两天晒网”,某人从 2010 年 1 月 1 日起三天打鱼两天晒网,编程计算 2010年 5 月 1 日,他在打鱼还是在晒网。打鱼则输出 1 ,晒网则输出 0 。请将程序填写完整。
public class Exam4 {public static void main(String[] args) {int[] dpm = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };int month = 5;int day = 1;for (int i = 0; ____(39)____; i++) {day = day + dpm[i];}day = day % 5;if (____(40)____) {System.out.println("1"); // 表示打鱼} else {System.out.println("0"); // 表示晒网}}
}

  1. 调用函数 f 输出 n 的所有质数因子如 n=13860 则输出 2 2 3 3 5 7 11。请将下面的程序填写完整。
public class JModify {public static void f(int n) {int i = 2;while (n > 1) {____(41)____ {System.out.println(i);n /= i;} else {____(42)____;}}}public static void main(String[] args) {int n = 100;f(n);}
}

  1. 下面的程序通过方法调用从包含 4 个手机号码的字符串数组中随机抽取一个幸运手机号并输出显示,请根据提示将程序填写完整。
public class RandomTel {public ____(43)____ String getTel() {String[] tels = {"138****8080","189****6666","133****1234","139****9999",};int index = ____(44)____; // 用Math类中的方法生成0 ~ 3 之间的随机数return tels[index];}public static void main(String[] args) {System.out.println("随机幸运手机号为:" + ____(45)____);}
}

  1. 宾馆里有 100 个房间,从 1-100 进行编号,第一个服务员将所有的房间门都打开,第二个服务员把所有编号是 2 的倍数的房间“相反处理’',第三个服务员将所有编号是 3 的倍数的房间再作“相反处理",以后每个服务员都是如此操作,当第 100 个服务员来过后,请编程计算哪几个房间的门是打开的?(所谓“相反处理"是指原来开着的门关上,原来关上的门打开)请将程序填写完整。
public class HotelDoor {public static void main(String[] args) {boolean[] a = new boolean[101];final int N = 101;int i,j;for (i = 1; i < N; i++) {____(46)____; // 第 1 个服务员将所有房间设置为打开状态}for (i = 2; i < N; i++) {for (____(47)____; j < N; j++) {if(j % i == 0) {____(48)____; // 执行相反处理}}}for (i = 1; i < N; i++) {if(a[i] == true) {System.out.println(i + " "); // 显示打开状态的房间编号}}}
}

  1. 以下程序要求从键盘输入一整数,判别该整数是否是素数,并输出“是素数"或“不是素数“,请将程序填写完整。
import java.util.Scanner;
public class PrimeExam {public static void main(String[] args) {Scanner sc = new Scanner(____(49)____);int flag = 0;int x = sc.____(50)____;int y = (int)Math.sqrt(x);for (int i = 2; i <= y; i++) {if(____(51)____) {System.out.println("不是素数");flag = 1;break;}}if (____(52)____) {System.out.println("是素数");}}
}

答案

(1) System.in
(2) t=t/10(3) int add(int a, int b)
(4) new AddOver()(5) Point
(6) temp
(7) Point s(8) new FileReader(fileName)
(9) line != null
(10) in.readLine()(11) static
(12) (int)(Math.random()*7)
(13) getXh()(14) Runnable
(15) Thread.sleep(1000)
(16) thread.start()(17) a <= 33
(18) b <= 20
(19) c % 3 == 0(20) new FileWriter("D:\\Hello.txt")
(21) fw.write(22) Integer.parseInt(s1)
(23) Double.parseDouble(s2)
(24) String.valueOf(z) 或 z + ""
(25) sbr.append(s4)(26) a.length - 1 - i 或 9 - i
(27) a[j] = a[j + 1]
(28) a[j + 1] = temp(29) i * i % 100 == i
(30) i * i % 1000 == i(31) int sum = 0
(32) i = i + 2 或 i += 2(33) x++
(34) m = m * x 或 m *= x(35) Thread
(36) super(str)
(37) sleep(1500)
(38) myThread.start()(39) i < month 或 i < 5
(40) day > 0 && day <= 3(41) if(n%i==0)
(42) i++(43) static
(44) (int)(Math.random()*4)
(45) getTel()(46) a[i] = true
(47) j = i
(48) a[j] = !a[j](49) System.in
(50) nextInt()
(51) x % i == 0
(52) flag == 0
http://www.yayakq.cn/news/416895/

相关文章:

  • 广州做企业网站找哪家公司好wordpress提醒用法
  • 给别人做网站别人违法经营网站建站的一般步骤
  • php手机网站怎么做北京网站排行
  • 沈阳软件公司 网站制作企点下载官网
  • 网站后台怎么进入wordpress建网站需要哪些步骤
  • 山西智能建站系统价格网站站点文件夹权限设置
  • 公益建设网站的作用网站设计中建设规划和准备阶段
  • 最超值的网站建设赚钱黑渠道入口
  • 著名设计网站deviantart的id模板高端做网站哪家好
  • 中石建基础设施建设有限公司网站好网站建设公司地址
  • 公司网站可以自己做吗h5商城网站开发
  • 如何做房产网站wordpress会员打赏插件
  • 用dw6做网站wp大学wordpress建站流程
  • 中英文网站建设经典软文文案
  • 网站建站费用多少邢台招聘信息最新招聘2023
  • 建立网站需要怎么做网页设计与制作实训心得体会
  • 有没有专业做二手老车的网站可以分销的平台
  • 广州网站设计联系方式重庆网站建设联系电话
  • 网站建设与管理量化考细则曲周专业做网站
  • 提供常州微信网站建设上海网站建设,迈
  • 白水网站建设濮阳房产网
  • 商用营销型网站建设单位网站建设管理情况
  • wordpress 导航 主题长春网络优化哪个公司在做
  • 甘肃省住房和城乡建设厅网站首页佛山网站设计建设
  • 浙江省住房和城乡建设厅官方网站seo什么职位
  • 怎么看网站关键词密度怎样提高网站的打开速度
  • 企业网站建设方案文档广告投放计划
  • 网站建设规划书中的技术可行性不包括电商网站项目
  • 网站建设公司开发肥东网站建设
  • art2008cms网站开发上海新媒体运营公司排名