Java Interview Questions
- 1 Can there be an abstract class with no abstract methods in it? Yes, But abstract method must have with abstract class.2. Can an interface be final? Can’t. Because abstract methods want to implement in the last concrete class3. Can interface have an inner class? Can have an inner class4. Can we define private and protected modifiers for variable in the interface? Can’t. can use only finale variable and public abstract methods5. What is a local, member variable?· Local – variable declared within the method called local variable· Member – variable declared within the class but not any method is called member variable6. Difference between interface and abstract class?· Abstract class defines with method· Interface declares only with method7. What do you mean by RMI and how it will works?· RMI – Remote Method Invocation· Can work with remote objects· Protocol – RMI-IIOP8. JDBC-ODBC bridge is not multithread9. Class Loader – Class loader is the one which loads class to JVM10. What are the statuses of the thread?· New·· Runnable· Not Runnable· Dead11. What is the socket? Socket is an endpoint for communication between two machine12. How to invoke any external process in java?· Runtime.getRunTime()13. What is the base class for the error and exception?· Throwable14. Package?· Group of class gather into single unit called package15. What is JVM? Java Virtual Machine and it is an interpreter, Totally independent from the operating system.java compiler compile the source code into Byte code and JVM reads the Byte code and convert to the machine code.JVM is the part of the JRE (Java Run time Environment)16. What is the final key word denotes?· It is denotes final implements for the class, method and variables· Class – Cannot extends· Method – Cannot override· Variable – Cannot change the initialized value17. Difference between ArrayList and LinkedList?· ArrayList – Can access randomly· LinkedList – Can access sequentially18. There can be abstract class with no abstract methods but there has abstract methods it should be an abstract class19. Explain different way of using threads· Implementing using runnerble interface· Extends the thread class20. What are passing by reference and pass by values?· pass by reference – copy of the reference will be parsed(object)· pass by value – copy of the bit pattern will be parsed(primitives)21. What is HashMap and Map?· Map is an interface· HashMap is a class22. Difference between vector and ArrayList?· Vector is synchronized· ArrayList is not synchronized23. Difference between Swing and AWT?· Swing – Light Weight / fast / It doesn't invoke native methods.· AWT – Heavy Weight / slow / Every graphical units it will invoke native methods24. Difference between constructor and methods?· Constructer – Member function of a class
Same name of the classNo return typesInvokes using new operator· Methods – Is an ordinary function of a classIt has its own nameHas return typeInvoke using Dot (.) Operator25. Define the access modifiers?· Public – public class is visible in other package· Private – variable and methods can access within the class· Protected - Is available to all classes in the same package and also available to all subclassesOf the class that owns the protected feature.26. What is a marker interface? An interface with no methods27. Static method cannot override, but can redeclare28. What is object Oriented Programmed? It is a problem solving techniques to develop software system. it’s a techniques to think real world in term of objects29. Need Object to deal with non static variables and methods30. Abstract class cannot instantiated (Cannot create class’s object )31. Don’t have multiple class inheritances , But have multiple interface inheritance32. Interface/abstract class cannot instantiated.33. GRASP pattern (General Responsibility Assignment Software Patterns (or Principles),)· Who should be responsible for creating a new instance of some class? - Creational Design Pattern· Coupling is a measure of how strongly one element is connected to, has knowledge of, or relies on other elements.· How to keep complexity manageable? – Cohesion34. Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine35. A Web server exclusively handles HTTP requests36. Application server serves business logic to application programs through any number of protocols.37. Applet is a simple java programe embedded to the web application38. Java Applets are usually used to add small, interactive components or enhancements to a Webpage
Reviewed by Pubudu Dewagama
on
10:55:00 PM
Rating:
No comments: