359). Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?

[A] getBytes()
[B]GetByte()
[C]giveByte()
[D]Give Bytes()

Show Answer

360). In the following Java code, what can directly access and change the value of the variable name?
 package test;
 class Target 
 {
  public String name = "hello";
 }

[A] any class
[B]only the Target class
[C]any class in the test package
[D] any class that extends Target

Show Answer

361). What will be the output of the following Java code?
public class Boxer1 
{
    Integer i;
    int x;
   public Boxer1(int y) 
   {
        x = i+y;
        System.out.println(x);
   }
   public static void main(String[] args) 
   {
       new Boxer1 (new Integer(4));
   }
}

[A]The value “4” is printed at the command line
[B]Compilation fails because of an error in line
[C]A NullPointerException occurs at runtime
[D]An IllegalStateException occurs at runtime

Show Answer

362). Which of these methods can be used to convert all characters in a String into a character array?
public class Boxer1 
{
    Integer i;
    int x;
   public Boxer1(int y) 
   {
        x = i+y;
        System.out.println(x);
   }
   public static void main(String[] args) 
   {
       new Boxer1 (new Integer(4));
   }
}

[A]charAt()
[B] both getChars() & charAt()
[C]both toCharArray() & getChars()
[D] all of the mentioned

Show Answer

363). What will be the output of the following Java code?
    class output 
    {
        public static void main(String args[])
        { 
           String c = "Hello i love java";
           int start = 2;
           int end = 9;
           char s[]=new char[end-start];
           c.getChars(start,end,s,0);
           System.out.println(s);
        }
    }

[A]Hello, i love java
[B]i love ja
[C] lo i lo
[D] llo i l

Show Answer

364). What will be the output of the following Java code?
    class output 
    {
        public static void main(String args[])
        {
            String a = "hello i love java";
            System.out.println(a.indexOf('i')+" "+a.indexOf('o') +" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o'));
        }
    }

[A] 6 4 6 9
[B]5 4 5 9
[C]7 8 8 9
[D]4 3 6 9

Show Answer

365). What will be the output of the following Java code?
    class output 
    {
        public static void main(String args[])
        {
            char c[]={'a', '1', 'b' ,' ' ,'A' , '0'};
            for (int i = 0; i < 5; ++i)
            {
                   if(Character.isDigit(c[i]))
                       System.out.println(c[i]+" is a digit");
                   if(Character.isWhitespace(c[i]))
                       System.out.println(c[i]+" is a Whitespace character");
                   if(Character.isUpperCase(c[i]))
                       System.out.println(c[i]+" is an Upper case Letter");
                   if(Character.isLowerCase(c[i]))
                       System.out.println(c[i]+" is a lower case Letter");
               i=i+3;
            }
        }
    }

[A] a is a lower case Letter is White space character
[B] b is a lower case Letter is White space character
[C] a is a lower case Letter A is an upper case Letter
[D] a is a lower case Letter 0 is a digit

Show Answer

366). What will be the output of the following Java code?
    class output 
    {
        public static void main(String args[])
        {
            char ch;
            ch = "hello".charAt(1);
            System.out.println(ch);
        }
   }

[A]h
[B]e
[C]I
[D]o

Show Answer