Wednesday, September 5, 2012

Java Model paper 2


1. Collections.sort(List list)
       - elements in the List should impliments comparable interface

2. Collections.sort(list, Comparator)
       - Sorts the specified list according to the order induced by the specified comparator.

3. Collections.sort(list, Comparator.reverseOrder())
      -Comparator.reverseOrder() Returns a comparator that imposes the reverse of the
        natural ordering on a collection of objects that implement the Comparable interface.

4. Use == to compare two primitives, or to see if two reference refer to the same object.

5. Use the equals() method to see if two different objects are equal

6.  Animal myDog = new Dog();
         with polymorphism, the reference type and object can be different.
                 new Dog(); - is Object
                 myDog - is reference variable
                 Animal - is reference variable type

7.  Dog  myDog = new Dog();
            Tells the JVM to allocate a space for a reference variable

8.  With polymorphism, the reference type can be a super class of the actual object type.

9. Abstract class can't be instantiated.

10. call the static method using Class name ex- Math(88,86)

11. Overridden method allow java to support run-time polymorphisam. It allows a general class to specify methods that will be common to all of its derivatives, while allowing subclass to define the specific implementation of some or all of those methods.
Overridden methods are another way that java implements the "one interface, multiple methods" aspect of polymorphism.

12. private synchronized void makeWithdrawal(int amount)
        synchronized keyword to modify a method so that only one thread at a time can access it.

13.

Thursday, August 9, 2012

java model paper 1

1. What happens if Exception thrown in catch block?
             .

2. Select correct sentence related to "checked Exception" ?
                -Assure the compiler that precautions have been taken using try/catch
                -Compiler cares/concern about these Exception
                -Exceptions must be announce/declared with throws clause
                -Risky code must be wrap with try/catch
                -All

3. How do you create Servlet Instance?
       -Instance creates by servlet container

4. How the data can be trasfered between JSP pages?
      - Session & request objects

5.  Method overriding (in java 5)?
       -overriding method can have a subtype of return type (covarient overriding)

6. Is static method able to call non-static method?
       -No
     
7.   TRUNCATE in sql?
       -TRUNCATE removes all rows from a table.
       -The operation cannot be rolled back and no triggers will be fired.
       -As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.

8.  Is static method allowed in Abstract Class?
        -Yes (calender & Math)

9.  How to acheive session tracking if cookies disabled in browser?
        - response.encodeURL(java.lang.url   url)
          (encode the specified URL by including sessionID in it OR if encoding is not needed
            it returns the URL unchanged)

10.  XmlBeanFactory ?
         -BeanFactory factory = new XmlBeanFactory( new FileInputStream("beans.xml"));
                  MyBean myBean = (MyBean) factory.getBean("myBean");
         - To create an XmlBeanFactory, pass a java.io.InputStream to the constructor.
         - The InputStream will provide the XML to the factory.

11. What is the use of private constructor?
       -out side code can't create a instance
       -
12.   int x=32;
        ArrayList list = new ArrayList();
         list.add(x);
         whats the correct statement below?
               . it works in all the java versions
               . it works below java 5
               . works in java 5 or higher
               . it doesn't work in any versions

13.  Run() method in Thread?
          -can be override(extending Thread class). if not overrided, actual Thread class version of
            Run() will be called but it does nothing
          - can be overloaded
          -overloaded method ignored by Thread class unless you call it yourself
          - calling overloaded method can't create a new call stack

14. select the correct statement for "variables placed in JSP declartion".
        -Multipul threads can access these variables.
        -Value(<%= getDate() %) of variable will be same regardless of how many times page loads.

15.  Collections.sort() ?
         -Sorts the specified list into ascending order,
         -according to the natural ordering of its elements.
         -All elements in the list must implement the Comparable interface
         -e1.compareTo(e2)

16. What's the correct statement to Static Method?
          -static method can't use the non-static variables
          -static method can be called by instances of the class
          -static method is called by class name
          -All above

17. How to add the cookie?
        response.addCookie(cookiename);

18.  what does creating subclass mean?
        -Creating specialized version of more general superclass

19. Below is the JSP declaration
      -<%        %>
      -<%= and %>
      -<%! and %>
      -<%@      %>

20. What the correct statement for constructor?
       -constructor needs to be mentioned explicitly
       -compile create default constructor if no user constructor defined

21. Can we have Action without form?
          -Yes

22. What is circular dependency in Spring?
       -object instatiation depends on each other with constructor injection
       -two objects are calling each other
       -two objects can be called both the directions

23. When to use Static?
      -want to have variables that are common to all objects
      -This is accomplished with the static modifier
      -They are associated with the class, rather than with any object
      -Any object can change the value of a class variable *
      -but class variables can also be manipulated without creating an instance of the class *

24.  DROP in SQL?
       -The DROP command removes a table from the database.
       -All the tables' rows, indexes and privileges will also be removed.
       -No DML triggers will be fired. The operation cannot be rolled back.

25.  How to invoke superclass version of a method from subclass that's overridden the method?
       . using super keyword (super.runreport)

26.  How to create a Thread?
             -2 ways first is extending   java.lang.Thread
              OR implementing Runnable Interface

27.  important ApplicationContext implementations in spring framework ?
          -ClassPathXmlApplicationContext
          -FileSystemXmlApplicationContext
          -XmlWebApplicationContext

28. What is correct statement to Hibernate "Entity"?
         . It must have default constructors
         . It should have getter/setters for all the fields
         . It should not contain static or final fields.
         . Above all
29. JDBC template in Spring?
        context = new ClassPathXmlApplicationContext("xyz-beans.xm.");
         datasource = new context.getBean("mySqlDatasource");
          template = new JdbcTemplate(datasource);
          template.queryForXXX();

30. What happen if constructor is created with return type?
         . then it will become regular method
  
31.  sql DELETE Statement?
       -used to delete rows in a table
       -If you omit the WHERE clause, all records will be deleted!

32. Core interfaces of Hibernate framework?
           -Configuration Interface
           -Session Interface
           -SessionFactory Interface
           -Transaction Interface
           -Query and Criteria Interface

33. What are application context advantages over the Bean factory?
          -application context is global access
          -application context also including entireprize features(i.e transaction, AOP)
          -application context has a more scope
          -above all

34.  wraper class
         -almost all wraper class implements the Comparable, Serializable interface
         -so e1.compareTo(e2) method is present, that's why these wraper classes is
           sorted  in collections(TreeSet)
         -all wraper class has equals & hashcode method

35. What is the wrong statement below?
         . Interface is 100% pure abstract class
         . class extended by only one class, but it impliments many interfaces
         . constructor can be overridden
         . interface methods are implicitly public & abstract

36. How many ways spring bean gets instatiated?
           -2 ways(static factory method, instance factory method)

37. How to create a session?
         HttpSession session=req.getSession(true);
         String sessionID=session.getId();
        -returns the current session associated with the request. OR if request doesn't have
          a session, create one

38.  Is it possible to create a regular method with Class name?
           .Yes (it should have return type)
39.  BeanFactory?
        - root interface for accessing a Spring bean container.

40.  What are the things needed for the socket connection?
          - IP address & TCP port
41.  How to find number of records in a table?
        - select count(*) FROM persons;
42.  compare(T o1,T o2) method in Comparator interface?
         -Compares its two arguments for order.
         -Returns a negative integer, zero, or a positive integer
         -as the first argument is less than, equal to, or greater than the second

43. Write a code for random number which should be between 0 to 5?
                int rand= (int) (Math.random() * 5);
44.  BeanFactory?
         -A BeanFactory is an implementation of the factory pattern that applies Inversion of Control to   separate the application’s configuration and dependencies from the actual application code.

45. m1() mehtod is overridden in subclass. how to call super calss version of m1() method from the
         instance of subclass?
             superclasstype    xy= instance;
                  superclasstype.m1();
46.  e1.compareTo(e2)
        -less than zero - invoking object less than parameter object
       
47.  What to use to get int value of String?
         Integer.parseInt();

48.   JdbcTemplate?
            -inject datasource object into JdbcTemplate
              then inject JdbcTemplate into DAO

49. Comparator
         -The Comparator is needed if you have an object
           which does not implement the Comparable interface.

50. What is the worng statement for servlet?
       . servlet instance is created for each request
       . only one servlet instance is created regardless of how many requests made
       . servlet is not thread safe (multiful threads run on single instance)



      



Wednesday, June 15, 2011

English ver 2.0

-I do not understand why I have not been told directly by Naveen about his illness.
-He has put his phone off at this time.
-not sure why Jayesh was chosen to give this message than you or Vikas.
-Did you cc Jennifer Malta?
-what are you currently working on ?
-none of you are online in webex… again not sure what’s the issue is but this violates our project SLA (service level agreement).
-this is the URL to which to connect.

Tuesday, September 21, 2010

Java

>Class variables (static fields) are fields declared with the static modifier; there is exactly one copy of a class variable, regardless of how many times the class has been instantiated.

--String s = "this is a string";. String objects are immutable, which means that once created, their values cannot be changed.

Monday, August 30, 2010

English

-From the HR perspective, you may contact your practice HR for any practice related queries.
-I need that books badly.
-Who are you waiting for?
-Fresh graduate alway tend to spend more than the experienced.
-Exam results do not necessarily reflect the ability of a student.
-My parents send me to Mumbai so that i could send them money.
-Dad told me that He would buy a new car.
-You told me you would not come.
-I don't know you would come.
-I didn't think you would come. I think you would come.
-I don't mind giving a call. But i'm afraid i will forget.
-Who will be in the governamet and who will not be in governamet.
-There is know question of left support.
-He said he would complain to the police.
-How long have been using your scootor?
-Don't think there are no crocodiles because water is calm.
-you will never be loved... the way you are now
-you never have been... you never will be
-To get financially sound and stable before getting laid off the second time.
-Lend means to give something and borrow means to take something.
-So think about your financial stability first, when you get laid off, you kids
will complain to you and not your boss.
-Discovery is seeing what everybody else has seen, and thinking what nobody else has thought.
Your love for me is more than enough! I've got more than what I could have asked for!
The Dream is not what you see in sleep, Dream is which does not let you sleep.