面试题:这些题是一家单位给我面试的,那位仁兄能做?
现我把题目公布出来,供大家参考:该写的我都贴出了,有不清楚的大家也不要问我,我也不清楚
题1、write a program to judge whether a number is "loop number"
such as 12321,574765 with java programming language.
题2、what's design pattern please describe one or two design
pattern(s)used in your project.题3、please draw correct associction notations in this diagram,
and then convert the diagram to java souce code _______________ _________________
|(interface) | | Machine |
| Drirable | |_______________|
|______________| |_______________|
|+tarnlefor |
|+trunRight |
|______________|
________________ _______________
| Car | | Wheel |
|______________| |______________|
|______________| |______________|
题4、
public final class Test4{
class inner{
void test(){
if(Test4.this.flag){
sample();
}
}
}
private boolean flag=false;
public void sample(){
system.out.println("sample");}
Public void Test4(){
(new inner()).test();
}
Public static void main(Strung args[]){
new Test4();
}
}
题5、
Public class Demo{
Public static void main(String args[]){
int n=3
System.out.println("the word is"+args[n]);
}
}
what happens?
a)b)c) the runtine system reports an ArrayindexoutofBoundException in the
maun method.d)Then runtime system reports a NullPointerException in the main method.
现我把题目公布出来,供大家参考:该写的我都贴出了,有不清楚的大家也不要问我,我也不清楚
题1、write a program to judge whether a number is "loop number"
such as 12321,574765 with java programming language.
题2、what's design pattern please describe one or two design
pattern(s)used in your project.题3、please draw correct associction notations in this diagram,
and then convert the diagram to java souce code _______________ _________________
|(interface) | | Machine |
| Drirable | |_______________|
|______________| |_______________|
|+tarnlefor |
|+trunRight |
|______________|
________________ _______________
| Car | | Wheel |
|______________| |______________|
|______________| |______________|
题4、
public final class Test4{
class inner{
void test(){
if(Test4.this.flag){
sample();
}
}
}
private boolean flag=false;
public void sample(){
system.out.println("sample");}
Public void Test4(){
(new inner()).test();
}
Public static void main(Strung args[]){
new Test4();
}
}
题5、
Public class Demo{
Public static void main(String args[]){
int n=3
System.out.println("the word is"+args[n]);
}
}
what happens?
a)b)c) the runtine system reports an ArrayindexoutofBoundException in the
maun method.d)Then runtime system reports a NullPointerException in the main method.
public class StaticVariable {
public static void main(String[] args) {
System.out.println(StaticVariable.setNum(2345432));
}
public static boolean setNum(int num) {
boolean isTrue = false;
String strNum = String.valueOf(num);
String strNums[] = new String[strNum.length()];
if (strNum.length() % 2 != 0) {
for (int i = 0; i < strNums.length; i++) {
strNums[i] = strNum.substring(i, i + 1);
System.out.println("strNums[i]=" + strNums[i]);
}
int j = 0;
for (int i = 0; i < strNums.length - 1 / 2; i++) {
if (strNums[i].equals(strNums[strNums.length - 1-i])) {
j++;
}
if (j==strNums.length - 1 / 2) {
isTrue = true;
} }
}
return isTrue;
}
}
而且居然还肯定地说是 ArrayIndexOutOfBoundsException
private String s;
public LoopNumber() {
} public LoopNumber(String str) {
s = str;
} public boolean checkNumber() {
if (s == null) {
return false;
}
char[] cTemp = s.toCharArray();
char[] c = new char[cTemp.length];
int j = 0;
for (int i = cTemp.length - 1; i >= 0; i--) {
c[j] = cTemp[i];
j++;
}
if (String.valueOf(c).equals(s)) {
return true;
}
return false;
} public void setNumber(String str) {
s = str;
} public static void main(String[] args) {
LoopNumber loopnumber = new LoopNumber();
loopnumber.setNumber("abccba");
System.out.println(loopnumber.checkNumber());
}
}
第三题目:
class Machine {
}class car
extends Machine implements Drirable {
private Wheel wheel0, wheel1, wheel2, wheel3;
public void tarnlefor() {
} public void trunRight() {
}
}interface Drirable {
public void tarnlefor(); public void trunRight();
}class Wheel {
}
简单写写,uml关系在jbuilder直接看
好像不全,构造函数没有,估计什么都不会输出。
题目5:
没有给处args参数的索引长度,估计也不全。如果数组越界会执行抛异常。编译没问题。以上题目都是基础题目。
public class StaticVariable
{
public static void main(String[] args)
{
System.out.println(StaticVariable.setNum0(55));
}
public static boolean setNum0(int num)
{
boolean isTrue = true;
String strNum=String.valueOf(num);
int length=strNum.length();
for(int i=0; i<(length/2); i++)
{
if(strNum.charAt(i)!=strNum.charAt(length-1-i))
{
isTrue=false;
break;
}
}
return isTrue;
}