Skip to main content

Posts

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