Prepare Interview

Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address
Check our LIVE MOCK INTERVIEWS

ANT Interview Questions and Answers

Freshers / Beginner level questions & answers

Ques 1. What is ANT?

ANT full form is Another Needed Tool. Ant is a build tool that is java based. A build tool performs the following tasks:

Compiling java code into byte code
Placing this byte code in a package
Deployment to production systems
Document creation and release notes preparation.

Is it helpful? Add Comment View Comments
 

Ques 2. Explain ANT functionality.

Ant is an open source project available under the Apache license. Therefore, its source code can be downloaded and modified. 


Additionally, Ant uses XML build files which make its development easy.
Cross Platform.

Use of XML along with Java makes Ant makes it the perfect solution for developing programs designed to run or be built across a range of different operating systems.
Extensible.

New tasks are used to extend the capabilities of the build process, while build listeners are used to help hook into the build process to add extra error tracking functionality.

As Ant is extensible and open, it can be integrated with any editor or development environment easily.

Is it helpful? Add Comment View Comments
 

Ques 3. Explain using ANT and give an small example.

Before start using ANT, we should be clear about the project name and the .java files and most importantly, the path where the .class files are to be placed.

For example, we want the application HelloWorld to be used with ant. The Java source files are in a subdirectory called Dirhelloworld, and the .class files are to put into a sub directory called Helloworldclassfiles.

1. The build file by name build.xml is to be written. The script is as follows


<project name=”HelloWorld” default=”compiler” basedir=”.”> 
<target name=”compiler”> 
<mkdir dir = “Helloworldclassfiles”> 
<javac srcdir=”Dirhelloworld” destdir=”Helloworldclassfiles”> 
</target> 
</project>

2. Now run the ant script to perform the compilation:

C :\> ant
Buildfile: build.xml

and see the results in the extra files and directory created:

c:\>dir Dirhelloworld
c:\>dir Helloworldclassfiles

All the .java files are in Dirhelloworld directory and all the corresponding .class are in Helloworldclassfiles directory.

Note: mkdir command is to be used in MS-DOS and mk dir command is to be used in UNIX/Linux

Dir command is to be used in MS-DOS and ls command is to be used in UNIX /Linux

Is it helpful? Add Comment View Comments
 

Ques 4. How to set Classpath in Ant script?

The following is the code snippet to set the classpath in ant:

<path id=”build.classpath”>
<fileset dir=”${build.lib}” includes=”**/*.jar/>
<fileset dir=”${build.class”}/>
</path>

<target….>
<javac….>
<classpath field=”build.classpath”/>
</javac>
</target>

<target….>
<javac….>
<classpath field=”build.classpath”/>
</javac>
</target>

Is it helpful? Add Comment View Comments
 

Ques 5. Explain how to compile using Ant script?

<target name="compile" depends="-init">
<mkdir dir="${build.dir}/classes" />
<javac destdir="${build.dir}/classes" includeantruntime="false" debug="true" optimize="true" verbose="false" deprecation="false" source="1.5" target="1.5">
<classpath refid="classpath.base" />
<src path="${src.dir}/main/java" />
</javac>
</target>

Is it helpful? Add Comment View Comments
 

Ques 6. Explain how to test classes for JUnit using Ant script?

<target name="test" depends="-copytestresources, compile">
<mkdir dir="${build.dir}/junit-reports" />
<junit printsummary="false"
fork="on"
haltonfailure="false"
failureproperty="test.failure">
<classpath refid="classpath.junit" />
<formatter type="plain" />
<batchtest todir="${build.dir}/junit-reports">
<fileset dir="${build.dir}/test-classes" includes="**/*Test.class" />
</batchtest>
</junit>
<junitreport tofile="target/junit-reports/TEST.xml">
<fileset dir="${target}/junit-reports" includes="TEST-*.xml" />
<report format="frames" todir="${target}/junit-reports" />
</junitreport>
</target>

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

Related interview subjects

REST API interview questions and answers - Total 52 questions
Unix interview questions and answers - Total 105 questions
SDLC interview questions and answers - Total 75 questions
Apache Kafka interview questions and answers - Total 38 questions
Language in C interview questions and answers - Total 80 questions
ANT interview questions and answers - Total 10 questions
Nature interview questions and answers - Total 20 questions
Ruby On Rails interview questions and answers - Total 74 questions
Business Analyst interview questions and answers - Total 40 questions
HTML interview questions and answers - Total 27 questions
Hadoop interview questions and answers - Total 40 questions
iOS interview questions and answers - Total 52 questions
HR Questions interview questions and answers - Total 49 questions
C++ interview questions and answers - Total 142 questions
Cryptography interview questions and answers - Total 40 questions
JSON interview questions and answers - Total 16 questions
CSS interview questions and answers - Total 74 questions
XML interview questions and answers - Total 25 questions
Ethical Hacking interview questions and answers - Total 40 questions
Android interview questions and answers - Total 14 questions
ChatGPT interview questions and answers - Total 20 questions
Data Structures interview questions and answers - Total 49 questions
Zend Framework interview questions and answers - Total 24 questions
Fashion Designer interview questions and answers - Total 20 questions
©2023 WithoutBook