一些java考试题目,大家帮忙解答一下,拜托了

njgb 2004-08-19 11:10:19

JAVA
Question 1:
① 略
② In what case is not allowed for one class to inherit another? Given an example of such a case;
③ Briefly explain how overloaded constructors can be distinguished from each other?
④ Define a class called MyMath include a constant of type double called NePero that has values 2.71,ensure that this member can be accessed without instantiating an object.
⑤ Include a method in the MyMath class called “thirdPower” that takes in an integer argument and returns the third power of an argument. Make sure that this method can be called without instantiating an object.
⑥ Include a recursive routing called factorial that takes in one integer argument and returns the factorial of that number.
⑦ Identify and explain how error conditions can be prevented when manipulating a static stack.
⑧ Declare a proper data structure StackNode that supports the dynamic implementation of a stack.. each node in the stack contains integer value include the definition of two public methods. Void push(int N) and in pop().
⑨ Implement a method SumNodes that receives two arguments: top of type stackNode, and an integer N. The parameter top will reference to the top element found in the stack. The purpose of this method is to return the sum of the values from the first to N-th node contained in the stack.
Question 2
Class Stock{ private in id;
Private double price;}
① add a constructor for class Stock that takes in two arguments to initialize the member variables,
② define an accessor getPrice() for class Stock.
③ Write java statement to create a node clinenticsal array of 50 stock objects called “phone”.[这个地方记不清楚了,可能是 声明一个对含有50个元素的Stock类的对象数组]
④ Implement an iteratine stacic method “Highest price” which returns the most expensive price found in the array phone. [Public static double HighestPrice(Stock []phone, int size) ]
⑤ Define an interface named security that contains a constant variable “limits” that holds 10000, and a single method named “range()” that returns a Boolean value.

Question 5
① give a definition of binary search tree.
② Convert these to postfix and prefix notation.
G*H+J/K+D*H
C*D/T+W
③ definition a class for implement a dynamic binary tree, each node in the tree contains data of integer type.
④ Implement a method search that receives a parameter node of binaryTrddBode and an integer searchData and returns ture if the tree contains a node whose data is equal to equal to searchData, and false otherwise.
⑤ Writes a method called countLeaf, the signature of which is given below, which takes in a given binary Search tree of the type, the method should return the numbers of nodes belonging to the leaf category.

...全文
208 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
射天狼 2004-08-19
  • 打赏
  • 举报
回复
UP
moke33 2004-08-19
  • 打赏
  • 举报
回复
分开问吧,这样可以多拿点分,呵呵
zmpcoming 2004-08-19
  • 打赏
  • 举报
回复
记下
aoaoJava 2004-08-19
  • 打赏
  • 举报
回复
恩,看者眼睛就花了
steel007 2004-08-19
  • 打赏
  • 举报
回复
2.final class
3.because of their different parameters
4.class MyMath
{
public static final double NePero = 2.71;
}

问题都不太难,楼主还是自己多看看书吧
draco2002 2004-08-19
  • 打赏
  • 举报
回复
问题太多了,老兄!

建议你分几次问,那样的话回帖的人可能就多了!

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧