IT

모든 훌륭한 Java / Java EE 개발자가 대답 할 수있는 질문이 있습니까?

lottoking 2020. 6. 22. 07:28
반응형

모든 훌륭한 Java / Java EE 개발자가 대답 할 수있는 질문이 있습니까? [닫은]


나는 모든 좋은 .Net 개발자가 대답 할 수 있어야하고 질문 의 내용과 접근 방식에 크게 감명을 받았으므로 같은 질문으로 Java / Java EE Developer에 대해이 질문을하고 있습니다.

훌륭한 Java / Java EE 프로그래머가 어떤 질문에 대답 할 수 있다고 생각 하십니까?

이 질문은 사용자별로 다르며 프로그래밍 커뮤니티를 제공하는 것을 목표로하기 때문에 커뮤니티 위키로 표시하고 있습니다.

놀라운 답변을 기대합니다.

편집 : 사람들이 언어에 대해 새로운 것을 배울 수 있도록 의견에 제안 된대로 질문에 대답하십시오.


hashCode ()와 equals ()의 관계는 무엇입니까? 이 방법의 중요성은 무엇입니까? 이를 구현하기위한 요구 사항은 무엇입니까?


세트, 맵 및 목록의 차이점은 무엇입니까?

나는 아직도 전화 인터뷰에서 얼마나 많은 사람들이 이것을 모르는 것에 놀랐습니다.


인터페이스가 여러 인터페이스를 확장 할 수 있습니까?

대부분의 사람들은 java에 다중 상속이 없다는 것을 알고 있기 때문에 "아니오"라고 대답합니다. 그러나 인터페이스는 여전히 여러 인터페이스를 확장 할 수 있지만 클래스는 여러 클래스를 확장 할 수 없습니다. 이것은 다이아몬드 문제로 이어지지 않습니다.

대답은 "아니오"가 "왜, 면접관 물어 안 이 금지 될?". 그런 다음 그것에 대해 생각하기 시작하면 문제가 없음을 인식해야합니다.

그래서 당신은 면접에서 무언가를 스스로 배웠고, 면접관에게 당신이 수업, 사물, 상속, 다형성 등에 대해 추론 할 수 있다는 것을 보여주었습니다. 그것은 실제로 답을 아는 사람은 후보보다 훨씬 낫습니다. 왜 이해


메소드 호출에서 최종 키워드 사용 . 예를 들어 아래 코드에서 메소드 테스트인해 메소드 매개 변수에 최종 규정자를 사용하더라도 컴파일 오류가 발생하지 않는 이유는 무엇입니까?

class Name {
    private String name;

    public Name (String s) {
        this.name = s;
    }

    public void setName(String s) {
        this.name = s;
    }
}

private void test (final Name n) {
    n.setName("test");
}


확실한 것은 문자열 비교입니다. 차이점

String helloWorld = "Hello World";
helloWorld == "Hello World";
"Hello World".equals (helloWorld);


트릭 질문 : Java에서 어떤 종류의 매개 변수가 참조로 전달됩니까?

얼마나 많은 사람들이 여전히 "기본형이 가치에 의해 전달되고, 객체가 기준에 의해 전달됨"만트라를 앵무새 화하는지는 놀랍습니다.


당신은 "좋은", "개발자"라고 말했다. 여기도 2 센트입니다 .. :)

  • "체크 된 예외"는 무엇을 의미합니까?
  • 어느 쪽을 사용하는 것이 더 낫고 언제 : 예기치 않은 조건을 처리하기위한 주장 또는 예외?
  • 왜 String 클래스가 최종적인가? (또는 그렇지 않습니까?;))
  • 클래스의 wait, notify 및 notifyAll 메소드입니까?
  • 왜 스레드 클래스는 최종적이지 않습니까? 왜 스레드를 확장합니까?
  • 왜 두 개의 Date 클래스가 있습니까? 하나는 java.util 패키지와 다른 하나는 java.sql?
  • finally 블록에서 예외가 발생하면 어떻게됩니까? 나머지는 마지막으로 실행됩니까?
  • 가비지 수집기가 있지만 Java 응용 프로그램에서 메모리 누수가 완전히 없습니까? 그렇지 않다면 어떻게됩니까?

J2EE의 경우 :

  • 서블릿에 인스턴스 / 정적 변수를 갖는 것이 좋습니까? 왜 안돼? 그렇다면 "상태"를 어디에 저장합니까?
  • 위의 질문에 계속 : (웹) 응용 프로그램의 "상태"는 무엇입니까?
  • "JSP"에서 DB 연결 생성 / 닫기를 시작하면 어떻게됩니까?
  • JSP 예외를 처리하는 방법은 무엇입니까? 시험 해봐? 흠 .. 다른 게 있습니까?

나는 많은, 많은, 더 많은 것을 생각할 수 있지만 지금은 할 것입니다 :)


String, StringBuffer 및 StringBuilder의 차이점은 무엇입니까?


"배포 설명자가 무엇입니까?"

후보자가 무의식적으로 떨리는 경우 3.0 이전 EJB를 사용한 경험이 있습니다.


많은 질문과 인터뷰는 http://www.techinterviews.com/interview-questions/java 에서 구할 수 있으며 그중 일부를 복사하여 붙여 넣는 데 가치가있는 것은 아닙니다.

아닙니다 . 중요하다고 생각하는 것들을 스스로 편집하는 것은 당신 의 몫 입니다. 개인적으로 저는 항상 두 단계로 진행합니다. 먼저 경험과 기술에 대한 기본 아이디어를 얻는 몇 가지 질문, 문제 해결 상황. 나는 알려진 질문 에 대답 할 수 있다는 것이 당신에게 좋은 또는 나쁜 알 수없는 문제 해결사를 만들어 준다고 확신하지는 않습니다 . 그래서 저는 사람들에게 주어진 문제를 해결하고, 요구 사항을 제시하고, 종이에 쓰지 말고 코드를 작성하도록 요청하고 싶습니다. 나는 그들에게 돌아와서 그들이 어떻게했는지, 코딩 스타일, 제안 된 API를 어떻게 사용했는지 등을 확인할 시간을 준다.

That all being said, my favorite question is "what don't you like about Java?" (in the spirit of this one). It is really a excellent question, it gives you an immediate feedback on how much a candidate has used Java and explored its API and if he just religious about it or not (as the OP wrote).

Update: As suggested by CPerkins, a better wording for the question suggested above might be "What would you most like to see changed in Java?". And indeed, I prefer this way.


What is 'System', 'out', 'println' in System.out.println ? What happens when you call 'put' on HashMap ?


  1. Explain the various access modifiers used in Java. I have had lots of people struggle with this, especially default access.
  2. If you could change one thing about the Java language or platform what would it be? Good developers will have an answer here while those who aren't really interested in development probably don't care.
  3. If their CV says something like they use EJB2.1 then ask about EJB3 to see what they know about it. The best developers will keep up with the latest developments even if they don't use the newer versions.

  • What is the general contract when overriding equals?
  • Is better option prefer lists or arrays?
  • What are the generally accepted naming conventions?
  • How serialization works?
  • How to implement Comparable?
  • What are the advantages of using JDBC's Prepared Statements?
  • What is Java EE?
  • What is a container and what services does it provide?

If you are hiring graduates with Java "experience" a simple question like Write some code that will cause a NullPointerException to be thrown can distinguish which candidates have used Java recently, and didn't just stop when they finished their unit/course.


What will be printed?

public void testFinally(){
    System.out.println(setOne().toString());

}

protected StringBuilder setOne(){
    StringBuilder builder=new StringBuilder();
    try{
        builder.append("Cool");
        return builder.append("Return");
    }finally{
        builder.append("+1");
    }
}

Answer: CoolReturn+1

A bit more difficult:

public void testFinally(){
    System.out.println(setOne().toString());

}

protected StringBuilder setOne(){
    StringBuilder builder=new StringBuilder();
    try{
        builder.append("Cool");
        return builder.append("Return");
    }finally{
        builder=null;  /* ;) */
    }
}

Answer: CoolReturn


What is the difference between an abstract class and an interface? When would you use each of them?

Lots of Java developers don't know this, I asked most people on my computer science course at university and the vast majority could not answer it.


Simple questions such as,

  • What is JRE and JDK?
  • Why does java claim interoperability?

Though these are very basic, many developers do not know the answers. I suggest these be asked before the code-related queries.


Top 5 J2EE/JEE questions

The list of J2EE/JEE middleware questions I have faced is exceptionally long, but here are the top 5 that I have been asked, and have lead to good discussions:

  1. What happens when an MDB encounters an exception that it cannot handle?
    This question usually leads to various interesting discussions about poison messages, error queues, etc.,
  2. Given a JMS Topic, and a few consumers on different JVMs, questions on various scenarios with and without durable consumers.
    This question usually allows me to discuss in terms of when to use durable subscribers, when to use queues, etc.,
  3. If stuck in a situation where accessing a Hibernate/JPA POJO contents leads to exceptions, how would one resolve it?
    This leads to wonderful discussions about lazy loading, rehydrating, etc., It has even lead to comparing and contrasting JPA with Entity beans. I have found it useful to be prepared, and to be clear in concepts.
  4. How could a simple web service be provided?
    Any solution from simple web server based to sophisticated SOAP/REST solutions, and any in between, should be good enough. Also, based on the interviewer, sometimes it leads to very interesting discussions on topics such as some design ideas - WSDL first, doc-style, SOAP intermediaries, etc., It might lead to questions such as listing improvements in JAX-WS over JAX-RPC, or SOAP1.2 over SOAP1.1, answers to which are usually based on how much I remember.
  5. JEE 5 resource injection
    This question is posed in many ways, starting from Service Locator pattern to javax.naming.Context questions.

Another tricky question I find troubling, but have faced many times is, How are dependent libraries packaged into an archive?
or Visibility of various classes in a bundled archive.
If the discussion does not lead to class loader hierarchy of different application servers, resource archives, etc., it is best to resign and move on.

Top 5 core Java questions:

  1. Questions on java.util.collections
    This is the mother of all questions. Once you can effectively land the interviewer in this area, and if you are prepared, the rest of the interview usually stays here. Be sure of knowing Set, List, Map, and the importance of Object.equals() and Object.hashCode() in every implementation of these interfaces.
  2. Refactoring questions
    These are good if the interviewer has an open mind. If the interviewer already has a specific solution in mind, and yours does not match his/hers, you are pretty much doomed. It is best to agree with the answer "I understand other solutions are possible. "
  3. Questions on multi-threading in JDK5, comparing with earlier JDK versions I have found it is best to be prepared with java.util.concurrent package classes. Doug Lea's book has most of the answers.
  4. What's new in JDK1.6/JDK1.7...?
    This is a sure shot question with many interviewers. As much as I hate this, it is best to be prepared. At least remembering a few that I have worked with, and leading the discussion in some other direction, largely and effectively dodges and solves the problem.
  5. Patterns in Java API
    Time and again I have been asked to point out a GoF pattern in the Java API. Better be prepared for this one.

Difference between and web server and a web container


What do you like most / least about Java and why?


why would you override the toString() method?


A more pure Java question:

What is the difference between sleep and wait ? Not many people actually understand how wait is working.

How do you need to handle InterruptedExceptions ?


This is the question I faced in my interview.

Why is main method in Java called as public static void main(String[] args) ?

Answer:

1.main() must be declared public because it is invoked by JVM whenever the program execution starts.JVM doesnot belong to our program package.

Inorder to access main outside the package we have to declare it as public.If we declare it as anything other than public it shows a Runtime Error but not Compilation time error

2.main() must be declared as static because if a method is declared as static then we can call that method outside the class using ClassName.methodName();

class Sample
{
     static void fun()
     {
           System.out.println("Hello");       
     }
}

class Test
{
      public static void main(String[] args)
      {
                Sample.fun();
      }
}

The JVM will first Load the Test class,and will check for the Commandline arguments and calls the main method as Test.main();

3.main() must be declared as void main() because JVM is not expecting any value from main().So,it must be declared as void.

If other return type is provided,the it is a RunTimeError i.e;NoSuchMethodFoundError.

4.main() must have String arguements as arrays because JVM calls main method by passing command line arguement.As they are stored in string array object it is passed as an argument to main().


What is the difference between J2SE and J2EE (or JSE and JEE)?

A developer should be able to point out that the enterprise edition is basically an interface definition (i.e. a specification) which can be implemented by vendors. Whereas the standard edition is an implementation in its own right


How does volatile affect code optimization by compiler?


How about what is a session bean and describe some differences between stateless and stateful session beans.


Write a program to accept two integers and output the largest of two numbers to a file at a location of your choice. Now describe what each statement does.

It's possible to drill down pretty deep starting from the significance of the import statement, right down to abnormal termination


Core: 1. What are checked and unchecked exceptions ? 2. While adding new exception in code what type (Checked/Unchecked) to use when ?

Servlet: 1. What is the difference between response.sendRedirect() and request.forward() ?


How do threads work? What is synchronized? If there are two synchronized methods in a class can they be simultaneously executed by two threads. You will be surprised to hear many people answer yes. Then all thread related question, e.g. deadlock, starvation etc.


One thing many Java programmers don't know is that Strings are immutable, so use StringBuilder or StringBuffer!

String s = "";
for(int i = 0; i < 100; i++) {
  s += "Strings " + "are " + "immutable, " + " so use StringBuilder/StringBuffer to reduce memory footprint";
}

참고URL : https://stackoverflow.com/questions/2114212/questions-every-good-java-java-ee-developer-should-be-able-to-answer

반응형