Java 英文面试题

合集下载

java经典面试题汇总

java经典面试题汇总

Java基础方面:1、作用域public,private,protected,以及不写时的区别答:区别如下:作用域当前类同一package 子孙类其他packagepublic √√√√protected √√√ ×friendly √√ × ×private √ × × ×不写时默认为friendly2、Anonymous Inner Class (匿名内部类) 是否可以extends(继承)其它类,是否可以implements(实现)interface(接口)答:匿名的内部类是没有名字的内部类。

不能extends(继承) 其它类,但一个内部类可以作为一个接口,由另一个内部类实现3、Static Nested Class 和 Inner Class的不同答:Nested Class (一般是C++的说法),Inner Class (一般是JA V A的说法)。

Java内部类与C++嵌套类最大的不同就在于是否有指向外部的引用上。

注:静态内部类(Inner Class)意味着1创建一个static内部类的对象,不需要一个外部类对象,2不能从一个static内部类的一个对象访问一个外部类对象4、&和&&的区别答:&是位运算符,表示按位与运算,&&是逻辑运算符,表示逻辑与(and)5、Collection 和 Collections的区别答:Collection是集合类的上级接口,继承与他的接口主要有Set 和List.Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作6、什么时候用assert答:assertion(断言)在软件开发中是一种常用的调试方式,很多开发语言中都支持这种机制。

在实现中,assertion就是在程序中的一条语句,它对一个boolean表达式进行检查,一个正确程序必须保证这个boolean表达式的值为true;如果该值为false,说明程序已经处于不正确的状态下,系统将给出警告或退出。

经典java面试英文题

经典java面试英文题

1.What is the result when you compile and run the following code?public class Test{public void method(){for(int i=0;i<3;i++){System.out.print(i);}System.out.print(i);}}result: compile error分析:i是局部变量。

for循环完成后,i的引用即消失。

2.What will be the result of executing the following code?Given that Test1 is a class.class Test1{public static void main(String[] args){Test1[] t1 = new Test1[10];Test1[][] t2 = new Test1[5][];if(t1[0]==null){t2[0] = new Test1[10];t2[1] = new Test1[10];t2[2] = new Test1[10];t2[3] = new Test1[10];t2[4] = new Test1[10];}System.out.println(t1[0]);System.out.println(t2[1][0]);}}result:null null分析:new数组后,数组有大小,但值为null3.What will happen when you attempt to compile and run the following code? class Base{int i = 99;public void amethod(){System.out.println("Base.method()");}Base(){amethod();}}public class Derived extends Base{int i = -1;public static void main(String args[]){Base b = new Derived();System.out.println(b.i);b.amethod();}public void amethod(){System.out.println("Derived.amethod()");}}result:Derived.amethod()99Derived.amethod()解释:Derived 重写了Base的amethod方法。

JAVA试题英文版(答案)

JAVA试题英文版(答案)

一.Which two demonstrate an “is a” relationship? (Choose Two)A. public interface Person { }//语法错了public class Employee extends Person { }B. public interface Shape { }//语法错了public class Employee extends Sha pe { }C. public interface Color { }//语法错了public class Employee extends Color { }D. public class Species { }public class Animal{private Species species;}E. interface Component { }Class Container implements Component (Private Component[ ] children;二.which statement is true?A. An anonymous inner class may be declared as finalB. An anonymous inner class can be declared as privateC. An anonymous inner class can implement mutiple interfacesD. An anonymous inner class can access final variables in any enclosing scope (不能)E. Construction of an instance of a static inner class requires an instance of the encloing outer class构造一个静态的内部类对象需要构造包含它的外部类的对象三. Given:1. package foo;2.3. public class Outer (4. public static class Inner (5. )6. )Which statement is true?A. An instance of the Inner class can be constructed with “new Outer.Inner ()”B. An instance of the inner class cannot be constructed outside of package foo他们都是public的,只要在外部import就行C. An instance of the inner class can only be constructed from within the outer classD. From within the package bar, an instance of the inner class can be constructed with “new inner()”四.Exhibit(展览、陈列):1 public class enclosinggone{2 public class insideone{}3 }4 public class inertest{5 public static void main (String[] args){6 enclosingone eo = new enclosingone();7 //insert code here8 }}Which statement at line 7 constructs an instance of the inner class?A. InsideOne ei = eo.new InsideOne(); 写程序试出来B. Eo.InsideOne ei = eo.new InsideOne();C InsideOne ei = EnclosingOne.new InsideOne();D.EnclosingOne InsideOne ei = eo.new InsideOne();五.1) interface Foo{2) int k=0;3) }4) public class Test implements Foo{5) public static void main(String args[]){6) int i;7) Test test =new Test();8) i=test.k;9) i=Test.k;10) i=Foo.k;11) }12) }What is the result?A. Compilation succeeds.B. An error at line 2 causes compilation to fail.C. An error at line 9 causes compilation to fail.D. An error at line 10 causes compilation to fail.E. An error at line 11 causes compilation to fail.六.//point Xpublic class Foo{public static void main(String[] args){PrintWriter out=new PrintWriter(new java.io.OutputStreamWriter(System.out),true); out.println("Hello");}}which statement at point X on line 1 allows this code to compile and run?在point X这个位置要填入什么代码才能使程序运行A.import java.io.PrintWriterB.include java.io.PrintWriterC.import java.io.OutputStreamWriterD.include java.io.OutputStreamWriterE.No statement is needed本来两个都要import,但是后者OutputStreamWriter指定了包结构java.io.OutputStreamWriter七.what is reserved words in java? 保留字而非关键字A. runB.defaultC. implementD. import八. which three are valid declaraction of a float?(float作为整数是可以的,其余几个都是double)A. float foo=-1;B. float foo=1.0;C. float foo=42e1;D. float foo=2.02f;E. float foo=3.03d;F. float foo=0x0123;九. Given:8. int index = 1;9. boolean[] test = new boolean[3]; (数组作为对象缺省初始化为false)10. boolean foo= test [index];What is the result?A. foo has the value of 0B. foo has the value of nullC. foo has the value of trueD. foo has the value of falseE. an exception is thrownF. the code will not compile十. Given:1. public class test(2. public static void main(String[]args){3. String foo = args [1];4. String foo = args [2];5. String foo = args [3];6. }7. }And the command line invocation:Java TestWhat is the result?A. baz has the value of “”B. baz has the value of nullC. baz has the value of “red”D. baz has the value of “blue”E. bax has the value of “green”F. the code does not compileG. the program throws an exception(此题题目出错了,重复定义了变量foo,如果没有重复的话,应选G,因为只传递了0-2三个数组元素,而题目中需要访问args [3],所以会抛出数组越界异常)十一.int index=1;int foo[]=new int[3];int bar=foo[index]; //bar=0int baz=bar+index; //baz=1what is the result?A. baz has a value of 0B. baz has value of 1C. baz has value of 2D. an exception is thrownE. the code will not compile十二.1)public class Foo{2)public static void main(String args[]){3)String s;4)System.out.println("s="+s);5)}6)}what is the result?A. The code compiles and “s=” is printed.B. The code compiles and “s=null” is printed.C. The code does not compile because string s is not initialized.D. The code does not compile because string s cannot be referenced.E. The code compiles, but a NullPointerException is thrown when toString is called.十三. Which will declare a method that forces a subclass to implement it?(谁声明了一个方法,子类必须实现它)A. public double methoda();B. static void methoda (double d1) {}C. public native double methoda();D. abstract public void methoda();E. protected void methoda (double d1){}十四.You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access modifier that will accomplish this objective?(你希望子类在任何包里都能访问父类,为完成这个目的,下列哪个是最严格的访问权限)A. PublicB. PrivateC. ProtectedD. TransientE. No access modifier is qualified十五. Given:1. abstract class abstrctIt {2. abstract float getFloat ();3. )4. public class AbstractTest extends AbstractIt {5. private float f1= 1.0f;6. private float getFloat () {return f1;}7. }What is the result?A. Compilation is successful.B. An error on line 6 causes a runtime failure.(抛出实时异常)C. An error at line 6 causes compilation to fail.D. An error at line 2 causes compilation to fail.(子类覆盖父类方法的时候,不能比父类方法具有更严格的访问权限)十六. Click the exhibit button:1. public class test{2. public int aMethod(){3. static int i=0;4. i++;5. return I;6. }7. public static void main (String args[]){8. test test = new test();9. test.aMethod();10. int j = test.aMethod();11. System.out.printIn(j);12. }13. }(局部变量不能声明为静态)What is the result?A. Compilation will fail.B. Compilation will succeed and the program will print “0”.C. Compilation will succeed and the program will print “1”.D. Compilation will succeed and the program will print “2”.十七.1) class Super{2) public float getNum(){return 3.0f;}3) }4)5) public class Sub extends Super{7) }which method, placed at line 6, will cause a compiler error?A. public float getNum(){return 4.0f;}B. public void getNum(){} 返回值类型不同不足以构成方法的重载C. public void getNum(double d){}D. public double getNum(float d){return 4.0d;}十八. Which declaration prevents creating a subclass of an outer class?A.static class FooBar{}B.pivate class Foobar{}C.abstract class FooBar{}D.final public class FooBar{}E.final abstract class FooBar{} 抽象类不能声明为final十九. byte[] array1,array2[]byte array3[][]byte[][] array4if each has been initialized, which statement will cause a compile error?A. array2 = array1;B. array2 = array3;C. array2 = array4;D. both A and BE. both A and CF. both B and C(一维数组和二维数组的区别)二十.class Super{public int i=0;public Super(String text){i=1;}public class Sub extends Super{public Sub(String text){i=2;}public static void main(String args[]){Sub sub=new Sub("Hello");System.out.println(sub.i);}}what is the result?A. compile will failB. compile success and print "0"C. compile success and print "1"D. compile success and print "2"子类总要去调用父类的构造函数,有两种调用方式,自动调用(无参构造函数),主动调用带参构造函数。

【推荐】干java的用英语咋介绍自己-优秀word范文 (12页)

【推荐】干java的用英语咋介绍自己-优秀word范文 (12页)

本文部分内容来自网络整理,本司不为其真实性负责,如有异议或侵权请及时联系,本司将立即删除!== 本文为word格式,下载后可方便编辑和修改! ==干java的用英语咋介绍自己篇一:英文面试自我介绍英语面试指南Problem solver 解决问题能手 Creative thinker 充满创意Accurate 小心谨慎Team player 合群英文面试自我介绍Good morning, my name is Alan Turing, and my Chinese name is Tan Haihui; it is really a great honor to have this chance for the interview. I would like to answer whatever you may ask, and I hope I can make a good performance today.Now I will introduce myself briefly, I am 24 years old, and born in Sichuan province. I’m senior right now, studying in SichuanUniversity of Science & Engineering, my major is Computer Science & Technology, and I’ll get Bachelor Degree this year. Till Now, I’ve got almost 1 year working experience as a development engineer in Sichuan JiuYuanYinHai Company.I’m open-minded, have many interests like basketball, reading, travelling and especially in engineering such as software programing. That’s why I choose this kind of job as my career.Ok, that’s all. Thank you very much.如何用英语介绍自己的工作经验I: Please tell me your present job. (What’s your work experience)A: I am working in a software company as I mentioned before. My present job is Java programming, and I am looking for a new job which is morechallenging and better development.I: Have you done any successful cases in this field?Yes, I have worked in this field for almost 1 year. I’ll getBachelor Degree and graduate in Computer Science. And I used to workin a large, comp lex enterprise level applications. I’m really proficient in java programming and have a deep understanding in some database, such as oracle & mysql and I also know a little bit of SQL server. People person 与人相处融洽 Organized 组织力高I: What qualifications do you have that make you feel you will be successful in your field?First, I think my technical background is helpful. I have enough knowledge in Java programming. Secondly, I continue to learn thelatest knowledge of software development through the network. Finally, I have enough passion for my work. These qualifications will make me successful in my career.Top 10 Interview Questions1. Tell me about yourself / Please introduce yourself可以部分采用自我介绍2. What were your responsibilities in work / project? -I mainly focus on the programming, and also do some job in testing, submitting Bug and regression testing.3. What did you like or dislike about your previous job? -I enjoyed the people I worked with. It was a friendly and funatmosphere and I actually enjoyed going to work each morning. I felt the leadership team was great as well. They knew all of theiremployees on a first name basis and tried to make those personal connections. One of the reasons I am leaving is that I felt I was not challenged enough at the job.I feel my can be better utilized elsewhere, where my capabilities are more recognized and there is th(来自: : 干java的用英语咋介绍自己 )e opportunity for growth.4. What major challenges and problems did you face? How did youhandle them?你遇到过什么大的困难,并且是怎么解决的?(自己结合自己的情况用英语写出来背过)Well the first project I work with 5 other people as a group leader. The project is about a management system. I response for the backend programing, as a leader I can’t not …5. What is your greatest strength? –I can work well under pressure and I enjoy the wok that challenges me.6. What is your greatest weakness?缺点,如果面试的时候不提,就不要回答了。

java基础面试题(答案)

java基础面试题(答案)
答:
package com.tarena;
import java.util.Random;
public class TestArray {
final static char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h','i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
ቤተ መጻሕፍቲ ባይዱ答:B
3、已知表达式int m [ ] = {0,1,2,3,4,5,6};下面哪个表达式的值与数组下标量总数相等?
A)m.length()B)m.length C)m.length()+1D)m.length-1
答:D
4、已知如下代码:public class Test {long a[]=new long [10];public static void main(String arg[] ){ System.out.print(a[6]); } }请问哪个语句是正确的?

JAVA面试题及思考

JAVA面试题及思考

JAVA⾯试题及思考===========================================学⽽时习之=============================================1.public class Test {public static void main(String[] args) {String str = "123";changeStr(str);System.out.print(str);}public static void changeStr(String str){str = "abc";}}关键词:java内存分配2.public class Test {static boolean foo(char c) {System.out.print(c);return true;}public static void main(String[] args) {int i = 0;for (foo('A'); foo('B') && (i < 2); foo('C')) {i++;foo('D');}}}关键词:c for3.public class B extends A {// here}class A {protected int method1(int a, int b) {return 0;}}//Which two are valid in a class that extends class A? (Choose two)//A. public int method1(int a, int b) { return 0; }//B. private int method1(int a, int b) { return 0; }//C. private int method1(int a, long b) { return 0; }//D. public short method1(int a, int b) { return 0; }//E. static protected int method1(int a, int b) { return 0; }关键词:override , overloadThe public type A must be defined in its own fileCannot reduce the visibility of the inherited method from AThe return type is incompatible with A.method1(int, int)This static method cannot hide the instance method from ADuplicate method method1(int, int) in type A⽅法重载是单个类内部,通常说⽅法调⽤ a. ⽅法名 b. 参数⽅法重写是继承关系中,全部相同,除了 a. ⼦可见度>=⽗可见度 b. ⼦final可终⽌继承4.public class Outer {public void someOuterMethod() {// Line 3}public class Inner {}public static void main(String[] args) {Outer o = new Outer();// Line 8}}// Which instantiates an instance of Inner?// A. new Inner(); // At line 3// B. new Inner(); // At line 8// C. new o.Inner(); // At line 8// D. new Outer.Inner(); // At line 8// E. new Outer().new Inner(); // At line 8关键词:内部类构造⽅法也是⽅法构造⽅法前必须有new 修饰谁调⽤⽅法:实例调⽤实例⽅法new,类调⽤类⽅法static还有⼀种内部类叫静态内部类5.CREATE TABLE zxg(a VARCHAR2(10),b VARCHAR2(10))INSERT INTO zxg VALUES('a',NULL);INSERT INTO zxg VALUES('b','234');INSERT INTO zxg(a,b) VALUES ('c','');INSERT INTO zxg(a,b) VALUES ('d','');SELECT*FROM zxg--1 a--2 b 234--3 c--4 dSELECT*FROM zxg WHERE b LIKE'%'--1 b 234--2 d关键词:LIKE , NULL关于oracle中like ‘%’ 或者 like '%%' 还有 is null ,is not null长度为零的字符串即空字符串varchar2 类型时为 null好⽐调⼀个⽅法的前提是调动者得存在6.//final 是形容词最终的,final 类不可以被继承,final 字段不可以被改变,final⽅法不可以被重写//The type A cannot subclass the final class B//Cannot override the final method from B//The final field A.s cannot be assigned//finally 是副词 try{}catch(){}finally{}//finalize() 是⽅法,垃圾回收机制关键词:final , finally , finalize7.Controlling Access to Members of a ClassAccess LevelsModifier Class Package Subclass Worldpublic Y Y Y Yprotected Y Y Y Nno modifier Y Y N NNprivate Y N N关于package的⼀个问题:package a;package a.b;有⽗⼦关系吗?在a中定义⼀个pckage-private 的类,该类能不能被a.b中的类访问?答案是:不能。

java面试题 英文

java面试题 英文

java面试题英文Java Interview QuestionsIntroduction:In recent years, Java has become one of the most popular programming languages worldwide. Its versatility and wide range of applications have made it a sought-after skill in the IT industry. As a result, job interviews often include a section dedicated to Java. In this article, we will explore some commonly asked Java interview questions and provide detailed explanations and solutions. Whether you are a seasoned developer or preparing for your first Java interview, this article will help you enhance your knowledge and boost your confidence.1. What is Java?Java is a high-level, object-oriented programming language developed by Sun Microsystems. It was designed to be platform-independent, which means Java programs can run on any operating system that has a Java Virtual Machine (JVM). Java consists of a compiler, runtime environment, and a vast library, making it a powerful tool for building a wide range of applications.2. Explain the difference between JDK, JRE, and JVM.JDK (Java Development Kit) is a software package that includes the necessary tools for developing, compiling, and running Java applications. It consists of the Java compiler, debugger, and other development tools.JRE (Java Runtime Environment) is a software package that contains the necessary components to run Java applications. It includes the JVM and a set of libraries required to execute Java programs.JVM (Java Virtual Machine) is a virtual machine that provides an execution environment for Java programs. It interprets the Java bytecode and translates it into machine code that can be executed by the underlying operating system.3. What is the difference between a class and an object?In object-oriented programming, a class is a blueprint or template for creating objects. It defines the properties and behaviors that an object will possess. An object, on the other hand, is an instance of a class. It represents a specific entity or concept and can interact with other objects.4. What are the features of Java?Java is known for its robustness, portability, and security. Some key features of Java include:- Object-oriented: Java follows the object-oriented programming paradigm, allowing developers to build modular and reusable code.- Platform-independent: Java programs can run on any platform that has a JVM, including Windows, Mac, and Linux.- Memory management: Java has automatic memory management through garbage collection, which helps in deallocating memory occupied by unused objects.- Exception handling: Java provides built-in mechanisms for handling exceptions, ensuring the smooth execution of programs.- Multi-threading: Java supports concurrent programming through multi-threading, allowing programs to perform multiple tasks simultaneously.5. Explain the concept of inheritance in Java.Inheritance is a fundamental concept in object-oriented programming, where a class inherits properties and behaviors from another class, known as the superclass or base class. The class that inherits these properties is called the subclass or derived class. In Java, inheritance allows code reuse, promotes modularity, and enables hierarchical classification of objects.There are several types of inheritance in Java, including single inheritance (where a class inherits from only one superclass) and multiple inheritance (where a class inherits from multiple superclasses using interfaces).6. What is the difference between method overloading and method overriding?Method overloading refers to the ability to have multiple methods with the same name but different parameters within a class. The methods can have different return types or different numbers and types of arguments. The compiler determines which method to call based on the arguments provided during the method call.Method overriding, on the other hand, occurs when a subclass provides a specific implementation for a method that is already defined in its superclass. The signature of the overridden method (name, return type, and parameters)must match exactly with that of the superclass. The overridden method in the subclass is called instead of the superclass's method when invoked.Conclusion:In this article, we have explored some common Java interview questions and provided detailed explanations and solutions. Understanding these concepts will not only help you ace your Java interview but also enhance your overall programming skills. Remember to practice coding and explore real-world scenarios to strengthen your understanding of Java. Good luck with your Java interviews!。

java面试题

java面试题

java面试题大全-基础方面Java基础方面:1、作用域public,private,protected,以及不写时的区别答:区别如下:作用域 当前类 同一package 子孙类 其他packagepublic √ √ √ √protected √ √ √ ×friendly √ √ × ×private √ × × ×不写时默认为friendly2、Anonymous Inner Class (匿名内部类) 是否可以extends(继承)其它类,是否可以implements(实现)interfac 答:匿名的内部类是没有名字的内部类。

不能extends(继承) 其它类,但一个内部类可以作为一个接口,由另一个3、Static Nested Class 和 Inner Class的不同答:Nested Class (一般是C++的说法),Inner Class (一般是JAVA的说法)。

Java内部类与C++嵌套类最大的不4、&和&&的区别答:&是位运算符,表示按位与运算,&&是逻辑运算符,表示逻辑与(and)5、Collection 和 Collections的区别答:Collection是集合类的上级接口,继承与他的接口主要有Set 和List.Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操6、什么时候用assert答:assertion(断言)在软件开发中是一种常用的调试方式,很多开发语言中都支持这种机制。

在实现中,assert 7、String s = new String("xyz");创建了几个String Object答:两个,一个字符对象,一个字符对象引用对象8、Math.round(11.5)等於多少? Math.round(-11.5)等於多少答: Math.round(11.5)==12;Math.round(-11.5)==-11;round方法返回与参数最接近的长整数,参数加1/2后求其9、short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错答:short s1 = 1; s1 = s1 + 1; (s1+1运算结果是int型,需要强制转换类型)short s1 = 1; s1 += 1;(可以10、Java有没有goto答:java中的保留字,现在没有在java中使用11、数组有没有length()这个方法? String有没有length()这个方法答:数组没有length()这个方法,有length的属性。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

英文Java面试题Question: What is transient variable?Answer: Transient variable can't be serialize. For example if a variable is declared as transient in a Serializable class and the class is written to an ObjectStream, the value of the variable can't be written to the stream instead when the class is retrieved from the ObjectStream the value of the variable becomes null.Question: Name the containers which uses Border Layout as their default layout?Answer: Containers which uses Border Layout as their default are: window, Frame and Dialog classes.Question: What do you understand by Synchronization?Answer: Synchronization is a process of controlling the access of shared resources by the multiple threads in such a manner that only one thread can access one resource at a time. In non synchronized multithreaded application, it is possible for one thread to modify a shared object while another thread is in the process of using or updating the object's value. Synchronization prevents such type of data corruption.E.g. Synchronizing a function:public synchronized void Method1 () {// Appropriate method-related code.}E.g. Synchronizing a block of code inside a function:public myFunction (){synchronized (this) {// Synchronized code here.}}Question: What is Collection API?Answer: The Collection API is a set of classes and interfaces that support operation on collections of objects. These classes and interfaces are more flexible, more powerful, and more regular than the vectors, arrays, and hashtables if effectively replaces.Example of classes: HashSet, HashMap, ArrayList, LinkedList, TreeSet and TreeMap.Example of interfaces: Collection, Set, List and Map.Question: Is Iterator a Class or Interface? What is its use?Answer: Iterator is an interface which is used to step through the elements of a Collection.Question: What is similarities/difference between an Abstract class and Interface?Answer: Differences are as follows:Interfaces provide a form of multiple inheritance. A class can extend only one other class. Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.Interfaces are slow as it requires extra indirection to find corresponding method in the actual class. Abstract classes are fast.Similarities:Neither Abstract classes or Interface can be instantiated.Question: How to define an Abstract class?Answer: A class containing abstract method is called Abstract class. An Abstract class can't be instantiated.Example of Abstract class:abstract class testAbstractClass {protected String myString;public String getMyString() {return myString;}public abstract string anyAbstractFunction();}Question: How to define an Interface?Answer: In Java Interface defines the methods but does not implement them. Interface can include constants. A class that implements the interfaces is bound to implement all the methods defined in Interface.Emaple of Interface:public interface sampleInterface {public void functionOne();public long CONSTANT_ONE = 1000;}Question: Explain the user defined Exceptions?Answer: User defined Exceptions are the separate Exception classes defined by the user for specific purposed. An user defined can created by simply sub-classing it to the Exception class. This allows custom exceptions to be generated (using throw) and caught in the same way as normal exceptions.Example:class myCustomException extends Exception {// The class simply has to exist to be an exception}Question: Explain the new Features of JDBC 2.0 Core API?Answer: The JDBC 2.0 API includes the complete JDBC API, which includes both core and Optional Package API, and provides inductrial-strength database computing capabilities.New Features in JDBC 2.0 Core API:Scrollable result sets- using new methods in the ResultSet interface allows programmatically move the to particular row or to a position relative to its current positionJDBC 2.0 Core API provides the Batch Updates functionality to the java applications.Java applications can now use the ResultSet.updateXXX methods.New data types - interfaces mapping the SQL3 data typesCustom mapping of user-defined types (UTDs)Miscellaneous features, including performance hints, the use of character streams, full precision for java.math.BigDecimal values, additional security, and support for time zones in date, time, and timestamp values.Question: Explain garbage collection?Answer: Garbage collection is one of the most important feature of Java. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. User program cann't directly free the object from memory, instead it is the job of the garbage collector to automatically free the objects that are no longer referenced by a program. Every class inherits finalize() method from ng.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use. I Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected.Question: How you can force the garbage collection?Answer: Garbage collection automatic process and can't be forced.Question: What is OOPS?Answer: OOP is the common abbreviation for Object-Oriented Programming.Question: Describe the principles of OOPS.Answer: There are three main principals of oops which are called Polymorphism, Inheritance andEncapsulation.Question: Explain the Encapsulation principle.Answer: Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.Question: Explain the Inheritance principle.Answer: Inheritance is the process by which one object acquires the properties of another object.Question: Explain the Polymorphism principle.Answer: The meaning of Polymorphism is something like one name many forms. Polymorphism enables one entity to be used as as general category for different types of actions. The specific action is determined by the exact nature of the situation. The concept of polymorphism can be explained as "one interface, multiple methods".Question: Explain the different forms of Polymorphism.Answer: From a practical programming viewpoint, polymorphism exists in three distinct forms in Java:Method overloadingMethod overriding through inheritanceMethod overriding through the Java interfaceQuestion: What are Access Specifiers available in Java?Answer: Access specifiers are keywords that determines the type of access to the member of a class. These are:PublicProtectedPrivateDefaultsQuestion: Describe the wrapper classes in Java.Answer: Wrapper class is wrapper around a primitive data type. An instance of a wrapper classcontains, or wraps, a primitive value of the corresponding type.Following table lists the primitive types and the corresponding wrapper classes:Primitive Wrapperboolean ng.Booleanbyte ng.Bytechar ng.Characterdouble ng.Doublefloat ng.Floatint ng.Integerlong ng.Longshort ng.Shortvoid ng.VoidQuestion: Read the following program:public class test {public static void main(String [] args) {int x = 3;int y = 1;if (x = y)System.out.println("Not equal");elseSystem.out.println("Equal");}}What is the result?A. The output is equal?br>B. The output in not Equal?br>C. An error at " if (x = y)" causes compilation to fall.D. The program executes but no output is show on console.Answer: CQuestion: what is the class variables ?Answer: When we create a number of objects of the same class, then each object will share a common copy of variables. That means that there is only one copy per class, no matter how many objects are created from it. Class variables or static variables are declared with the static keyword in a class, but mind it that it should be declared outside outside a class. These variables are stored in static memory. Class variables are mostly used for constants, variable that neverchange its initial value. Static variables are always called by the class name. This variable is created when the program starts i.e. it is created before the instance is created of class by using new operator and gets destroyed when the programs stops. The scope of the class variable is same a instance variable. The class variable can be defined anywhere at class level with the keyword static. It initial value is same as instance variable. When the class variable is defined as int then it's initial value is by default zero, when declared boolean its default value is false and null for object references. Class variables are associated with the class, rather than with any object.Question: What is the difference between the instanceof and getclass, these two are same or not ?Answer: instanceof is a operator, not a function while getClass is a method of ng.Object class. Consider a condition where we useif(o.getClass().getName().equals("ng.Math")){ }This method only checks if the classname we have passed is equal to ng.Math. The class ng.Math is loaded by the bootstrap ClassLoader. This class is an abstract class.This class loader is responsible for loading classes. Every Class object contains a reference to the ClassLoader that defines. getClass() method returns the runtime class of an object. It fetches the java instance of the given fully qualified type name. The code we have written is not necessary, because we should not compare getClass.getName(). The reason behind it is that if the two different class loaders load the same class but for the JVM, it will consider both classes as different classes so, we can't compare their names. It can only gives the implementing class but can't compare a interface, but instanceof operator can.The instanceof operator compares an object to a specified type. We can use it to test if an object is an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface. We should try to use instanceof operator in place of getClass() method. Remember instanceof opeator and getClass are not same. Try this example, it will help you to better understand the difference between the two.Interface one{}Class Two implements one {}Class Three implements one {}public class Test {public static void main(String args[]) {one test1 = new Two();one test2 = new Three();System.out.println(test1 instanceof one); //trueSystem.out.println(test2 instanceof one); //trueSystem.out.println(Test.getClass().equals(test2.getClass())); //false}}* Q1. How could Java classes direct program messages to the system console, but error messages, say to a file?.The class System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default, they both point at the system console. This how the standard output could be re-directed:Stream st = new Stream(new FileOutputStream("output.txt")); System.setErr(st); System.setOut(st);* Q2. What's the difference between an interface and an abstract class?A. An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.* Q3. Why would you use a synchronized block vs. synchronized method?A. Synchronized blocks place locks for shorter periods than synchronized methods.* Q4. Explain the usage of the keyword transient?A. This keyword indicates that the value of this member variable does not have to be serialized with the object. When the class will be de-serialized, this variable will be initialized with a default value of its data type (i.e. zero for integers).* Q5. How can you force garbage collection?A. You can't force GC, but could request it by calling System.gc(). JVM does not guarantee that GC will be started immediately.* Q6. How do you know if an explicit object casting is needed?A. If you assign a superclass object to a variable of a subclass's data type, you need to do explicit casting. For example:Object a; Customer b; b = (Customer) a;When you assign a subclass to a variable having a supeclass type, the casting is performed automatically.* Q7. What's the difference between the methods sleep() and wait()A. The code sleep(1000); puts thread aside for exactly one second. The code wait(1000), causes a wait of up to one second. A thread could stop waiting earlier if it receives the notify() or n otifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread.* Q8. Can you write a Java class that could be used both as an applet as well as an application?A. Yes. Add a main() method to the applet.* Q9. What's the difference between constructors and other methods?A. Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.* Q10. Can you call one constructor from another if a class has multiple constructorsA. Yes. Use this() syntax.* Q11. Explain the usage of Java packages.A. This is a way to organize files when a project consists of multiple modules. It also helps resolve naming conflicts when different packages have classes with the same names. Packages access level also allows you to protect data from being used by the non-authorized classes.* Q12. If a class is located in a package, what do you need to change in the OS environment to be able to use it?A. You need to add a directory or a jar file that contains the package directories to the CLASSPATH environment variable. Let's say a class Employee belongs to a package com.xyz.hr; and is located in the file c:\dev\com\xyz\hr\Employee.java. In this case, you'd need to add c:\dev to the variable CLASSPATH. If this class contains the method main(), you could test it from a command prompt window as follows:c:\>java com.xyz.hr.Employee* Q13. What's the difference between J2SDK 1.5 and J2SDK 5.0?A.There's no difference, Sun Microsystems just re-branded this version.* Q14. What would you use to compare two String variables - the operator == or the method equals()?A. I'd use the method equals() to compare the values of the Strings and the == to check if two variables point at the same instance of a String object.* Q15. Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written?A. Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first.* Q16. Can an inner class declared inside of a method access local variables of this method?A. It's possible if these variables are final.* Q17. What can go wrong if you replace && with & in the following code:String a=null; if (a!=null && a.length()>10) {...}A. A single ampersand here would lead to a NullPointerException.* Q18. What's the main difference between a Vector and an ArrayListA. Java Vector class is internally synchronized and ArrayList is not.* Q19. When should the method invokeLater()be used?A. This method is used to ensure that Swing components are updated through the event-dispatching thread.* Q20. How can a subclass call a method or a constructor defined in a superclass?A. Use the following syntax: super.myMethod(); To call a constructor of the superclass, just write super(); in the first line of the subclass's constructor.For senior-level developers:** Q21. What's the difference between a queue and a stack?A. Stacks works by last-in-first-out rule (LIFO), while queues use the FIFO rule** Q22. You can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces?A. Sometimes. But your class may be a descendent of another class and in this case the interface is your only option.** Q23. What comes to mind when you hear about a young generation in Java?A. Garbage collection.** Q24. What comes to mind when someone mentions a shallow copy in Java?A. Object cloning.** Q25. If you're overriding the method equals() of an object, which other method you might also consider?A. hashCode()** Q26. You are planning to do an indexed search in a list of objects. Which of the two Java collections should you use:ArrayList or LinkedList?A. ArrayList** Q27. How would you make a copy of an entire Java object with its state?A. Have this class implement Cloneable interface and call its method clone().** Q28. How can you minimize the need of garbage collection and make the memory use more effective?A. Use object pooling and weak object references.** Q29. There are two classes: A and B. The class B need to inform a class A when some important event has happened. What Java technique would you use to implement it?A. If these classes are threads I'd consider notify() or notifyAll(). For regular classes you can use the Observer interface.** Q30. What access level do you need to specify in the class declaration to ensure that only classes from the same directory can access it?A. You do not need to specify any access level, and Java will use a default package access level.The J2EE questions are coming soon. Stay tuned for Yakov Fain on Live . Ask your questions to Yakov on the air!=====================IBM java 英文面试题1.what is oracle.2.what is major differenece oracle8i and oracle9i.4.tell me some thing ur self.5.please tell me about oops.6.what is single inheritance.7.what is multiple inheritance.8.can java support multiple inheritance.9.what is interface.10.what is differenec between abstract class and interface.11.how to u prove that abstrace class cannot instantiate directly.12.what is differenece between string and stringbuffer.13.what is immutable14.how to write a program using sort program.15 how to write a program using unsort program.16.what is legacy.17.what is legacy api18.what is legacy interface.19.what is main difference hashmap and hastable20.what is main difference between arraylist and vector.21.what is struts framework.22.what are distributed techonologies.23.what is advantage and disadvantage of distributed techonologies.24.what is main difference between jsp and servlets.25.what is difference between procedure and functions.26.what is jdbc.27.what are type of drivers.28.what is type 4 driver.29.how to collect requuirements form u r client.30.which process use in ur project.31.what is deployment descriptor.32.what is heirarchy of files in struts.33.please draw struts frame wrok.34.please draw j2ee architecture.35.please draw mvc-2 architecture.36.please draw that how design op module.37.how to find a file on linux.38.how to configure weblogic8.1 on linux.39.why you use struts framework in ur project.40.what is platfrom independent41.what is awt and swing.42.what is heavy wieght components.43.what is feature of weblgoic8.1.44.why you choose application server on linux and database server on aix.45.please tell me about ur project.46.what is major concepts in oops.47.why u choose mvc-2 architecture.48.what is implicit object.49.how many implicit objects in jsp50.why choose weblogic8.1 other than any applicationserver.51.what is water fall model vs sdlc52.what is use of dataflowdiagrams53.wha t is ip in ur project.54.what about reception module—————————————————————————————————————————————————————————1. Oracle is an RDBMS product with DDL and DML from a company called Oracle Inc.2. Difference between 8i and 9i is given in the Oracle site3. Question not available4. Something5. oops is Object Oriented Programming6.what is single inheritance.ans:one class is inherited by only other one class7.what is multiple inheritance.ans:One class inheriting more than one class at atime8.can java support multiple inheritance.ans:No9.what is interface.ans:Interface has only method declarations but no defn10.what is differenec between abstract class and interface.ans:In abstract class some methods may contain definition,but in interface every method should be abstract11.how to u prove that abstrace class cannot instantiate directly.ans:As they dont have constructor they cant be instantiated12.what is differenece between string and stringbuffer.ans:Strings are immutable where as string buffer can be modified13.what is immutableans:Which cant be changed14.how to write a program using sort program.15 how to write a program using unsort program.ans: Both can be done using javascriptThis is for Sortfunction SelectTextSort(obj) { // sort by textvar N=obj.options.length;for (var i=0;i<N-1;i++) {for (var j=i+1;j<N;j++) {if ( obj.options[i].text > obj.options[j].text ) {var i1= (obj.options[i].selected == true ) ? true : falsevar j1= (obj.options[j].selected == true ) ? true : falsevar q1 = obj.options[j].text;var q2 = obj.options[j].value;obj.options[j].text = obj.options[i].text;obj.options[j].value = obj.options[i].value;obj.options[i].text = q1;obj.options[i].value = q2;obj.options[i].selected = (j1 && true ) ? true : falseobj.options[j].selected = (i1 && true ) ? true : false}}}return true}16.what is legacy.17.what is legacy api18.what is legacy interface.ans: legacy is something that is old in terms of technology/ system19.what is main difference hashmap and hastableans:Hash table is synchronised20.what is main difference between arraylist and vector.ans:Vector is synchronised21.what is struts framework.22.what are distributed techonologies.distributed technologies means any technology / s/w program that are having many components in multiple environments that interact with each other depending on the functional requirements and design.23.what is advantage and disadvantage of distributed techonologies.overdependance on single platform / single language is avoided. Application can be built flexible to meet requirements. Division of labour is possible. Best of all the technologies and platforms can be optimally utilized. Complexity of requirements can be reduced.25.what is difference between procedure and functions.'ans:Fuctions can return value ,procedures cant return value26.what is jdbc.ans:Connecting to DB from java program requires JDBC27.what are type of drivers.type1,2,3,429.how to collect requuirements form u r client.is not a job of a technical person. It is better for a BA to do it.30.which process use in ur project.Generally u can say:Project related process: Analysis, Design, Sign-off Documents, Implementation, Integration, Testing, UATWork related process:Technical Design, Work Allocation, Code Review Checklist, Unit Test Form will be prepared by the Project Lead and given to the developer.Developer prepares the Unit Test CaseImplements Code, Performs TestSubmits Code through CVS / VSSSubmits documents along with Release Checklist to the tester / leader.31.what is deployment descriptor.ans:Which contains the infrnmation like which file to be used40.what is platfrom independentans:A language is said to be platform independent if it can be run on any machine with out modifying code41.what is awt and swing.ans:AWT are heavy weight components and swings are light weight components46.what is major concepts in oops.ans:Abstraction,polymorphism,encapsulation,inheritance47.why u choose mvc-2 architecture.ans:In MVC-2 controller is servlet rather than JSP which makes it efficient48.what is implicit object.ans:Implicit objects are a set of Java objects that the JSP Container makes available to developers in each page49.how many implicit objects in jspans:out,page,session,request,response,application,page context,config。

相关文档
最新文档