Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


naresh
Corejava
1 Answer(s)      4 years ago
Posted in : Java Interview Questions


1. Convert input date format from (dd/mm/yyyy) to (yyyymmdd)
2. Remove a character at a specified position using substring method
3. Tokenize an input string by using both split & StrinTokenizer and store it in an ArrayList or Vector and display them in a console.
4. Divide one BigDecimal from another BigDecimal
5. Read an input file and find the occurences of lines having only numeric values by using Pattern class.

Advertisement
View Answers

August 4, 2010 at 5:56 PM


Hi Friend,

4)

import java.math.*;
import java.util.*;
class DivideBigDecimal
{
public static void main(String[] args)
{
Scanner input =new Scanner(System.in);
System.out.println("Enter number 1: ");
int n1=input.nextInt();

System.out.println("Enter number 2: ");
int n2=input.nextInt();

BigDecimal b1=new BigDecimal(n1);
BigDecimal b2=new BigDecimal(n2);
BigDecimal result=b1.divide(b2);
System.out.println(result);

}
}

3)
using StringTokenizer:

import java.util.*;
public class String_Example{
public static void main(String[]args){
StringTokenizer st=new StringTokenizer("Welcome to roseindia");
ArrayList list=new ArrayList();
while(st.hasMoreElements())
{
String token = st.nextElement().toString();
list.add(token);
}
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
}
}

using split() method:

import java.util.*;
public class String_Example{
public static void main(String[]args){
String st="Welcome to roseindia";
ArrayList list=new ArrayList();
String str[]=st.split(" ");
for(int i=0;i<str.length;i++){
list.add(str[i]);
}
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
}
}

Thanks


Related Tutorials/Questions & Answers:
CoreJava Project
CoreJava Project  Hi Sir, I need a simple project(using core Java, Swings, JDBC) on core Java... If you have please send to my account
Advertisements
corejava - Java Beginners
corejava pass by value semantics  Example of pass by value semantics in Core Java.  Hi friend,Java passes parameters to methods using pass by value semantics. That is, a copy of the value of each of the specified
Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
;    Q 1. When should I use the abstract class rather...;   Q 2. What is hashcode? When is hashCode() used ? Ans : ... use the equals method to make an exact match.    Q 3. How can I get
Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
;    Q 1. How can I get the full path of Explorer.exe... that system can be access from an applet loaded via the Internet.     Q 2....   Q 3. Is it possible to convert a string to an abstract path ? Ans
Corejava Interview,Corejava questions,Corejava Interview Questions,Corejava
;    Q 1 : How should I create an immutable class ? Ans...; Q 2 : Is println overloading or overriding ?  Ans : The println() method...;     Q 3 : What is dynamic method dispatch ?  Ans
JList
JList  pls tell me about the concept the JList in corejava? and tell me a suitable example
core java - Java Beginners
core java  how to create a login page using only corejava(not servlets,jsp,hibernate,springs,structs)and that created loginpage contains database(ms-access) the database contains data what ever u r enter and automatically date
HOW TO BECOME A GOOD PROGRAMMER
HOW TO BECOME A GOOD PROGRAMMER  I want to know how to become good programmer   Hi Friend, Please go through the following link: CoreJava Tutorials Here you will get lot of examples with illustration where you can
What is Locale - Java Beginners
://www.roseindia.net/tutorial/java/corejava/javatext
Eclipse - IDE Questions
Eclipse  Hi To All.. I am new to ECLIPSE IDE. Please suggest me any book which can give me complete idea of setting environment and development with basic to advance development of java like(corejava,servlet,jsp,struts,ejb
Java Locale
/corejava/javatext/parseAndFormatDateUsingLocale.html Thanks
autentication & authorisation - JSP-Servlet
/interviewquestions/corejava/null-marker-interfaces-in-java.shtml Thanks
Inter Thread Communication
://www.devmanuals.com/tutorials/java/corejava/InterthreadCommunication.html
how to count words in string using java
how to count words in string using java  how to count words in string using corejava   Hi Friend, Try the following code: import java.util.*; class CountWords{ public static void main(String[] args
Factorial Program in Java
"); } } } Output C:\Documents and Settings\bharat\Desktop\bipul\CoreJava\Swing Example...\bipul\CoreJava\Swing Example\Factorial> java Factorial1 enter
using oops concepts - Development process
total source code in corejava using oops concepts.  Hi
Interthread Communication in Java
. This tells the Consumer that it should now remove it. package corejava...(); } } class Producer implements Runnable { Queue q; Producer(Queue q) { this.q = q... Runnable { Queue q; Consumer(Queue q) { this.q = q; new Thread(this, "
JAXB Create XML File And Get Data From XML
{ File file = new File("C:\\Documents and Settings\\bharat\\Desktop\\bipul\\CoreJava... File("C:\\Documents and Settings\\bharat\\Desktop\\bipul\\CoreJava
help me in these - Java Interview Questions
use the corejava.*  Hi Friend, 1) import java.util.*; public class
Mutliple files upload
; if (skilltype == "Java") { list = new Array("CoreJava","J2EE","J2SE..."); listValue = new Array("CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload
; if (skilltype == "Java") { list = new Array("CoreJava","J2EE","J2SE..."); listValue = new Array("CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload
; if (skilltype == "Java") { list = new Array("CoreJava","J2EE","J2SE..."); listValue = new Array("CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload
== "Java") { list = new Array("CoreJava","J2EE","J2SE..."); listValue = new Array("CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
Mutliple files upload
; if (skilltype == "Java") { list = new Array("CoreJava","J2EE","J2SE..."); listValue = new Array("CoreJava","J2EE","J2SE","Struts","Hibernet","Springs","JSP
JSF Basic Interview Questions
strong basic knowledge of corejava and related web technologies. For your
 

 

 

DMCA.com