Most important j2ee questions

0 comments Posted by Stephen thangaraj at 18:52
1. What is J2EE?J2EE is an environment for developing and deploying enterprise applications. The J2EE platform consists of a set of services, application programming interfaces (APIs), and protocols that provide the functionality for developing multitiered, web-based applications.

2. What is the J2EE module?
A J2EE module consists of one or more J2EE components for the same container type and one component deployment descriptor of that type.

Read More »

Most important j2ee questions

0 comments Posted by Stephen thangaraj at 18:52

1. What is J2EE?J2EE is an environment for developing and deploying enterprise applications. The J2EE platform consists of a set of services, application programming interfaces (APIs), and protocols that provide the functionality for developing multitiered, web-based applications.



2. What is the J2EE module?
A J2EE module consists of one or more J2EE components for the same container type and one component deployment descriptor of that type.

3. What are the components of J2EE application? 
A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and communicates with other components. The J2EE specification defines the following J2EE components:
Application clients and applets are client components.
Java Servlet and JavaServer PagesTM (JSPTM) technology components are web components.
Enterprise JavaBeansTM (EJBTM) components (enterprise beans) are business components.
Resource adapter components provided by EIS and tool vendors.4. What are the four types of J2EE modules?




1. Application client module

2. Web module
3. Enterprise JavaBeans module
4. Resource adapter module

5. What does application client module contain? 
The application client module contains:
--class files,
--an application client deployment descriptoor.
Application client modules are packaged as JAR files with a .jar extension.6. What does web module contain?The web module contains:
--JSP files,
--class files for servlets,
--GIF and HTML files, and
--a Web deployment descriptor.
Web modules are packaged as JAR files with a .war (Web ARchive) extension.
Read More »

Top 100 j2ee Questions

0 comments Posted by Stephen thangaraj at 18:50

  1. How do I instantiate a bean whose constructor accepts parameters using the useBean tag?
  2. Replacing Characters in a String?
  3. Searching a String?
  4. Connecting to a Database and Strings Handling?
  5. What is a transient variable?
  6. What is the difference between Serializalble and Externalizable interface?
  7. How many methods in the Externalizable interface?
  8. How many methods in the Serializable interface?
  9. How to make a class or a bean serializable?
  10. What is the serialization?
Read More »

most Asked j2ee questions

0 comments Posted by Stephen thangaraj at 18:49

What servlet container and JDK is used in J2EE Public Service?
Apache Tomcat, release 5.5.23 running on Java SDK version 6.

What Servlet/JSP specification versions are supported?
The supported specification versions are: Servlet 2.4 and JSP 2.0.

My webapplication uses EJB, can I host it in the J2EE Public Service?
Apache Tomcat is not an EJB server. It is a Servlet container so EJBs are not supported directly by the J2EE Public Server. 
A solution to use EJBs in the J2EE Public Service is to use OpenEJB. It is a project developed by the Apache Software Foundation which allows to use EJBs with Tomcat server (Tomcat 5 or 6 ). For more information, please visit the project website OpenEJB.
Read More »

HR hibernate Interview Questions

0 comments Posted by Stephen thangaraj at 18:29

What is component mapping in Hibernate?
  • A component is an object saved as a value, not as a reference
  • A component can be saved directly without needing to declare interfaces or identifier properties
  • Required to define an empty constructor
  • Shared references not supported
Read More »

Hibernate interview Questions Part1

0 comments Posted by Stephen thangaraj at 18:28

What is Hibernate?


Hibernate is a powerful, high performance object/relational persistence and query service.It is an open-source technology which fits well both with Java and .NET technologies.Hibernate lets developers write persistence classes with hibernate query features of HQL within principles of Object Oriented paradigm.It means one can include association,inheritance,polymorphism,composition and collection of these persisting objects to build applications.

Hibernate Architecture

The main objective of Hibernate is to relieve the developers from manual handling of SQLs,JDBC APIs for resultsets handling and it helps in keeping your data portable to various SQL databases,just by switching the delegate and driver details in hibernate.cfg.xml file.
Read More »

Using Hibernate with Tomcat

0 comments Posted by Stephen thangaraj at 18:26
Using Hibernate with Tomcat

If you use Hibernate on Tomcat you don't have to use Tomcat's JNDI-bound JDBC connections. You can let Hibernate manage the JDBC connection pool. This works on all versions of Tomcat and is very easy to configure.
First, create a hibernate.cfg.xml or hibernate.propertiesfile, as per documentation (no, property names in cfg.xml don't have to be prefixed with "hibernate.xxx"):
<!DOCTYPE hibernate-configuration PUBLIC 
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 
<hibernate-configuration>
    <session-factory>
    
        <!-- Settings for a local HSQL (testing) database. -->
        <property name="dialect">org.hibernate.dialect.HSQLDialect</property>
        <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="connection.url">jdbc:hsqldb:hsql://localhost</property>
        <property name="connection.username">sa</property>
        <property name="connection.password"></property>
 
        <!-- Use the C3P0 connection pool. -->
        <property name="c3p0.min_size">3</property>
        <property name="c3p0.max_size">5</property>
        <property name="c3p0.timeout">1800</property>
    
        <!-- Disable second-level cache. -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
        <property name="cache.use_query_cache">false</property>
        <property name="cache.use_minimal_puts">false</property>
        <property name="max_fetch_depth">3</property>
    
        <!-- Print SQL to stdout. -->
        <property name="show_sql">true</property>
        <property name="format_sql">true</property>
    
        <!-- Drop and then re-create schema on SessionFactory build, for testing. -->
        <property name="hbm2ddl.auto">create</property>
    
        <!-- Bind the getCurrentSession() method to the thread. -->
        <property name="current_session_context_class">thread</property>
 
        <!-- Hibernate XML mapping files -->
        <mapping resource="org/MyClass.hbm.xml"/>
    
        <!-- Hibernate Annotations (and package-info.java)
        <mapping package="org.mypackage"/>
        <mapping class="org.MyClass/>
        -->
 
    </session-factory>
 
</hibernate-configuration>
Now copy this file into your WEB-INF/classes directory of your web application. Copy hibernate3.jar into your WEB-INF/libdirectory and with it all required 3rd party libraries (see lib/README.txt in the Hibernate distribution). Don't forget to also copy your JDBC driver to common/libor WEB-INF/lib. Never ever copy anything in Tomcat into a global directory outside of your web application or you are in classloader hell!
Start Hibernate by building a SessionFactory, as shown here with HibernateUtil.
This listener initializes and closes Hibernate on deployment and undeployment, instead of the first user request hitting the application:
public class HibernateListener implements ServletContextListener {
 
    public void contextInitialized(ServletContextEvent event) {
        HibernateUtil.getSessionFactory(); // Just call the static initializer of that class    
    }
 
    public void contextDestroyed(ServletContextEvent event) {
        HibernateUtil.getSessionFactory().close(); // Free all resources
    }
}
Add it to your web.xml:
<listener>
    <listener-class>org.mypackage.HibernateListener</listener-class>
</listener>


click the Below link download this file 
Read More »

Tcs Hibernate questions and answers

1 comments Posted by Stephen thangaraj at 18:22

What is Hibernate?


Hibernate is a powerful, high performance object/relational persistence and query service.It is an open-source technology which fits well both with Java and .NET technologies.Hibernate lets developers write persistence classes with hibernate query features of HQL within principles of Object Oriented paradigm.It means one can include association,inheritance,polymorphism,composition and collection of these persisting objects to build applications.

Hibernate Architecture

The main objective of Hibernate is to relieve the developers from manual handling of SQLs,JDBC APIs for resultsets handling and it helps in keeping your data portable to various SQL databases,just by switching the delegate and driver details in hibernate.cfg.xml file.
Hibernate offers sophisticated query options, you can write plain SQL, object-oriented HQL (Hibernate Query Language), or create programmatic criteria and example queries. Hibernate can optimize object loading all the time, with various fetching and caching options.
Some snapshots of Hibernate:
-Free open source
-OO Concepts can be implemented.
-A rich variety of mappings for collections and dependent objects
-No extra code generation or bytecode processing steps in your build procedure
-Great performance, has a dual-layer cache architecture, and may be used in a cluster
-Its own query language support
Read More »

Advanced Jms Questions

0 comments Posted by Stephen thangaraj at 18:16

  • Q. When to Remove messages from the queue ? 
  • Q. What is poison messages? And how to handle poison messages? 
  • What are the Message Headers in JMS message ?
  • What are the steps to send and receive JMS message ?
  • What is Publish/Subscribe Messaging in JMS ? 
  • What Point-to-Point Messaging in JMS ? 
  • What are the main component in JMS? 
Read More »

Advanced Java Questions

0 comments Posted by Stephen thangaraj at 19:22

1)What is the functionality of web server? What are servlets? 

Answer 1) Web server that provides services to remote clients has two main responsibilities:- http://capptitudebank.blogspot.in/ 
The first is to handle network connections; the second is to create a response to be sent back. 

The first task involves programming at the socket level, extracting information from request messages, and implementing client-server protocols, such as HTTP. 
Read More »

Depth JMS Interview Questions & Answers

0 comments Posted by Stephen thangaraj at 19:14
Q:  What is JMS?
A: JMS is an acronym used for Java Messaging Service. It is Java's answer to creating software using asynchronous messaging. It is one of the official specifications of the J2EE technologies and is a key technology.
           
Q: How JMS is different from RPC?
A: In RPC the method invoker waits for the method to finish execution and return the control back to the invoker. Thus it is completely synchronous in nature. While in JMS the message sender just sends the message to the destination and continues it's own processing. The sender does not wait for the receiver to respond. This is asynchronous behavior.
Read More »

JMS Interview Questions - Part1

0 comments Posted by Stephen thangaraj at 19:00
JMS Interview Questions - Part1

1. What is JMS? 
Java Message Service is the new standard for interclient communication. It allows J2EE application components to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous. 



2. What type messaging is provided by JMS 

Both synchronous and asynchronous 
Read More »

EJB solved questions For LNT

0 comments Posted by Stephen thangaraj at 18:54
Why does EJB needs two interfaces(Home and Remote Interface)

There is a pure division of roles between the two .

Home Interface is the way to communicate with the container which is responsible for creating , locating and removing beans and Remote Interface is the link to the bean that allows acces to all methods and members.


What are the optional clauses in EJB QL?
WHERE and ORDERBY clauses are optional in EJB QL where as SELECT and FROM are required clauses.
Can I invoke Runtime.gc() in an EJB?
You shouldn’t. What will happen depends on the implementation, but the call will most likely be ignored.
Read More »

J2EE interview question In LNT

0 comments Posted by Stephen thangaraj at 15:44
Java – Fundamentals
Q 01: Give a few reasons for using Java? 
A 01: Java is a fun language. Let’s look at some of the reasons:
􀂃 Built-in support for multi-threading, socket communication, and memory management (automatic garbage collection).
􀂃 Object Oriented (OO).
􀂃 Better portability than other languages across operating systems.
􀂃 Supports Web based applications (Applet, Servlet, and JSP), distributed applications (sockets, RMI, EJB etc) and network protocols (HTTP, JRMP etc) with the help of extensive standardized APIs (Application Programming Interfaces).
Read More »

CORE JAVA INTERVIEW QUESTIONS AND ANSWERS

0 comments Posted by Stephen thangaraj at 02:27


CORE JAVA INTERVIEW QUESTIONS AND ANSWERS 



What is the most important feature of Java? 
Java is a platform independent language. 

What do you mean by platform independence? 
Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform eg (Linux,Solaris,etc). 

Are JVM's platform independent?
JVM's are not platform independent. JVM's are platform specific run time implementation provided by the vendor. 
Read More »

Mahindra Java Interview Questions With Answers-2:

0 comments Posted by Stephen thangaraj at 02:24

Mahindra Java Interview Questions With Answers-2:
1) Explain about Core Java?
Java is increasingly used for middleware applications to communicate between Server and clients. Java has features such as multithreading, portability and networking capabilities. Changes in the java library made java as a favorite programming language for developers it added functionality to their scripts.

2) State some advantages of Java?
Platform independence is the key feature of Java during runtime. Syntax of java is similar to the popular object oriented languages such as C and C++. Java program can eliminate most of the bugs present in the program. Manual memory allocation and de allocation feature present in Java is automated.
Read More »

HCL JAVA INTERVIEW QUESTIONS AND ANSWERS

2 comments Posted by Stephen thangaraj at 02:23

JAVA INTERVIEW QUESTIONS AND ANSWERS

What is the difference between an Interface and an Abstract class?

A:        An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.

Q:        What is the purpose of garbage collection in Java, and when is it used?

A:        The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.
           
Read More »

c genious solved questions

0 comments Posted by Stephen thangaraj at 03:42

                                                               C Solved Questions

Question: What is the output of the following code

#include <iostream>
#include <algorithm>
#include <iterator>

struct g
{
g():n(0){}
int operator()() { return n++; }
int n;
};

int main()
{
int a[10];
std::generate(a, a+10, g());
std::copy(a, a+10, std::ostream_iterator<int>(std::cout, " "));
}


Answer: 0 1 2 3 4 5 6 7 8 9
Read More »

Oracle Interview Questions

0 comments Posted by Stephen thangaraj at 03:36
What is SQL? 
What is SELECT statement?
How can you compare a part of the name rather than the entire name?
What is the INSERT statement?
How do you delete a record from a database?
How could I get distinct entries from a table?
How to get the results of a Query sorted in any order?
How can I find the total number of records in a table?
What is GROUP BY?
What is the difference among "dropping a table", "truncating a table" and "deleting all records" from a table?
What are the Large object types suported by Oracle?
Difference between a "where" clause and a "having" clause ?
What's the difference between a primary key and a unique key?

What are cursors? Explain different types of cursors. What are the disadvantages of cursors? How can you avoid cursors?
What are triggers? How to invoke a trigger on demand?
What is a join and explain different types of joins.
What is a self join?

What is SQL?
SQL stands for 'Structured Query Language'.:

What is SELECT statement?
The SELECT statement lets you select a set of values from a table in a database. The values selected from the database table would depend on the various conditions that are specified in the SQL query.


How can you compare a part of the name rather than the entire name?
SELECT * FROM people WHERE empname LIKE '%ab%' Would return a recordset with records consisting empname the sequence 'ab' in empname .
 What is the INSERT statement?
The INSERT statement lets you insert information into a database.

How do you delete a record from a database?
Use the DELETE statement to remove records or any particular column values from a database.

How could I get distinct entries from a table?
The SELECT statement in conjunction with DISTINCT lets you select a set of distinct values from a table in a database. The values selected from the database table would of course depend on the various conditions that are specified in the SQL query. Example
SELECT DISTINCT empname FROM emptable

How to get the results of a Query sorted in any order?
You can sort the results and return the sorted results to your program by using ORDER BY keyword thus saving you the pain of carrying out the sorting yourself. The ORDER BY keyword is used for sorting.
SELECT empname, age, city FROM emptable ORDER BY empname

How can I find the total number of records in a table?
You could use the COUNT keyword , example
SELECT COUNT(*) FROM emp WHERE age>40

What is GROUP BY?
The GROUP BY keywords have been added to SQL because aggregate functions (like SUM) return the aggregate of all column values every time they are called. Without the GROUP BY functionality, finding the sum for each individual group of column values was not possible.
What is the difference among "dropping a table", "truncating a table" and "deleting all records" from a table.

Dropping :  (Table structure  + Data are deleted), Invalidates the dependent objects ,Drops the indexesTruncating:  (Data alone deleted), Performs an automatic commit, Faster than delete
Delete : (Data alone deleted), Doesn’t perform automatic commit

What are the Large object types suported by Oracle?
Blob and Clob.

Difference between a "where" clause and a "having" clause.
Having clause is used only with group functions whereas Where is not used with.
What's the difference between a primary key and a unique key?
Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major difference is that, primary key doesn't allow NULLs, but unique key allows one NULL only.

What are cursors? Explain different types of cursors. What are the disadvantages of cursors? How can you avoid cursors?
Cursors allow row-by-row prcessing of the resultsets.
Types of cursors: Static, Dynamic, Forward-only, Keyset-driven. See books online for more information.
Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network roundtrip, where as a normal SELECT query makes only one rowundtrip, however large the resultset is. Cursors are also costly because they require more resources and temporary storage (results in more IO operations). Furthere, there are restrictions on the SELECT statements that can be used with some types of cursors.
Most of the times, set based operations can be used instead of cursors.

What are triggers? How to invoke a trigger on demand?
Triggers are special kind of stored procedures that get executed automatically when an INSERT, UPDATE or DELETE operation takes place on a table.
Triggers can't be invoked on demand. They get triggered only when an associated action (INSERT, UPDATE, DELETE) happens on the table on which they are defined.
Triggers are generally used to implement business rules, auditing. Triggers can also be used to extend the referential integrity checks, but wherever possible, use constraints for this purpose, instead of triggers, as constraints are much faster.

What is a join and explain different types of joins.
Joins are used in queries to explain how different tables are related. Joins also let you select data from a table depending upon data from another table.
Types of joins: INNER JOINs, OUTER JOINs, CROSS JOINs. OUTER JOINs are further classified as LEFT OUTER JOINS, RIGHT OUTER JOINS and FULL OUTER JOINS.

What is a self join?
Self join is just like any other join, except that two instances of the same table will be joined in the query.



click the Below link download this file 
Read More »

Struct interview questions and Answer

0 comments Posted by Stephen thangaraj at 03:35


Struts Interview Questions

The core of the Struts framework is a flexible control layer based on standard technologies like Java Servlets, JavaBeans, ResourceBundles, and XML, as well as various Jakarta Commons packages. Struts encourages application architectures based on the Model 2 approach, a variation of the classic Model-View-Controller (MVC) design paradigm.Struts provides its own Controller component and integrates with other technologies to provide the Model and the View. For the Model, Struts can interact with standard data access technologies, like JDBC and EJB, as well as most any third-party packages, like Hibernate, iBATIS, or Object Relational Bridge. For the View, Struts works well with JavaServer Pages, including JSTL and JSF, as well as Velocity Templates, XSLT, and other presentation systems.The Struts framework provides the invisible underpinnings every professional web application needs to survive. Struts helps you create an extensible development environment for your application, based on published standards and proven design patterns.

Read More »

Jsp Interview questions and Answers

0 comments Posted by Stephen thangaraj at 03:30

JSP Interview Questions


What is a output comment?
What is a Hidden comment? 
What is an Expression?
What is a Declaration ? 
What is a Scriptlet?
What are implicit objects? List them?
Difference between forward and sendRedirect?
What are the different scope values for the <jsp:useBean>?
Explain the life-cycle methods in JSP?
How does JSP handle run-time exceptions?
Read More »

Java tuff Questions And Answers

0 comments Posted by Stephen thangaraj at 03:26

Tcs Java Questions

What is the Collections API?

What is the List interface? 

What is the Vector class?

What is an Iterator interface? 

Which java.util classes and interfaces support event handling?
Read More »

Java depth Interview Questions and Answers

0 comments Posted by Stephen thangaraj at 03:23

HCL Interview  Questions-part 1

  What is the difference between an Interface and an Abstract class?

  What is the purpose of garbage collection in Java, and when is it used?  

  Describe synchronization in respect to multithreading.

  Explain different way of using thread?  

  What are pass by reference and passby value?

  What is HashMap and Map?

  Difference between HashMap and HashTable?

Difference between Vector and ArrayList?

  Difference between Swing and Awt?
Read More »

Depth in Java

0 comments Posted by Stephen thangaraj at 03:18

Depth in Java

utility of introspection

One of Java's strengths is that it was designed with the assumption that the environment in which it was running would be changing dynamically. Classes are loaded dynamically, binding is done dynamically, and object instances are created dynamically on the fly when they are needed. What has not been very dynamic historically is the ability to manipulate "anonymous" classes. In this context, an anonymous class is one that is loaded or presented to a Java class at run time and whose type was previously unknown to the Java program.

Anonymous classes
Supporting anonymous classes is hard to explain and even harder to design for in a program. The challenge of supporting an anonymous class can be stated like this: "Write a program that, when given a Java object, can incorporate that object into its continuing operation." The general solution is rather difficult, but by constraining the problem, some specialized solutions can be created. There are two examples of specialized solutions to this class of problem in the 1.0 version of Java: Java applets and the command-line version of the Java interpreter.
Read More »

J2EE Interview questions and answers

1 comments Posted by Stephen thangaraj at 18:32

PART-I

1. What is J2EE?

J2EE is an environment for developing and deploying enterprise applications. The J2EE platform consists of a set of services, application programming interfaces (APIs), and protocols that provide the functionality for developing multitiered, web-based applications.

2. What is the J2EE module?

A J2EE module consists of one or more J2EE components for the same container type and one component deployment descriptor of that type.
Read More »

HCL EJB interview questions and Answers

0 comments Posted by Stephen thangaraj at 18:29
Is it legal to have static initializer blocks in EJB? 

Although technically it is legal, static initializer blocks are used to execute some piece of code before executing any constructor or method while instantiating a class. Static initializer blocks are also typically used to initialize static fields - which may be illegal in EJB if they are read/write - In EJB this can be achieved by including the code in either the ejbCreate(), setSessionContext() or setEntityContext() methods. 


No, you cannot map more than one table to a single CMP Entity Bean. CMP has been, in fact, designed tomap a single table. 

Read More »

EJB Interview Questions

0 comments Posted by Stephen thangaraj at 18:26

EJB Interview Questions and Answers
Q:
What are the different kinds of enterprise beans?
A:
Stateless session bean- An instance of these non-persistent EJBs provides a service without storing an interaction or conversation state between methods. Any instance can be used for any client.

Stateful session bean- An instance of these non-persistent EJBs maintains state across methods and transactions. Each instance is associated with a particular client.

Entity bean- An instance of these persistent EJBs represents an object view of the data, usually rows in a database. They have a primary key as a unique identifier. Entity bean persistence can be either container-managed or bean-managed. 

Message-driven bean- An instance of these EJBs is integrated with the Java Message Service (JMS) to provide the ability for message-driven beans to act as a standard JMS message consumer and perform asynchronous processing between the server and the JMS message producer.
Read More »

EJB Interview Questions

0 comments Posted by Stephen thangaraj at 18:21
EJB Interview Questions

How EJB Invocation happens?



• Retrieve Home Object reference from Naming Service via JNDI


• Return Home Object reference to the client


• Create me a new EJB Object through Home Object interface


• Create EJB Object from the Ejb Object


• Return EJB Object reference to the client


• Invoke business method using EJB Object reference


• Delegate request to Bean (Enterprise Bean).




Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

You can pass the HttpSession as parameter to an EJB method, only if all objects in session are serializable.This has to be consider as ?passed-by-value", that means that it?s read-only in the EJB. If anything is altered from inside the EJB, it won?t be reflected back to the HttpSession of the Servlet Container.The ?pass-byreference? can be used between EJBs Remote Interfaces, as they are remot references. 
Read More »

HCL C++ Interview questions and answers

0 comments Posted by Stephen thangaraj at 02:20
HCL C++ Interview questions and answers


Define structured programming.


Structured programming techniques use functions or subroutines to organize the programming code. The programming purpose is broken into smaller pieces and organized together using function. This technique provides cleaner code and simplifies maintaining the program. Each function has its own identity and isolated from other, thus change in one function doesn’t affect other.


Explain Object oriented programming.
Object oriented programming uses objects to design applications. This technique is designed toisolate data. The data and the functions that operate on the data are combined into single unit. This unit is called an object. Each object can have properties and member functions. You can call member function to access data of an object. It is based on several techniques like encapsulation, modularity, polymorphism, and inheritance.

Read More »

C++ Aptitude Questions and Answers

0 comments Posted by Stephen thangaraj at 02:10
C++ Aptitude Questions and Answers
1.Find the output of the following program
 class Sample
{              
 public:
         int *ptr;
         Sample(int i)
         {
         ptr = new int(i);
         }
         ~Sample()
         {
         delete ptr;
         }
         void PrintVal()
         {
         cout << "The value is " << *ptr;
         }
 };
 void SomeFunc(Sample x)
{
 cout << "Say i am in someFunc " << endl;
}
 int main()
{
 Sample s1= 10;
SomeFunc(s1);
 s1.PrintVal();
}
Read More »

Tcs c++ Apptiude questions and Answers

0 comments Posted by Stephen thangaraj at 02:09
Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived object, calling of that virtual method will result in which method being called? 
a. Base method
b. Derived method..

Ans. b

For the following C program

#define AREA(x)(3.14*x*x)

main()

{float r1=6.25,r2=2.5,a;
a=AREA(r1);
printf("\n Area of the circle is %f", a);
a=AREA(r2);
printf("\n Area of the circle is %f", a);
}
Read More »

Advanced c++ Questions And Answers

1 comments Posted by Stephen thangaraj at 02:08

What is encapsulation??
Containing and hiding information about an object, such as internal data structures and code. Encapsulation isolates the internal complexity of an object's operation from the rest of the application. For example, a client component asking for net revenue from a business object need not know the data's origin.
What is inheritance?
Inheritance allows one class to reuse the state and behavior of another class. The derived class inherits the properties and method implementations of the base class and extends it by overriding methods and adding additional properties and methods.
Read More »

Basic C++ Questions and Answers

0 comments Posted by Stephen thangaraj at 02:06
Basic C++ Questions and Answers

What is C++?



Released in 1985, C++ is an object-oriented programming language created by Bjarne Stroustrup. C++ maintains almost all aspects of the C language, while simplifying memory management and adding several features - including a new datatype known as a class (you will learn more about these later) - to allow object-oriented programming. C++ maintains the features of C which allowed for low-level memory access but also gives the programmer new tools to simplify memory management.


C++ used for:

C++ is a powerful general-purpose programming language. It can be used to create small programs or large applications. It can be used to make CGI scripts or console-only DOS programs. C++ allows you to create programs to do almost anything you need to do. The creator of C++, Bjarne Stroustrup, has put together a partial list of applications written in C++.
How do you find out if a linked-list has an end? (i.e. the list is not a cycle)

You can find out by using 2 pointers. One of them goes 2 nodes each time. The second one goes at 1 nodes each time. If there is a cycle, the one that goes 2 nodes each time will eventually meet the one that goes slower. If that is the case, then you will know the linked-list is a cycle.


What is the difference between realloc() and free()?
The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no action will occur. The realloc subroutine changes the size of the block of memory pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and returns a new pointer to the block. The pointer specified by the Pointer parameter must have been created with the malloc, calloc, or realloc subroutines and not been deallocated with the free or realloc subroutines. Undefined results occur if the Pointer parameter is not a valid pointer.

Read More »

TCS c datastructure questions

0 comments Posted by Stephen thangaraj at 02:05
TCS c datastructure interview Questions questions
1)How do you write a function that can reverse a linked-list?
void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
}
else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0;
cur-> next = head;

for(; curnext!=0; )
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}

curnext->next = cur;
}
}

Read More »

C,C++ Questions

0 comments Posted by Stephen thangaraj at 02:04

1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived  object,. calling of that virtual method will result in which method being called? 


a. Base method 

b. Derived method..

Ans. b


2. For the following C program

#define AREA(x)(3.14*x*x)

main()
{float r1=6.25,r2=2.5,a;
a=AREA(r1);
printf("\n Area of the circle is %f", a);
a=AREA(r2);
printf("\n Area of the circle is %f", a);
}

What is the output?

Ans. Area of the circle is 122.656250

        Area of the circle is  19.625000



3. What do the following statements indicate. Explain.
·         int(*p)[10]
·         int*f()
·         int(*pf)()
·         int*p[10]

Refer to:

-- Kernighan & Ritchie page no. 122

-- Schaum series page no. 323


Read More »

Technical interview questions -c++

1 comments Posted by Stephen thangaraj at 01:58
Technical interview questions -c++
What is a class? 
What is an object?
What is the difference between an object and a class?
What is the difference between class and structure?
What is public, protected, private?
What are virtual functions?
What is friend function?
What is a scope resolution operator?
What do you mean by inheritance?
What is abstraction?
Read More »

Latest C Interview questions

0 comments Posted by Stephen thangaraj at 18:14
Here are the important Latest – New – Recent Reasoning, aptitude questions and C / C++ language programs (to find errors / output) for TCS Placement Paper:
TCS Placement Test Paper Questions:
1. fn(int n,int p,int r)
{
static int a=p;
switch(n);
{
case4: a+ = a*r;
case3: a+ = a*r;
case2: a+ = a*r;
case1: a+ = a*r;
}
}
The aboue programme calculates
a.Compound interest for 1 to 4 years
b.Amount of Compound interest for 4 years
c.Simple interest for 1 year
d.Simple interest for 4 year
Read More »

TCS C Questions

0 comments Posted by Stephen thangaraj at 18:05
TCS C  Questions
1. Difference between "C structure" and "C++ structure".
2. Diffrence between a "assignment operator" and a "copy constructor"
3. What is the difference between "overloading" and "overridding"?
4. Explain the need for "Virtual Destructor".
5. Can we have "Virtual Constructors"?
6. What are the different types of polymorphism?

Read More »

Depth C language job interview Questions

0 comments Posted by Stephen thangaraj at 17:57
   Depth C language job interview Questions
1. Difference between "C structure" and "C++ structure".
2. Diffrence between a "assignment operator" and a "copy constructor"
3. What is the difference between "overloading" and "overridding"?
4. Explain the need for "Virtual Destructor".
5. Can we have "Virtual Constructors"?
6. What are the different types of polymorphism?
7. What are Virtual Functions? How to implement virtual functions in "C"
8. What are the different types of Storage classes?
9. What is Namespace?
10. What are the types of STL containers?.
Read More »

Blog Archive

 

© 2011. All Rights Reserved | Interview Questions | Template by Blogger Widgets

Home | About | Top