StringBuffer Trim Java Example

[ad_1]

 /*
StringBuffer Trim Java Example
This example shows how to trim StringBuffer object in Java using substring method.
*/

public class JavaStringBufferTrimExample {

public static void main(String[] args) {

//create StringBuffer object
StringBuffer sbf = new StringBuffer(" Hello World ! ");

/*
* Method 1: convert StringBuffer to string and use trim method of
* String.
*/

String str = sbf.toString().trim();

System.out.println("StringBuffer trim: "" + str +"""""");

[ad_2]

Molecular Biology Questions and Answers – Recombination in Higher Organisms – 2

[ad_1]

This set of Molecular Biology Question Paper focuses on “Recombination in Higher Organisms – 2”.

1. What is the central protein of homologous recombination?
a) RecB
b) RecD
c) RecA
d) RecC
View Answer

Answer: c
Explanation: RecA is the central protein of homologous recombination. It is the founding member of a family of enzymes called the strand exchange protein.

2. What is the joint molecule?
a) RecB of the RecBCD pathway
b) B DNA
c) Z DNA
d) Rec A bound three stranded structure
View Answer

Answer: d
Explanation: The RecA bound three stranded structure is known as the joint molecule. It usually contains several hundred base pairs of hybrid DNA.

3. The RuvAB complex specifically recognizes the Holliday junction in a ATP dependent manner.
a) True
b) False
View Answer

Answer: a
Explanation: RuvA recognizes and binds to the Holliday junction and recruits RuvB protein to this site. RuvB is a hexameric ATPase thus making the process an ATP dependent one.

4. Which component cleaves the specific DNA strands at the Holliday junction?
a) RuvC
b) RuvD
c) RuvA
d) RuvB
View Answer

Answer:
Explanation: RuvC recognizes the Holliday junction. It specifically nicks two of the homologous DNA strands that have the same polarity.

5. After cleaved by RuvC the resulting ligated recombination products will only be the splice product.
a) True
b) False
View Answer

Answer: b
Explanation: Depending on which pair of strands is cleaved by RuvC the resulting recombinant product will depend. It either forms a spliced product or a patched product.

6. What is the cleavage site of RuvC?
a) 5’….A/TTTG/C….3’
b) 5’….G/TTTC/T….3’
c) 5’….T/TGCG/C….3’
d) 5’….C/ATTG/T….3’
View Answer

Answer: a
Explanation: Cleavage by RuvC takes place at sites conforming to the consensus sequence 5’….A/TTTG/C….3’. cleavage occurs after the second T in this sequence.

7. What is the source of energy during the action of SPO11?
a) Cleavage of peptide bond
b) Cleavage of amide bond
c) Cleavage of glycoside bond
d) Cleavage of phosphodiester bond
View Answer

Answer: d
Explanation: During the action of SPO11 the cleavage of DNA phosphodiester bond is stored in the bound protein-DNA linkage. By this process the DNA strands can be released.

8. What are the components of the MRX protein?
a) MreII, Rad50, Xrs2
b) Rad51, Rad52, Rad59
c) RecA, RuvC, RuvAB
d) Rad51C, WRN, BLH
View Answer

Answer: a
Explanation: MRX enzyme complex is used for the event of DNA processing. It is composed of protein subunits, MreII, Rad50 and Xrs2. The first letters of the subunits gives the complex its name.

9. Processing of the DNA at the break site occurs at the 3’ end.
a) True
b) False
View Answer

Answer: b
Explanation: Processing of the DNA at the break site occurs exclusively at the 5’ terminus. The strand ic covalently attached to the Spo11 protein.

10. How many cycles are required for the configuration of chromosomes?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
Explanation: Chromosomes are configured during two division cycles. This is because meiosis involves two rounds of nuclear divisons.

11. What is non-disjunction?
a) Proper alignment
b) Sister chromatid formation
c) Failed alignment
d) Chromosome segregation
View Answer

Answer: c
Explanation: The absence of recombination leads to the failed alignment of the chromosomes in the 1st meiotic division and as a result there is a high incidence of chromosome loss. This improper segregation of chromosomes is called nondisjunction.

12. For which biological phenomenon homologous recombination is critical?
a) Mitosis
b) Meiosis
c) Fragmentation
d) Sporing
View Answer

Answer: b
Explanation: Homologous recombination is critical for meiosis during the pachytene stage of meiosis I. This is important for the introduction of genetic variations in every generations.

13. What are homologs?
a) Part of DNA
b) Pair of nucleus
c) Pair of chromosomes
d) Part of a cell
View Answer

Answer: c
Explanation: Before cell division the cell has two copies of each chromosome, one of each was inherited from either parent. These are known as homologs.

14. What is the function of the Spo11 in meiotic recombination?
a) Introduction of mutation
b) Introduction of nick
c) Introduction of DSB
d) Introduction of lesion
View Answer

Answer: c
Explanation: Spo11 gene encodes a protein that introduces DSBs in chromosomal DNA to initiate meiotic recombination. The Spo11 protein cuts the DNA at many chromosomal locations with little sequence selectivity but at a very specific time during meiosis.

15. How many subunits of Spo11 are involved in the process of cleavage of DNA?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
Explanation: The two subunits of Spo11 cleave the DNA two nucleotides apart on the two DNA strands. It makes staggered double strand break by cleavage.

Sanfoundry Global Education & Learning Series – Molecular Biology.

To practice all questions papers on Molecular Biology, here is complete set of 1000+ Multiple Choice Questions and Answers.

[ad_2]

Source link

10a. Advanced WebDriver – Using Apache ANT

[ad_1]

Hiya folks! Do you have ANTs in your build? Just kidding! Actually, I am not. Agreed that it sounds weird, but don’t fear as I am here! (Now, that’s what I call, rhyming.)

Today, let us ponder about what exactly this Apache ANT is and why it takes its place as an important building block in the construction of a WebDriver framework. By the end of this post, you should be able to handle any ANT project in general.

Jumping right in:

Another Neat Tool provided by The Apache Software Foundation is a build tool written in Java. It is old (Maven is winning this space and Gradle is getting along), quite popular and can still be found in most of the projects. The beauty of Apache ANT is that it only does what it is told to do. There isn’t much magic that is happening under the hood. (Beware, this can be a double-edged sword at times!)

To create an executable would mean,

  • Compiling the required .java files under the src folder
  • Creating the Manifest file for the JAR
  • Zipping all the .class files along with the manifest file
  • Using the jar command to create the executable

But with Apache ANT all these steps can be handled with a simple Target (we will see what a Target is, in a minute!).

Everything to be achieved is specified in an XML file, in a structured and modular way making it very easy to identify if something breaks. And this file is known as the famous, “build.xml”.

Apache ANT comes with a default buildfile named, build.xml. We can always edit or create a new XML file to suit our needs. This is basically a command-line tool. So, it is very easy to run Apache ANT from the command prompt using the command, “ant build_file_name.xml”. The best part here is, in case you did not rename the build.xml (just modified the provided default or created your own and named it build.xml), then just the command, “ant” would automatically know to look for build.xml and do what it is made for!

Apache ANT gives a lot of power, enough to cross the Thank You threshold! We can,

  • Clean up the project
  • Compile source code
  • Generate a distributable JAR or WAR
  • Handle code from version control systems such as CVS, SVN etc.
  • Echo messages to loggers and listeners at a specified level (error, warning, info, verbose, debug)
  • Create or delete directories
  • Copy, move, delete files
  • Can zip, unzip, tar, untar, unjar, unwar files
  • Execute JUnit tests, test scripts etc.
  • Execute a series of SQL statements via JDBC to a database
  • Generate JUnit test report

And do much much more…

And guess what, it sounds intimidating but every single thing that I have mentioned so far can be achieved with just the buildfile.

Time to juggle with the elements of the much-hyped, buildfiles. These are written in XML.

Sticky Note: Below information is enough to get familiarized with an Apache ANT buildfile. For in depth knowledge, please visit the Apache ANT user manual. (http://ant.apache.org/manual/)

Each buildfile has,

  1. Project – contains a minimum of one Target
  2. Target – set of Tasks that perform a unit of work
  3. Task – piece of code that can be executed

Sample build.xml file is as follows,

sample build.xml

Let us distill the buildfile one tag at a time.

Project: This has three attributes.

  1. name – The name of the project
  2. default – The default target that should be executed in case nothing is provided
  3. baseDir – The base directory from which the relative paths in the file are calculated. “.” refers to the current directory from which execution takes place

Target: As shown in the sample buildfile, a project can have one or more targets. Target is a set of Tasks. We can select which targets we would like ANT to execute by their names separated by commas. When no target is specified, then the default target is executed.

The important attribute to note here is “depends”. This specifies the target name that it is dependent on. For example, the compile target will execute only after its dependent, init target is executed. Thus, depends attribute specifies the order in which targets are to be executed.

Task: This is a piece of code that can be executed. Each task can have one or more attributes as key-value pairs.

Syntax:

<name attribute1=”value1attribute2=”value2” … />

name is the name of the task, attributeN and valueN are the attribute and value names respectively.

Here is a long list of built-in tasks that come right out of the box. We can code our own tasks as well. (Remember? It is all written in Java).

You must be wondering, why to go so deep into buildfiles rather than just installing it straight away and start some action! There is a reason for imparting so much ANT knowledge. And you will appreciate me for that as we go further in our journey. Just wait and watch…

Down to business now!

Step 1: Go to, ‘https://ant.apache.org/bindownload.cgi’ and click on ‘apache-ant-1.10.2-bin.zip’ to download the .zip file under ‘Current Release of Ant’.

Download link

Step 2: Once the .zip archive is downloaded, extract all the files to a directory on your local machine.

Step 3: Set the environment variables, ANT_HOME and Path as follows,

Right click on ‘Computer’ -> Properties -> Advanced system settings -> ‘Advanced’ tab -> Environment Variables -> Click ‘New’ under system variables.

ANT_HOME is set to the path of the folder in which Apache ANT files are extracted.

System variable settings

Similarly edit the Path variable to include %ANT_HOME%bin.

Step 4: Verify if Apache ANT is installed by typing the following command in ‘Command Prompt’

ant -version

ANT version check in cmd

Step 5: Next task is to open Eclipse IDE,

  • Right-click on the Java project -> Export
  • Under ‘General’, select ‘Ant Buildfiles’ and click ‘Next’
  • Make sure the required project is selected
  • Uncheck ‘Create target to compile project using Eclipse compiler’ in order to remove any dependency on Eclipse

Generating ANT buildfile

Click on ‘Finish’ to see an eclipse auto-generated build.xml file.

And that’s it! You are all set to run your project as ANT build. It is laughably simple, isn’t it?

Sticky Note: Eclipse comes integrated with ANT. In order to make sure Eclipse’s ‘Ant Home’ points to the latest version of ANT, click on Windows -> Preferences -> Ant -> Runtime. Click on the ‘Classpath’ tab. Expand ‘Ant Home Entries’ and verify the path. If it is pointing to a different version, then click ‘Ant Home’ and browse the location of the folder in which Apache ANT files are extracted.

In our next post let us do just that and generate a JUnit report with the help of an ANT target.

Happy installing!

Series Navigation

<< 9z. WebDriver – Window maximize

[ad_2]

StringBuffer toString Java Example

[ad_1]

/*

StringBuffer toString Java Example

This example shows how to convert StringBuffer to String in Java using

toString method of String class.

*/

 

public class JavaStringBufferToStringExample {

 

public static void main(String args[]){

//create StringBuffer object

StringBuffer sbf = new StringBuffer(“Hello World!”);

/*

* To convert StringBuffer to String object, use

* String toString() method of StringBuffer class.

*/

String str = sbf.toString();

System.out.println(“StringBuffer to String: “ + str);

}

}

 

/*

Output of above given StringBuffer to String example would be

StringBuffer to String: Hello World!

*/

[ad_2]

Energy Engineering Questions and Answers – Applications of Biogas & Gasifier

[ad_1]

This set of Energy Engineering Multiple Choice Questions & Answers (MCQs) focuses on “Applications of Biogas & Gasifier”.

1. What is the percentage at which rated power from biogas in petrol engine can be developed?
a) 45%
b) 65%
c) 75%
d) 85%
View Answer

Answer: d
Explanation: Petrol engine can be operated on biogas after initially starting with petrol. Petrol replacement of 1005 is possible and petrol engines can develop about 85% of rated power where as diesel engine can develop full power.

2. Which engine can run on dual fuel with little engine modification?
a) Diesel engine
b) Petrol engine
c) IC engine
d) External combustion engine
View Answer

Answer: a
Explanation: Diesel engine can run on dual fuel with little engine modifications. Advancing the injection timing and entry of biogas with intake air, it can be achieved by providing a mixing chamber below the air cleaner which facilitates mixing of biogas with air before entering into the cylinder.

3. Which of the SI engine can be run on biogas?
a) Diesel engine
b) Petrol engine
c) IC engine
d) External combustion engine
View Answer

Answer: b
Explanation: Petrol engine can run on biogas, but it is required to be started with petrol in the beginning. Petrol engine can be modified for operation on biogas including provision for entry of biogas, throttling of intake air and advancing ignition timing.

4. What does CNG stands?
a) Converted natural gas
b) Compressed natural gas
c) Compressed Non-soluble gas
d) Compressed natural gasoline
View Answer

Answer: b
Explanation: Compressed natural gas (CNG) (methane stored at high pressure) is a fuel which can be used in place of gasoline (petrol), Diesel fuel and propane/LPG. CNG combustion produces fewer undesirable gases than the fuels mentioned above.

5. What is the full form of VRA?
a) Vibration resistant appliance
b) Vehicle Refueling Appliances
c) Volatile removal assembly
d) Validated requirement authority
View Answer

Answer: b
Explanation: Vehicle refueling appliance is abbreviated as VRAs. Certified natural gas compressors for refueling the vehicles are commercially available. These allow refueling at home and work. After upgrading with the above-mentioned technologies, the biogas (transformed into biomethane) can be used as vehicle fuel in adapted vehicles.

6. A device for converting substances (chemically or physically) into gas is called ______
a) Gasifies
b) Biogas plants
c) Draughts
d) Gas chambers
View Answer

Answer: a
Explanation: The word Gasification implies converting a solid or liquid into a gaseous fuel without leaving any solid carbonaceous residue. Gasifier is a equipment which can gasify a variety of biomass such as wood waste, agricultural waste like stalks, and roots of various crops. The gasifier is essentially a chemical reactor where various complex physical and chemical processes take place.

7. How many types of gasifiers are there?
a) 2
b) 3
c) 4
d) 5
View Answer

Answer: c
Explanation: There are four types of gasifiers namely:
1. Up draught or counter current gasifier.
2. Down draught or co-current gasifier.
3. Cross draught gasifier.
4. Fluidized bed gasifier.

8. Which is the oldest and simplest type of gasifier?
a) Counter current gasifier
b) Cross draught gasifier
c) Co-current gasifier
d) Fluidized bed gasifier
View Answer

Answer: a
Explanation: The oldest and simplest type of gasifier is the counter current or up draught gasifier. The major advantage of this type of gasifier are its simplicity, high charcoal burnout and internal heat exchange leading to low gas exit temperatures and high equipment efficiency.

9. Which is the gasifier that can be operated in small scale/amounts?
a) Counter current gasifier
b) Cross draught gasifier
c) Co-current gasifier
d) Fluidized bed gasifier
View Answer

Answer: b
Explanation: It is actually the advantage of this system that it is capable of handling very small amounts for operation. Installations below 10 KW can under certain conditions be economically feasible. The reason is the very simple gas cleaning train which can be employed when using this type of gasifier.

10. Which gasifier has better tar converting capacity?
a) Counter current gasifier
b) Cross draught gasifier
c) Co-current gasifier
d) Fluidized bed gasifier
View Answer

Answer: c
Explanation: A solution to the problem of tar entrainment in the gas stream has been found by designing co-current or down draught gasifiers, in which primary gasification air is introduced at or above the oxidation zone in the gasifier.

11. Which gasifier has a minimum tar converting capability?
a) Counter current gasifier
b) Cross draught gasifier
c) Co-current gasifier
d) Fluidized bed gasifier
View Answer

Answer: b
Explanation: A disadvantage of cross draught gasifiers is their minimal tar converting capacity and the consequent needs for the high quality charcoal. It is because of the uncertainty of charcoal quality that a number of charcoal gasifiers employ down draught principle, in order to maintain at least a minimal tar cracking capability.

12. Which gasifier equipment has inability to operate on a number of unprocessed fuels?
a) Counter current gasifier
b) Cross draught gasifier
c) Co-current gasifier
d) Fluidized bed gasifier
View Answer

Answer: c
Explanation: Down draught gasifier or co-current gasifiers equipment lies in its inability to operate on a number of unprocessed fuels. In particular, fluffy, low density materials give rise to flow problems and excessive pressure drop and the solid fuel must be pelletized before use.

Sanfoundry Global Education & Learning Series – Energy Engineering.

To practice all areas of Energy Engineering, here is complete set of 1000+ Multiple Choice Questions and Answers.

[ad_2]

Source link