Skip to main content

Posts

Showing posts from September, 2015

Java question

  Java ques interview Ques:-List any five features of Java?  Ans :-Some features include Object Oriented, Platform Independent, Robust, Interpreted, Multi-threaded Ques . write full form of jdbc & odbc ?  Ans :-  JDBC -java database connectivity.             ODBC - open database connectivity Ques:- what are types of packages ? Ans: 1. Pre-defined packages 2. User defined packages Ques :-Define class?  Ans:- A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object. Ques:- Denfie string bulider? Ans :- Use StringBuilder whenever possible because it is faster than StringBuffer. But, if thread safety is necessary then use StringBuffer objects. Ques :- What is Singleton class?  Ans:Singleton class control object creation, limiting the number to one but allowing the flexibility to create m...

Program for print pattern

Program Write a java program to generate the following pattern String : computer c co com comp compu comput compute computer class Pattern {             public static void main(String args[])             {                         String s=new String(args[0]);                         for(int i=1;i<=s.length();i++)                         {                            ...

read a string and reverse

Program- Write a java program to read a string and reverse it class Reverse {             public static void main(String args[])             {                         String s=new String(args[0]);                         String rev=new String("");                  /* find the reverse of the string */                         for(int i=s.length()-1;i>=0;i--)              ...

String class methods:

String class methods: 1.       charAt(): This method is used to extract the character from a particular index position. E.g:            String s=new String(“computer”);            System.out.println(s.charAt(2)); Output:            m 2.     length(): This method is used to return the length of the string . That is , the total number of characters present in it . The general form is,             length() E.g.             String s=new String("computer");             System.out.println("length="+s.length()); Output:             Length=8

STRING WITH STRING CONSTRUCTORS

String: The class String and Stri ng Buffer are part of the java. lang package. String is a sequence of characters. But unlike many other languages that implement string as characters arrays, java implement string as object of type string. Implementing string as built in objects allows java to provide a full complement of features that make string handling convenient. Also string objects can be constructed a number of ways, making it easy to obtain when needed. The string handling  in the java is done with the help of the two classes present in the package java.lang                         i.  String                         ii. StringBuffer 1. String: String is a sequence of character and to store them we will use the object of the S...

Throw statement :

T hrow statement : The throw statement is used to explicitly raise the exception . The general form is             throw new Exceptiontype(); PROGRAM class ExceptionDem7 {             public static void main(String args[ ])             {                         try                         {                                     int a,b;             ...

Exception handling with multiple catch

PROGRAM- class ExceptionDem6 {             public static void main(String args[ ])             {             try                     {                                     int a=Integer.parseInt(args[0]);                                     int b=Integer.parseInt(args[1]);                   ...

PROGRAM OF EXCEPTIONHANDLING WITH FINAL

PROGRAM- class ExceptionDem4 {             public static void main(String args[ ])             {                System.out.println("In the Main block");                try                {                   System.out.println("In the try block");                   int a=Integer.parseInt(args[0]);                   int b=Integer.parseInt(args[1]);               ...