一份面试题

1、  求下列代码执行以后expr的值

a)         int a = 8,b = 4;  int expr = a++%++b*2


b)         int expr = 20 / 8 * 8;


c)         int expr = 4 << 2 + 1;


d)         int expr = -4321 >>>30;


e)         int expr = 123 ^ 321 ^ 123;


f)         int a = 255;

int expr = (byte)a + (((byte)a) & 0xff);

g)         int expr = “123454321”.charAt(4) + 2;


h)         Integer a =   new Integer(1234);

Integer b =   new Integer(1234);

boolean expr = a == b;


i)           String func(String s){

return s.length() > 0 ? func(s.substring(1)) + s.charAt(0) : “”;

}

String expr = func(“Gameloft”);

 

2、  知识题

a)         什么是垃圾回收?什么时候触发垃圾回收?如何降低垃圾回收的触发频率?它能保证程序有足够的可用内存吗?


b)        请写出short的取值范围。


c)         什么是混淆(obfuscate)?有什么好处?有哪些工具可以混淆jar文件?


d)        什么是状态机?游戏开发中有那些地方能用到状态机?


e)         请根据你的知识,对以下计算机名次进行尽量简单的描述:

                         i.              J2ME


                       ii.              Python


                     iii.              Ant


                     iv.              Javac


                       v.              Subversion


                     vi.              OpenGL


f)         请列出你心目中一名优秀员工所应该具备的品质,并按重要程度排序


3、  分析以下程序:

const [j2me1]SCREEN_WIDTH = 176;

const [j2me2]TEXTWORD_SPACE = 3;

public static void DrawString(String strText,int posX,int posY,int flagX){

         int width = GetTextWidth(strText);

         int x,int [j2me3]y = posY;

         if(flagX > 0){

               x = 0;

         }

         else if(flagX == 0){

               x = (SCREEN_WIDTH – width) / 2;

         }

         else{

               x = SCREEN_WIDTH – width;

         }

         x += posX;

byte [j2me4]charTemp;

         for(int i = 0;i <=[j2me5] strText.length();i++){

               charTemp = strText.charAt(i);

               if(charTemp < ‘!’ | charTemp > ‘z’){

                       x += TEXTWORD_SPACE;

                       continue;

               }

               x += DrawCharacter(charTemp,x,y);

         }

}

问题:

1)        请尽量找出程序中的错误,直接标注在上面。

2)        请解释参数flagX的作用


3)        请推测函数DrawCharater的返回值有什么意义?


4、  应用题

a)         写一个函数判断两个圆是否相交,并尽量优化运行速度。

bool IsOverlapped(int x1,int y1,int r1,int x2,int y2,int r2)


b)        写一个函数去掉一个字符串中单词间多余的空格,使得相邻两个单词间有且只有一个空格。例如当输入字符串是“Hello!_ _Game_programming_ _world!”时,调用该函数后字符串变为“Hello!_Game_programming_world!”。


c)         假定屏幕的像素宽度为screenWidth,写一个函数计算一个字符串需要分成几行显示。

要求:

1、每行应尽可能多地显示字符,但不能有字符部分或完全显示在屏幕外。超过部分的字符换下一行显示。

       2、每个字符的像素宽度不一样,每个字符的像素宽度不一样。用int GetCharWidth(char c)获得每个字符的像素宽度。


5、  把以下段落翻译成中文

a)         An integral approach to code documentation is to write the code so that it documents itself.In other words,the code should be naturally readable in such a way as to make it easy to understand .This is accomplished by proper naming conventions and statement formatting.


b)         Collections are the data structures that are most easily altered for performance-tuning purposes. Using the correct or most appropriate collection class can improve performance with little change to code. For example, if a large ordered collection has elements frequently deleted or inserted throughout it, it usually can provide better performance if based on a linked list rather than an array. On the other hand, a static(unchanging) collection that needs to be accessed by index performs better with an underlying implementation that is an array.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值