Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

JAVA QUESTIONS : PART 4

Which of these keywords is used to prevent content of a variable from being modified?

final
last
constant
static
SHOW ANSWER

Which of these cannot be declared static?

class
object
variable

method

SHOW ANSWER

Which of these methods must be made static?

main()
delete()
run()
finalize()
SHOW ANSWER

What is the output of this program?


        class access{
    
        public int x;
    
     static int y;
    
        void cal(int a, int b){
    
            x +=  a ;
    
            y +=  b;

            }
        
    }
        
    class static_specifier {
    
        public static void main(String args[]){
    
            access obj1 = new access();
    
            access obj2 = new access();
        
            obj1.x = 0;
    
            obj1.y = 0;
    
            obj1.cal(1, 2);

                obj2.x = 0;
    
            obj2.cal(2, 3);

                System.out.println(obj1.x + " " + obj2.y);
         
        }
    
   }

1 2
2 3
3 2
1 5
SHOW ANSWER

What is the output of this program?
    

    class access{
    
       static int x;
    
       void increment(){
    
           x++;
    
       }
        
     }
   
             class static_use {

            public static void main(String args[]){
    
            access obj1 = new access();
    
            access obj2 = new access();
    
            obj1.x = 0;
        
            obj1.increment();
    
            obj2.increment();
    
            System.out.println(obj1.x + " " + obj2.x);

                }
      
   }
 

1 2
1 1
2 2
Compilation Error
SHOW ANSWER

What is the output of this program?

 
    class Output {
    
        public static void main(String args[]){
    
            int arr[] = {1, 2, 3, 4, 5};
    
            for ( int i = 0; i < arr.length - 2; ++i)
    
                System.out.println(arr[i] + " ");
    
        }
    }
 

1 2
1 2 3
1 2 3 4
1 2 3 4 5

SHOW ANSWER

String in Java is a?

class
 object
variable
character array
SHOW ANSWER

Which of these method of String class is used to obtain character at specified index?

char()
Charat()
charAt()
SHOW ANSWER

Which of these keywords is used to refer to member of base class from a sub class?

upper
super
this
None of the mentioned
SHOW ANSWER

Which of these method of String class can be used to test to strings for equality?

isequal()

isequals()
equal()
equals()

SHOW ANSWER

What is the output of this program?
    

   class string_demo {
    
        public static void main(String args[]){
    
            String obj = "I" + "like" + "Java";
       
         System.out.println(obj);
        
        }
       }

I
like
Java
IlikeJava
SHOW ANSWER

What is the output of this program?


        class string_class {
        
        public static void main(String args[]){
        
            String obj = "I LIKE JAVA";
           
         System.out.println(obj.charAt(3));

                }
        }
 

I
L
K
E

SHOW ANSWER

What is the output of this program?
        class string_class {
        
        public static void main(String args[])
{
        
            String obj = "I LIKE JAVA";
            
            System.out.println(obj.length());
        
        }

        }
 

9
10
11
12
SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in