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面试中最经常被问到的问题1. What is the difference between an Applet and an Application?2. What are java beans?3. What is RMI?4. What gives java it's "write once and run anywhere" nature?5. How does Java inheritance work?6. What are native methods? How do you use them?7. Class A subclass B subclass C. All override foo(). I cast C to A and call foo(). What happens? C an C call A->foo()?8. What does the "static" keyword mean in front of a variable? A method? A class? Curly braces {}?9. How many different types of JDBC drivers are present? Discuss them.10. Does Java have "goto"?11. Why "bytecode"? Can you reverse-engineer the code from bytecode?12. How does exception handling work in Java?13. Does Java have destructors?14. What does the "final" keyword mean in front of a variable? A method? A class?15. Access specifiers: "public", "protected", "private", nothing?3. What is RMI?4. What gives java it's "write once and run anywhere" nature?5. How does Java inheritance work?6. What are native methods? How do you use them?7. Class A subclass B subclass C. All override foo(). I cast C to A and call foo(). What happens? C an C call A->foo()?8. What does the "static" keyword mean in front of a variable? A method? A class? Curly braces {}?9. How many different types of JDBC drivers are present? Discuss them.10. Does Java have "goto"?11. Why "bytecode"? Can you reverse-engineer the code from bytecode?12. How does exception handling work in Java?13. Does Java have destructors?14. What does the "final" keyword mean in front of a variable? A method? A class?15. Access specifiers: "public", "protected", "private", nothing?1. What is the difference between an Applet and an Application?A Java application is made up of a main() method declared as public static void that accepts a string array argument, along with any other classes that main() calls. It lives in the environment that the host OS provides.A Java applet is made up of at least one public class that has to be subclassed from java.awt. Applet. The applet is confined to living in the user's Web browser, and the browser's security rules, (or Sun's appletviewer, which has fewer restrictions).The differences between an applet and an application are as follows:1. Applets can be embedded in HTML pages and downloaded over the Internet whereas Applicatio ns have no special support in HTML for embedding or downloading.2. Applets can only be executed inside a java compatible container, such as a browser or appletvie wer whereas Applications are executed at command line by java.exe or jview.exe.3. Applets execute under strict security limitations that disallow certain operations(sandbox model security) whereas Applications have no inherent security restrictions.4. Applets don't have the main() method as in applications. Instead they operate on an entirely diff erent mechanism where they are initialized by init(),started by start(),stopped by stop() or destroye d by destroy().2. What are java beans?JavaBeans is a portable, platform-independent component model written in the Java programming language, developed in collaboration with industry leaders. It enables developers to write reusable components once and run them anywhere -- benefiting from the platform-independent power of Ja va technology. JavaBeans acts as a Bridge between proprietary component models and provides a seamless and powerful means for developers to build components that run in ActiveX container ap plications.Java beans is very powerful tool you can use in your servlet/JSP bridge. You can use the servlets t o build the bean and can be passed over to the JSP for reading. This provides tight encapsulation o f the data while preserving the sanctity of servlets and JSP.3. What is RMI?RMI stands for Remote Method Invocation. Traditional approaches to executing code on other ma chines across a network have been confusing as well as tedious and error-prone to implement. The nicest way to think about this problem is that some object happens to live on another machine, an d that you can send a message to the remote object and get a result as if the object lived on your lo cal machine. This simplification is exactly what Java Remote Method Invocation (RMI) allows yo u to do.4. What gives java it's "write once and run anywhere" nature?Java is compiled to be a byte code which is the intermediate language between source code and m achine code. This byte code is not platorm specific and hence can be fed to any platform. After bei ng fed to the JVM, which is specific to a particular operating system, the code platform specific m achine code is generated thus making java platform independent.5. How does Java inheritance work?A class can only directly extend one class at a time. Multiple inheritance is only allowed with rega rd to interfaces. A class can implement many interfaces. But a class can only extend one non-interf ace class.6. What are native methods? How do you use them?Native methods are used when the implementation of a particular method is present in language ot her than Java say C, C++.To use the native methods in java we use the keyword nativepublic native method_a()This native keyword is signal to the java compiler that the implementation of this method is in a la nguage other than java.Native methods are used when we realize that it would take up a lot of rework to write that piece o f already existing code in other language to java.7. Class A subclass B subclass C. All override foo(). I cast C to A and call foo(). What happens? C an C call A->foo()?An instance of Class C is of type Class B and A (both). SO you can cast C to A. You CANNOT ca st an instance of A to C.8. What does the "static" keyword mean in front of a variable? A method? A class? Curly braces {}?-- static variables: These are class level variable whose value remain same irrespective of the num ber of instances of the class.-- static methods:These are those methods that can be called without the need for creating the objects of the class i.e . they are class level methods. They can call only static methods. They cannot refer to "this" as the y are not associated with any particular instance.-- static block: These are called before the main is called and are called only once. Subsequent inv ocation of the java program containing static block would not call it again. Hence, they can be use d to load libraries say in native function call.-- Only Inner class could be declared as a "static". This declaration suppress the generation of the r eference to the outer class object. 这意味着:1)为创建一个static内部类的对象,我们不需要一个外部类对象;2)不能从static内部类对象访问一个外部类对象。
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 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!。
IBM英文面试题

ans:In abstract class some methods may contain definition,but in interface every method should be abstract
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.
ans: legacy is something that is old in terms of technology/ system
19.what is main difference hashmap and hastable
ans:Hash table is synchronised
52.what is use of dataflowdiagrams
53.wha t is ip in ur project.
54.what about reception module
———————————————————————————————————————————————————
11.how to u prove that abstrace class cannot instantiate directly.
ans:As they dont have constructor they cant be instantiated
JAVA面试经典试题及答案1

9. String s = new String("xyz"); 创建了几个 String Object. 2个
10. Math.round(11.5)等于多少?Math.round(-11.5)等于多少?
24. 启动一个线程使用 run() 还是 start() ? 启动线程是用 start()方法
25. 构造器 Constructor 是否可以被 override? 构造器不可以被 override
26. 是否可以继承 String 类? 不可以
27. 当一个线程进入一个对象的 synchronized 方法后, 其他线程是否可以进入此对象的其 他方法? 当 线 程 进 入 一 个 对 象 的 synchronize 方 法 后 , 其 他 线 程 可 以 访 问 这 个 对 象 的 非
36. 什么是 Web Service? Web Service 就是为了是原来孤立的站点之间的信息能够相互通讯、共享而提出的一种
接口
37. 多线程有几种实现方法?都是什么?同步有几种实现方法? 多线程有两种实现方法:分别是实现 Thread 类和 Runnable 接口 同步有两种实现方法:分别是 synchronized, wait 和 notify
30. 两个对象值相同(x.equals(y) = = true), 但却有不同的 hashCode, 这句话对不对? 不对,equal 方法必须和 hashCode 方法保持一致,如果实现者没有做到这一点,编译器
也不会报错,但这是一个严重的隐患
31. 当以对象被当做参数传递一个方法后, 此方法可改变这个对象的属性, 并可返回变化的 结果, 那么这里到底是值传递还是引用传递?
32个java基础面试题
第一,谈谈final, finally, finalize的区别。
最常被问到。
第二,Anonymous Inner Class (匿名内部类)是否可以extends(继承)其它类,是否可以implements(实现)interface(接口)?第三,Static Nested Class和Inner Class的不同,说得越多越好(面试题有的很笼统)。
第四,&和&&的区别。
这个问得很少。
第五,HashMap和Hashtable的区别。
常问。
第六,Collection和Collections的区别。
你千万别说一个是单数一个是复数。
第七,什么时候用assert。
API级的技术人员有可能会问这个。
第八,GC是什么?为什么要有GC?基础。
第九,String s = new String(xyz);创建了几个String Object?第十,Math.round(11.5)等於多少? Math.round(-11.5)等於多少?第十一,short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错?面试题都是很变态的,要做好受虐的准备。
第十二,sleep()和wait()有什么区别?搞线程的最爱。
第十三,Java有没有goto?很十三的问题,如果哪个面试的问到这个问题,我劝你还是别进这家公司。
第十四,数组有没有length()这个方法? String有没有length()这个方法?第十五,Overload和Override的区别。
Overloaded的方法是否可以改变返回值的类型?常问。
第十六,Set里的元素是不能重复的,那么用什么方法来区分重复与否呢?是用==还是equals()?它们有何区别?第十七,给出一些你最常见到的runtime exception。
如果你这个答不出来,面试的人会认为你没有实际编程经验。
第十八,error和exception有什么区别?第十九,List, Set, Map是否继承自Collection接口?第二十,abstract class和interface有什么区别?常问。
java_swing面试题目(3篇)
第1篇一、Java Swing基本概念1. 什么是Java Swing?答:Java Swing是一种用于创建图形用户界面的库,它是Java语言的一个扩展,允许开发者创建具有丰富视觉效果的桌面应用程序。
2. Swing的组件有哪些?答:Swing组件包括基本组件(如按钮、标签、文本框等)、容器组件(如面板、窗口、滚动条等)、特殊组件(如树、表格等)。
3. Swing与AWT的区别是什么?答:Swing是基于Java的,而AWT是基于本地平台的。
Swing组件在不同平台上表现一致,而AWT组件在不同平台上可能有所不同。
Swing运行速度较慢,但提供了更多功能和更好的用户体验。
二、Swing基本组件1. 如何创建一个按钮,并设置其文本和字体?答:使用JButton类创建按钮,并设置其文本和字体。
```javaJButton button = new JButton("按钮");button.setFont(new Font("宋体", Font.PLAIN, 12));```2. 如何获取并设置文本框中的文本?答:使用JTextField类创建文本框,并通过getText()和setText()方法获取和设置文本。
```javaJTextField textField = new JTextField();String text = textField.getText(); // 获取文本textField.setText("新文本"); // 设置文本```3. 如何使用单选按钮(JRadioButton)实现多选?答:使用JRadioButton类创建单选按钮,并使用ButtonGroup类将它们分组。
```javaJRadioButton radioButton1 = new JRadioButton("选项1");JRadioButton radioButton2 = new JRadioButton("选项2");ButtonGroup buttonGroup = new ButtonGroup();buttonGroup.add(radioButton1);buttonGroup.add(radioButton2);```4. 如何使用复选框(JCheckBox)实现多选?答:使用JCheckBox类创建复选框,它们之间互不影响。
java面试题之十一:WebService部分
java⾯试题之⼗⼀:WebService部分⼗⼀. webservice 部分1、WEB SERVICE 名词解释。
JSWDL 开发包的介绍。
JAXP、JAXM 的解释。
SOAP、UDDI,WSDL解释。
Web ServiceWeb Service 是基于⽹络的、分布式的模块化组件,它执⾏特定的任务,遵守具体的技术规范,这些规范使得Web Service 能与其他兼容的组件进⾏互操作。
JAXP(Java API for XML Parsing) 定义了在Java 中使⽤DOM, SAX, XSLT 的通⽤的接⼝。
这样在你的程序中你只要使⽤这些通⽤的接⼝,当你需要改变具体的实现时候也不需要修改代码。
JAXM(Java API for XML Messaging) 是为SOAP 通信提供访问⽅法和传输机制的API。
WSDL 是⼀种XML 格式,⽤于将⽹络服务描述为⼀组端点,这些端点对包含⾯向⽂档信息或⾯向过程信息的消息进⾏操作。
这种格式⾸先对操作和消息进⾏抽象描述,然后将其绑定到具体的⽹络协议和消息格式上以定义端点。
相关的具体端点即组合成为抽象端点(服务)。
SOAP 即简单对象访问协议(Simple Object Access Protocol),它是⽤于交换XML 编码信息的轻量级协议。
UDDI 的⽬的是为电⼦商务建⽴标准; UDDI 是⼀套基于Web 的、分布式的、为Web Service提供的、信息注册中⼼的实现标准规范,同时也包含⼀组使企业能将⾃⾝提供的Web Service注册,以使别的企业能够发现的访问协议的实现标准。
2、CORBA 是什么?⽤途是什么?CORBA 标准是公共对象请求代理结构(Common Object Request Broker Architecture),由对象管理组织(Object Management Group,缩写为OMG)标准化。
它的组成是接⼝定义语⾔(IDL), 语⾔绑定(binding:也译为联编)和允许应⽤程序间互操作的协议。
恩士迅java面试英文题
恩士迅java面试英文题Enson Java Interview English Questions1. What is Java?Java is a high-level, object-oriented programming language developed by Sun Microsystems (now owned by Oracle) in 1995. It is known for its platform independence, which means that Java programs can run on any device or operating system that has a Java Virtual Machine (JVM). Java is widely used for creating web applications, mobile applications, desktop software, and enterprise solutions.2. What are the main features of Java?Java has several key features that make it popular among developers:- Object-oriented: Java follows the principles ofobject-oriented programming (OOP), allowing developers to create reusable and modular code.- Platform independence: Java's 'write once, run anywhere' approach allows programs to be run on any device with a JVM, making it highly portable.- Memory management: Java uses automatic garbage collection, freeing developers from managing memory manually. - Multi-threading: Java supports concurrent programmingwith its built-in support for threads, allowing multiple tasks to run simultaneously.- Security: Java provides a secure environment with its built-in security features, such as sandboxing and permission-based access control.3. What is the difference between JDK and JVM?JDK (Java Development Kit) and JVM (Java Virtual Machine) are both essential components of the Java platform, but they serve different purposes.- JDK: JDK is a software development kit that provides tools and libraries necessary for Java development. It includes the Java compiler, debugger, and other utilities required to write, compile, and run Java programs.- JVM: JVM is a runtime environment that executes Java bytecode. It interprets the compiled Java code and converts it into machine code that can be understood by the underlying operating system. JVM also handles memory management and provides various runtime services.4. What is the difference between an abstract class and an interface?- Abstract class: An abstract class is a class that cannot be instantiated and is typically used as a base class for otherclasses. It can contain both abstract and non-abstract methods. Subclasses of an abstract class must implement its abstract methods. An abstract class can also have fields and constructors.- Interface: An interface is a collection of abstract methods and constants. It cannot be instantiated and is used to define a contract for implementing classes. A class can implement multiple interfaces, but it can only extend a single class. Interfaces are used to achieve multiple inheritance in Java.5. What are the different types of exceptions in Java? Java has two types of exceptions: checked exceptions and unchecked exceptions.- Checked exceptions: These are exceptions that are checked at compile-time. The developer must either handle these exceptions using try-catch blocks or declare them in the method signature using the 'throws' keyword. Examples of checked exceptions include IOException and SQLException.- Unchecked exceptions: These are exceptions that are not checked at compile-time. They are subclasses of RuntimeException and Error classes. Unchecked exceptions do not need to be declared or caught explicitly. Examples ofunchecked exceptions include NullPointerException and ArrayIndexOutOfBoundsException.These are just a few sample questions that can be asked during a Java interview. It is important to remember that the depth and complexity of questions may vary depending on the level of the position being applied for. It is advisable to thoroughly prepare and revise various topics related to Java programming to increase the chances of success in a Java interview.。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
英文Java tm试题Question: What is transient variable?Answer: Transient variable 臼n't be serialize. For example if a variable is declared as transient in a Serializable c1ass and the c1ass is written to an ObjectStream,the value of the variable can't be wn忧en to the stream instead when the c1ass is retrieved from the ObjectStream the value of the variable becomes nullQuestion: Name the containers which uses Border Layout as their default layout?Answer: Containers which uses Border Layout as their default are: window,Frame and Dialogc1asses.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. Synchronizationprevents such type of data corruptionE.g. Synchronizing a function:public synchronized void Methodl 0 {j j Appropriate method-related code.E.g. Synchronizing a block of code inside a function:public myFunction O{synchronized (this) {j j Synchronized code here.Question: What is Collection API?Answer: The Collection API is a set of c1asses and interfaces that support operation on collectionsof objects. These classes and interfaces are more flexi.ble,more powerfu,lthe vectors,arrays,and hashtables if e仔'ectively replaces.and more regular thanExample of c1asses: HashSet,HashMap,Array List,LinkedList,TreeSet and TreeMap. Example of interfaces: Collection,5时,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 similaritiesjdifference between an Abstract c1ass and Interface? Answer: Differences are as follows:Interfaces provide a form of multiple inheritance. A class can extend only one other classInterfaces 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 c lass testAbstractClass { protected String myString; public String getMγStringO {return myString;public abstract string anyAbstractFunctionO;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 samplelnterface {public void functionOneO;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 exceptionQuestion: 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 OptionalPackage API,and provides inductrial-strength database computing capabilitiesNew 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 position JDBC 2.0 Core API provides the Batch Updates functionality to the java applicationsJava 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 fromng.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 OOPSAnswer: There are three main principals of oops which are called Polymorphism,Inheritance andQuestion: 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 beexplained as "one interface,multiple methods".Question: Explain the different forms of Polymorphism.Answer: From a practical programming viewpoint,polymorphism exists in three distinct forms inJava: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:Public Protected Private DefaultsQuestion: Describe the wrapper classes in Java.Answer: Wrapper class is wrapper around a primitive data type. An instance of a wrapper classFollowing table lists the primitive types and the corresponding wrapper classes:Primitive Wrapperboolean java .lang.Boolean byte j ava .lang.Bytechar java .lang.Character double ng.Double float ng.Floatint ng.lnteger long java .lang.Long short ng.Short void ngV oidQuestion: 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.printl叫"Equal");What is the result?A. The output is equal?br>causes compilation to fall.B. The output in not Equal?br>C.An error at " if (x =γ)"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 statickeyword 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 sta内s i.e. it is created before the instance iscreated 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 asint then it's initial value is by default zero,when declared boolean its default value is false andnull 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 7Answer: instanceof is a operator ,not a function while getClass is a method of ng.Objectclass. Consider a condition where we use if(o.getClassO.getNameO.equals("java.Iang.Math")){ } This method only checks if the classname we have passed is equal to java .lang.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. getClassO method returns the runtime class of an object. It fetches thejava instance of the given fully qualified type name. The code we have written is not necessary,because we should not compare getClass.getNameO. 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 us.e 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 getClassO 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 TwoO;one test2 = new Three();System.out.println(testilnstanceof one);//trueSystem.out.println(test2 instanceof one);//trueSystem.out.println(Test.get ClassO.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 inheri tance. 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.gcO. JVM does not guarantee that GCwill 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 waitOA. 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 notifyAII() call. The method waitO 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 mainO 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 CLASSPATHenvironment 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 mainO,you could test it from a commandprompt 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 equalsO?A. I'd use the method equalsO to compare the values of the 5trings and the == to check if two variables point at the same instance of a 5tring object.* Q15. D oes it matter in what order catch statements for FileNotFoundException andIOExceptipon 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:5tring a=null;if (a!=null && a.lengthO>10) {...}A. A single ampersand here would lead to a 队1ullPointerException* 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 invokeLaterObe used?A. This method is used to ensure that 5wing components are updatedthrough 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.myMethodO; To call a constructor of the superclass ,just write superO;in the first line of the subclass's constructor.For senior-Ievel developers:忡Q21.What's the difference between a queue and a stack?A. 5tacks works by last-in-first-out rule(LlFO),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. 50 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 equalsO of an object,which other method you might also consider?A. hashCodeO忡Q26. You are planning to do an indexed search in a list of objects. Which of the two Java collections should you use:Array List 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 cloneO.忡Q28. How can you minimize the need of garbage collection and make the memory use more effective?e 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 notifyO or notifyAIIO. 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 SYS-CON川/. Ask yourquestions 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 interface1O.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 stringbu仔er.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.2 1.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 functions26.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 wrok34.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.1on linux.39.why you use struts framework in ur project.ans:lnterface has only method declarations but no defn10.what is differenec between abstract class and interfaceans:ln 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 stringbu仔er. ans:Strings are immutable where as string buffer can be modified13.what is immutable ans: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 50rtfunction SelectTextSort(obj) { // sort by text var N=obj.options.length;for (var i=O;i<N-1;i++) {for (var j=i吐;j<N;j++) {if ( obj.options[i].te对> obj.optionsÜ].text ) {var i1= (obj.options[i].selected == true ) ? true : false var j1= (obj.options[j].selected == true ) ? true : false var q1= obj.options[j].text;var q2 = obj.options[j].value; obj.optionsÜ].text = obj.options[i]坦xt; 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 : false obj.options[j].selected = (i1&& true ) ? true : falsereturn true16.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 hastable ans:Hash table is synchronised20.what is main difference between arraylist and vectorans:Vector is synchronised21.what is struts framework.22.what are distributed techonologiesdistributed 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. Oivision 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 jdbcans:Connecting to OB from java program requires JOBC27.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 it30.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 theProject 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 oopsans:Abstraction,polymorphism,encapsulation,inheritance47.why u choose m时-2 architecture.ans:ln MVC-2 controller is servlet rather than JSP which makes it efficient48.what is implicit object.ans:lmplicit 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。