Thursday, 15 December 2016

Common Interview questions for Java Developer


Tell me about yourself?
Tell me about your project?

What are the different features of oops?
What is Design Pattern? Describe some design patterns with example.
What is singelton Class? Write a code for it.
What is dynamic polymorphism? Write a code for explanation.
What is reflection mechanism in java?
What is CompiletimeException/CheckException and RuntimeException/UncheckedException?
What is static binding/Early binding and dynamic binding/late binding? Show by code.
What is the difference between ArrayList and LinkedList?
(mainly during insertion, deletion or traverse which is more used)
What are the new features Java7 & Java8?
What are the uses of marker interface? What are the different types avaialable for marker interface ?
What are the different type of cloning u used and when ?
What are the different way to create a thread object? write a code to create it.
What are Association, aggregation and composition in Java?
What are differences available for abstract classes and interface?
What is Deadlock,startvation and inter thread communication in java?
What are differences available for HashMap & HashTable?
What is the difference between synchronized block and synchronized method?
What is fail safe and fail fast?
Have you used any static code analysis tools?
Have static code analysis tools will improve performance? (JLint, Sonar and CheckStyle)
Have you done remote debugging? What is your debugging strategy if a production issue come?
What are the uses of volatile and transient variables in java?
What are the differences between differences ways of creating String object?
What are the different ways for garbage collection?
What are the differences between heap and stack memory?
What is the difference between Comparable and Comparator interface?


How HashMap internally works?
How can you sort the employee object on the basis of thier salary ?
How HashSet internally uses HashMap?
How Map & set being iterated?
How can you handle exception during method overriding?
How can you implement your own LinkedList/HashMap in java?
How can i reverse the one array using same array only?
How can i find the duplicate numbers available in any array ?
How can i sort one array using single iteration?
How can i found the 2nd highest number from an array in single iteration?
How will you manage producer and consumer problems? How can you prevent deadlock in java?
How dead lock is different from race conditions
How do you improve performance of an application?
How conscious you were with security issues while coding?
How a bad program can cause security threat?
How can i throw or catch an exception?
how to find that is there is any consecutive repeating characters within a string?
How and which sort algorithm you would use for sorting a char array?
How bitly shortens the URLs ?
How do you delete a node in Binary Search Tree?
How to write a code that causes deadlock?
How would you implement your own thread pool in java?

Thursday, 8 December 2016

Angular JS Frequently asked questions

What is the difference between ng-show and ng-if ?

what are the different ways to share the data across multiple controllers ?

What are difference between controller and directives ?

What are the best features so we love to use angular apart from other js framework ?

What is difference between filter and service ?

What are the different type of scope you used inside angular ?

What is promise, watch, digest, apply, timeout and $q inside angular ?

What are the use of route & state in angular ?

can i use 2 different module inside same application ?

What Single page application means actually for which i'm using angular js ?

What is the difference between $scope and $rootScope ?

How we can write success & error within $http call to communicate within any methods ?

What is the difference between ng-paginate and ng-repeat ?

What is the difference when using ng-click and anchor href ?

What are the uses of restrict in angular js and how many types of restriction are in use ?

when we use query param to share data between multiple controller ?

Wednesday, 7 December 2016

Important Differences available inside Collection Frameworks











Most Frequently used Java Questions

http://howtodoinjava.com/core-java/interviews-questions/real-java-interview-questions-asked-for-oracle-enterprise-manager-project/

1)  What is abstraction and encapsulation in java ?

2)  What is method overloading rules? Can we overload the super class method in sub class?                     Discussion happened with the example.

3)  What is method overriding rules?

4)  What is widening and narrowing in java? discussion happened with example?

5)  Can I have only try block in code?

6)  Threads : producer and consumer problem?

7)  Why wait(), notify() and notifyAll() are defined in Object class?

8)  Can we override wait() or notify() methods?

9)  Difference between wait(), sleep() and yield()?

10) Explain about join() method in thread class

11) Have you faced out of memory error? If yes how you fixed ? Tell different scenarios why it
      comes?

12) Database connection leakage?

13) To avoid this extra overhead every time, double checked locking principle is used what is that ??

14) What is Java Singleton Pattern ?? how are the different way to create a singleton class either by            thread safe or non thread safe ??
http://www.journaldev.com/1377/java-singleton-design-pattern-best-practices-examples

15) Rules of Exceptions during Method Overriding & Overloading
http://www.javatpoint.com/exception-handling-with-method-overriding

16) How to get data from HashMap & HashSet?

17) I have two arrays which contains integer. Write a program to merge those two arrays and remove       duplicate elements? At the end, I need one array which should have unique elements?

18) Write a program on Singleton?

19) Write a program to sort an array and remove duplicates?

20) Write a program to fetch the data from a table using JDBC and result set?

21) What happens if i write return in try block? Will finally executes? What happens if write                      system.exit(), will finally block executes?

22) Different type of design patterns used before ?
http://www.vogella.com/tutorials/DesignPatterns/article.html
http://www.java67.com/2012/09/top-10-java-design-pattern-interview-question-answer.html

23)  Can you override a private or static method in Java?

24) What will happen if we put a key object in a HashMap which is already there?

25) If a method throws NullPointerException in the superclass, can we override it with a method               which throws RuntimeException?

26) Difference between compareTo and compare in java

27) How do you ensure that N thread can access N resources without deadlock?

28) What is the difference between StringBuffer and StringBuilder in Java?

29) Can you access a non-static variable in the static context?

30) is it possible to load a class by two ClassLoader?

31) is it possible for equals() to return false, even if contents of two Objects are same?

32) How does "has before" apply to volatile work?

33) What happens when an exception is thrown by a Thread?

34) Difference between System.exit() and System.halt() method?

35) difference between BLOB and CLOB

36) Why character array is better than String for Storing password in Java?

37) How to create a thread-safe singleton in Java using double-checked locking?

38) Write Java program to create a deadlock in Java and fix it ?

39) Why is String immutable in Java?

40) Why does Java not support operator overloading ?

41) Why is multiple inheritances not supported in Java ?

42) Why wait and notify is declared in Object class instead of Thread ?

43) What happens if your Serializable class contains a member which is not  serializable? How do              you fix it?

44) Why wait and notify  called from synchronized method in Java?

45) Why does Java not support operator overloading ?

46) Why is multiple inheritances not supported in Java ?

47) Can we overload a static method in Java?

48) Can we override a static method in Java?

49) Can we prevent overriding a method without using the final modifier?

50) Can we override a private method in Java?

51) What is covariant method overriding in Java?

52) Can we change the return type of method to subclass while overriding?

53) Can we change the argument list of an overriding method?

54) Can we override a method which throws runtime exception without throws clause?

55) How do you call superclass version of an overriding method in sub class?

56) Can we override a non-static method as static in Java?

57) Can we override the final method in Java?

58) Can we have a non-abstract method inside interface?

59) What is the default method of Java 8?

60) Can we make a class both final and abstract at the same time?

61) Can we overload or override the main method in Java?

62) What is the difference between Association, Aggregation, and Composition in OOP?

63) What problem is solved by Strategy pattern in Java?

64) Which OOP concept Decorator design Pattern is based upon?

65) What is the difference between Decorator, Proxy and Adapter pattern in Java?

66) Consider the following Java code snippet,

which is initializing two variables and both are not volatile, and two threads T1 and T2 are modifying these values as following, both are not synchronized
int x = 0;
boolean bExit = false;

Thread 1 (not synchronized)
x = 1;
bExit = true;

Thread 2 (not synchronized)
if (bExit == true)
System.out.println("x=" + x);
Now tell us, is it possible for Thread 2 to print “x=0”?

Answer: It's impossible for a list of tricky Java questions to not contain anything from multi-threading. This is the simplest one I can get. Answer of this question is Yes, It's possible that thread T2 may print x=0.Why? because without any instruction to compiler e.g. synchronized or volatile, bExit=true might come before x=1 in compiler reordering. Also, x=1 might not become visible in Thread 2, so Thread 2 will load x=0. Now, how do you fix it?

 When I asked this question to a couple of programmers they answer differently, one suggests to make both threads synchronized on a common mutex, another one said make both variable volatile. Both are correct, as it will prevent reordering and guarantee visibility.

But the best answer is you just need to make bExit as volatile, then Thread 2 can only print “x=1”. x does not need to be volatile because x cannot be reordered to come after bExit=true when bExit is volatile.

WebLogic : The Application Server

1). If an administration server running machine got crashed, how will you restart the server with same configuration on new machine?

    • Oracle WebLogic Server allows the creation of a backup of the server as follows:
      • Install Oracle WebLogic Server on a backup machine.
      • Copy the application files to a backup machine.
      • Copy the configuration files to a backup machine.
      • Restart the Administration Server on a new machine.
    • The new Administration Server contacts the Managed Servers and informs them that it is running on a new IP address.
  • similarly we can also create a backup for tomcat as well, These ways you follow:
                   /tomcat/config
                   /tomcat/webapps
                   Also note down the version of tomcat you use. 
                   In webapps if you use war files, it should be sufficient to backup only all war files.
                   On restore install tomcat of same version, then copy above folders from backup 
                    (replacing files like server.xml)
                   Please test this setup on a test server. But in short this is all you need.
                   Don't forget the tomcat native in tomcat/bin

2). How can you run Multiple Weblogic server instances in a same physical machine?
    • You can run multiple instances of WLS using different configurations on the same physical machine at the same time by either:
      • Assigning multiple IP addresses to a machine (multihoming) and defining each server to use a unique IP address
      • Specifying the same IP address but using different listen ports
    • A multihomed machine:
      • Is a machine with multiple IP addresses
      • Can run a different WLS instance that is bound to each IP address
      • Can be used to configure a cluster on a single machine
    • In Tomcat, it is also possible to achieve by changing the http, https, ajp and shutdown ports.
3). How will you create Domain Template? Explain briefly?
    • A domain template defines the full set of resources within a domain.
    • Oracle provides sample templates for creating any platform domain.
    • There are three ways to create domain templates:
      • WLST offline command line tool
      • pack command
      • Domain Template Builder (config_builder.sh under WL_HOME/common/bin)
    • Use the Domain Template Builder to create a domain template or an extension template.
    • Using the Domain Template Builder:
      • Define a domain and replicate it across multiple projects
      • Distribute a domain packed with an application that has been developed to run in it
    • A template provides configuration information and files to support a feature or application on a tc Runtime instance. The built-in templates that ship with tc Server make it simple to configure tc Runtime features such as SSL or JMX or to add a management application to an instance at creation time, such as Spring Insight. You can create your own templates by creating a subdirectory in the templates directory of your tc Server installation directory and populating it with files accordingly.
4). What are the default Weblogic provided Groups for security realm?
  • Administrators
  • Deployers
  • Operators
  • Monitors
  • AppTesters
  • CrossDomainConnectors
  • AdminChannelUsers
5). What are the default Weblogic provided Roles for security realm?
  • Admin
  • Deployer
  • Operator
  • Monitor
  • AppTester
  • CrossDomainConnectors
  • AdminChannelUsers
  • Anonymous
6). What is the default Weblogic provided domain template file name and location?
  • Wls.jar is the default domain template and the location is
  • WL_HOMEcommontemplatesdomains
7).What are the elements of the Administration console?
  • Change Center
  • Domain Structure
  • How do I…
  • Tool Bar
  • Breadcrumb Navigation
  • System Status
8). What are the Node elements of the Administration console or Domain Structure?
  • Environment (Servers, Clusters, Virtual Hosts, Migratable Targets,  Machines …)
  • Deployment
  • Services (Messaging, JDBC, Persistent Store, JTA, File T3, jCOM …)
  • Security Realms
  • Interoperability
  • Diagnostics (Log Files, Diagnostics Modules, Diagnostics Images, Archives, Context)
9). What are the Tool Bar elements in Weblogic?
  • Welcome Message
  • Connected to
  • Home
  • Log Out
  • Preferences
  • Record
  • Help
  • Search
10). How will you enable the Administration Console?
By default, the Administration Console is enabled. If you disable it, you can re-enable it using the WebLogic Scripting Tool (WLST).
Start the Administration Server, then invoke WLST and use the following commands:
Using WLST to Re-enable the Console 
connect(“username”,”password”)
edit()
startEdit()
cmo.setConsoleEnabled(true)
save()
activate()
The following attribute(s) have been changed on MBeans which require server re-start.MBean Changed : com.bea:Name=mydomain,Type=Domain Attributes changed : 
ConsoleEnabled
Activation complete
ddisconnect()
exit()

http://interviewquestionsanswerspdf.com/2014/03/weblogic-interview-questions-and-answers/

JSP interview questions and answers

Q1. What is JSP and why do we need it? JSP stands for JavaServer Pages. JSP is java server side technology to create dynamic web pages. J...