A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 金鑫 中级黑马   /  2012-7-13 00:12  /  1761 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

JAVA的学习本身就是需要大量的实践,每天只看视频是远远不够的。谁有什么比较好的JAVA编程练习的题目,能发一份或者有网址的,万分感谢~~~

1 个回复

倒序浏览
这是毕老师讲的前两张的练习内容,不知道对你有没有用。
  1. 练习1:3000米长绳子,每天减一半,需要多少天绳子小于五米?
  2. 思路:
  3. 1,多少天,这个数据不确定,定义变量。
  4. 只要能减一半,就要算加一天。
  5. 满足某一个条件就要进行自增,计数器思想。

  6. 2,既然明确了是计数器思想,需要定义变量,
  7. 需要循环对该变量操作,同时还要明确条件。
  8. -----------------------------------------------
  9. 第一题
  10. int x = 1,y = 1;

  11. if(x++==2 & ++y==2)
  12. {
  13. x = 7;
  14. }
  15. System.out.println("x="+x+",y="+y);//x=2,y=2


  16. ---------------------------------------------------
  17. 第二题
  18. int x = 1,y = 1;

  19. if(x++==2 && ++y==2)
  20. {
  21. x = 7;
  22. }
  23. System.out.println("x="+x+",y="+y);//x=2,y=1

  24. ---------------------------------------------------

  25. 第三题
  26. int x = 1,y = 1;

  27. if(x++==1 | ++y==1)
  28. {
  29. x = 7;
  30. }
  31. System.out.println("x="+x+",y="+y);//x=7,y=2;


  32. ---------------------------------------------------

  33. 第四题
  34. int x = 1,y = 1;

  35. if(x++==1 || ++y==1)
  36. {
  37. x =7;
  38. }
  39. System.out.println("x="+x+",y="+y);//x=7,y=1


  40. ---------------------------------------------------
  41. 第五题
  42. boolean b = true;

  43. if(b==false) //如果写成if(b=false)有结果吗?如果有,结果是?
  44. System.out.println("a");
  45. else if(b)
  46. System.out.println("b");
  47. else if(!b)
  48. System.out.println("c");
  49. else
  50. System.out.println("d");


  51. ---------------------------------------------------

  52. 第六题
  53. int x = 2,y=3;

  54. switch(x)
  55. {
  56. default:
  57. y++;
  58. case 3:
  59. y++;
  60. case 4:
  61. y++;
  62. }

  63. System.out.println("y="+y);//y=6
  64. -------------------------------------------
  65. 用循环打印出这个图形

  66. * * * * *
  67. -* * * *
  68. --* * *
  69. ---* *
  70. ----*

  71. -------------------------------------------------

  72. 练习编程题:
  73. 定义一个功能,完成对考试成绩的等级划分。
  74. 90~100 A 优秀
  75. 80~89 B 良好
  76. 70~79 C 中等
  77. 60~69 D 及格
  78. 60以下 E 不及格
  79. ---------------------------------------------------
  80. 要求:画出该程序的内存运行流程图。
  81. class Test06
  82. {
  83. public static void main(String[] args)
  84. {
  85. int[] arr = new int[2];
  86. show(arr);
  87. System.out.println(arr[0]);
  88. }
  89. public static void show(int[] arr)
  90. {
  91. arr[0]++;
  92. }
  93. }
  94. -------------------------------------------
  95. 注:按Java规范书写程序代码,如果你认为程序有错误,请指出,并说明程序错误原因。

  96. 1.
  97. class Demo
  98. {
  99. void show(int a,int b,float c){}
  100. }


  101. A.void show(int a,float c,int b){}

  102. B,void show(int a,int b,float c){}

  103. C.int show(int a,float c,int b){return a;}

  104. D.int show(int a,float c){return a;}



  105. --------------------------------------------------
  106. 2.写出结果。
  107. class Demo
  108. {
  109. public static void main(String[] args)
  110. {
  111. int x=0,y=1;
  112. if(++x==y--&x++==1||--y==0)
  113. System.out.println("x="+x+",y="+y);
  114. else
  115. System.out.println("y="+y+",x="+x);
  116. }
  117. }
  118. --------------------------------------------------
  119. 3.
  120. 写出输出结果。
  121. class Demo
  122. {
  123. public static void main(String[] args)
  124. {
  125. int a=3,b=8;

  126. int c=(a>b)?a++:b++;//输出b++
  127. System.out.println("a="+a+"\tb="+b+"\tc="+c); //

  128. int d=(a>b)?++a:++b;//输出++b
  129. System.out.println("a="+a+"\tb="+b+"\td="+d); //
  130. int e=(a<b)?a++:b++;//输出a++
  131. System.out.println("a="+a+"\tb="+b+"\te="+e);//

  132. int f=(a<b)?++a:++b;输出++a
  133. System.out.println("a="+a+"\tb="+b+"\tf="+f); //
  134. }
  135. }

  136. --------------------------------------------------
  137. 4.写出结果。
  138. class Demo
  139. {
  140. public static void main(String[] args)
  141. {
  142. int m=0,n=3;
  143. if(m>0)

  144. if(n>2)
  145. System.out.println("A");
  146. else
  147. System.out.println("B");

  148. }
  149. }

  150. --------------------------------------------------
  151. 5.写出结果。
  152. public class Demo
  153. {
  154. public static void main(String []args)
  155. {
  156. int i = 0, j = 5;
  157. tp: for (;;)
  158. {
  159. i++;
  160. for(;;)
  161. {
  162. if(i > j--)
  163. break tp;
  164. }
  165. }
  166. System.out.println("i = " + i + ", j = "+ j);
  167. }
  168. }

  169. --------------------------------------------------
  170. 6.写出结果。
  171. class Demo
  172. {
  173. public static void main(String[] args)
  174. {
  175. String foo="blue";
  176. boolean[] bar=new boolean[2]; //
  177. if(bar[0])//
  178. {
  179. foo="green";
  180. }
  181. System.out.println(foo);//
  182. }
  183. }
  184. --------------------------------------------------
  185. 7.写出结果。
  186. public class Test
  187. {
  188. public static void leftshift(int i, int j)
  189. {
  190. i+=j;

  191. }
  192. public static void main(String args[])
  193. {
  194. int i = 4, j = 2;
  195. leftshift(i,j);
  196. System.out.println(i);
  197. }
  198. }
  199. --------------------------------------------------
  200. 8.写出结果。
  201. public class Demo
  202. {
  203. public static void main(String[] args)
  204. {
  205. int[] a=new int[1];
  206. modify(a);
  207. System.out.println(a[0]);
  208. }
  209. public static void modify(int[] a)
  210. {
  211. a[0]++;
  212. }
  213. }
  214. --------------------------------------------------
  215. 9.
  216. class Test
  217. {
  218. public static void main(String[] args)
  219. {
  220. String foo=args[1];
  221. String bar=args[2];
  222. String baz=args[3];
  223. }
  224. }
  225. d:\>java Test Red Green Blue

  226. what is the value of baz?
  227. A. baz has value of ""
  228. B. baz has value of null
  229. C. baz has value of "Red"
  230. D. baz has value of "Blue"
  231. E. baz has value of "Green"
  232. F. the code does not compile
  233. G. the program throw an exception

  234. --------------------------------------------------

  235. 11.
  236. 简述:函数在程序中的作用以及运行特点。。




  237. --------------------------------------------------
  238. 12.
  239. 打印99乘法表

  240. --------------------------------------------------

  241. 13.
  242. 下面哪个数组定义是错误的。
  243. 并对错误的答案加上单行注释,写出错误的原因。
  244. A,float[]=new float[3]; //
  245. B, float f2[]=new float[];//
  246. C, float[] f1=new float[3];
  247. D, boolean[] b={"true","false","true"};//
  248. E, double f4[]={1,3,5}; //
  249. F, int f5[]=new int[3]{2,3,4};
  250. G, float f4[]={1.2,3.0,5.4};















复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马