`
zengshaotao
  • 浏览: 788065 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

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 to find corresponding method in 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 position
  • JDBC 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 types
  • Custom  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 java.lang.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 and Encapsulation.  
 

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 overloading
  • Method overriding through inheritance
  • Method overriding through the Java interface


 

Question: 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
  • Defaults


 

Question: Describe the wrapper classes in Java.
Answer: Wrapper class is wrapper around a primitive data type. An instance of a wrapper class contains, or wraps, a primitive value of the corresponding type.

Following table lists the primitive types and the corresponding wrapper classes:

 

Primitive Wrapper
boolean   java.lang.Boolean
byte   java.lang.Byte
char   java.lang.Character
double   java.lang.Double
float   java.lang.Float
int   java.lang.Integer
long   java.lang.Long
short   java.lang.Short
void   java.lang.Void

 
 

 

Question: 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");
  else
    System.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: C

Question: 
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 never change 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 java.lang.Object class. Consider a condition where we use 
if(o.getClass().getName().equals("java.lang.Math")){ }
This method only checks if the classname we have passed is equal to java.lang.Math. The class java.lang.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); //true
System.out.println(test2 instanceof one); //true
System.out.println(Test.getClass().equals(test2.getClass())); //false
}

分享到:
评论

相关推荐

    Java核心技术+基础知识+面试汇总大全 完整PDF版

    这是一套Java核心技术基础使用手册,包含Java 基础核心总结、Java核心基础、Java核心知识、Java 基础面试题总结等,内含最强 Java 核心知识点整理及思维导图,需要的朋友可下载试试! Java是一门编程语言,Java发展...

    JAVA核心面试知识点整理

    JAVA核心面试知识点整理 Java是目前企业开发中最常用的编程语言之一,Java面试知识点涵盖了Java语言的方方面面,包括Java基础知识、Java高级知识、Java设计模式、Java框架等等。以下是Java核心面试知识点的整理。 ...

    JAVA面试核心知识点整理(283页).pdf

    JAVA面试核心知识点整理 本文档旨在为Java开发者提供一个 hệ thống的面试知识点整理,涵盖了Java的核心概念、JVM的工作原理、Java编程语言的基本语法和高级特性等多方面的知识点。下面是对该文档的详细解读。 ...

    JAVA核心面试知识整理.pdf

    Java核心面试知识整理包括了对JVM内存区域、垃圾回收机制、GC算法、JVM类加载机制、Java集合框架以及Java IO/NIO等多个方面的深入讲解。以下是对这些知识点的详细介绍: JVM内存区域:JVM内存区域包括了程序计数器...

    JAVA核心面试知识整理(283页).pdf

    以下是对"JAVA核心面试知识整理(283页).pdf"中提及的部分内容的详细解释: 1. JVM(Java虚拟机) JVM是Java的核心组成部分,它负责解析并执行Java字节码,为Java程序提供了一个运行环境。JVM通过类装载器、执行...

    JAVA面试核心知识点整理283页-2020.pdf.zip

    java面试各大知识点,非常齐全。jvm内存分区,gc算法,类加载机制。并发编程,并发编程各大容器,锁。框架spring mybatis原理,组件介绍。架构设计有设计模式,负载均衡。网络有协议,java 高并发io框架netty。数据...

    JAVA核心面试知识整理

    全面掌握这些Java核心知识将极大地提高你在面试中的竞争力。通过对这些知识点的深入理解和实践,你不仅能够顺利通过面试,还能在实际工作中游刃有余。在准备面试时,建议结合具体的面试题进行针对性练习,以便更好地...

    JAVA核心面试知识整理-最全.zip

    这份“JAVA核心面试知识整理-最全.zip”压缩包提供了全面的Java面试准备材料,涵盖了Java基础、Java虚拟机(JVM)、多线程并发以及算法和Java中间件等多个关键领域。 首先,让我们深入Java基础。这部分通常包括Java...

    JAVA核心知识点整理、面试必备

    这份"JAVA核心知识点整理、面试必备"资料涵盖了Java技术栈的多个重要方面,对于准备面试或提升技术能力非常有帮助。以下是其中涉及的主要知识点的详细解析: 1. **Java多线程并发**: 多线程是Java的重要特性,它...

    【精品干货】JAVA超全知识点总结——核心面试知识汇总(283页).pdf

    以下是对标题和描述中提到的Java核心面试知识的详细解释: 1. **JVM(Java虚拟机)** - JVM是Java平台的核心组成部分,它负责执行字节码,并为程序提供运行时环境。Java的“一次编写,到处运行”特性就依赖于JVM的...

    JAVA核心知识点总结.pdf

    《JAVA核心知识点总结》 Java作为一款广泛应用的编程语言,其核心知识点对于开发者来说至关重要。本资料旨在为准备面试或者系统学习Java的人员提供一个全面的复习框架。以下是对其中部分关键知识点的详细阐述: **...

    互联网公司Java面试题及核心知识点

    内容概要:本书从近一百套最新一线互联网公司面试题中精选而出,涵盖Java架构面试所有技术栈,包 括JVM,Mysql,并发,Spring,Mybatis,Redis,MQ,Zookeeper,Netty, Dubbo,Spring Boot,Spring Cloud,数据结构...

    JAVA核心知识点整理面试宝典

    Java核心知识点整理面试宝典是一份覆盖Java基础知识的面试准备指南,其中包含了Java集合框架、Java虚拟机(JVM)的深入探讨、Java多线程和高并发处理、Java I/O模型及阻塞队列原理等重要知识点。以下是对这些知识点...

    【Java核心知识面试】-阿里Java面试集锦.zip

    【Java核心知识面试】-阿里Java面试集锦.pdf 这份资料是针对Java开发人员,特别是对准备参加阿里巴巴集团面试的求职者所设计的面试指南。它涵盖了Java编程语言的各个方面,旨在帮助求职者全面理解并掌握Java的核心...

    【互联网一线大厂面试+学习指南】 涵盖大部分Java程序员所需要的面试知识点和面试技巧,分享真实面试经历。.zip

    首先,Java程序员面试的核心知识点通常包括以下几个方面: 1. **基础知识**:这是面试的基础,包括但不限于数据类型、运算符、流程控制语句、类与对象、封装、继承、多态等Java语言特性。同时,对异常处理、垃圾...

    Java核心面试知识整理.pdf

    本文档是一份关于Java核心面试知识的整理资料,内容涉及Java虚拟机(JVM)、Java内存模型、垃圾回收机制、Java IO/NIO、Java集合等多个关键知识点。通过对这些知识的梳理,能够帮助Java开发者更好地准备面试,同时也...

Global site tag (gtag.js) - Google Analytics