MCQ Java
MCQ Java
10. Which of these coding types is used for data type characters in Java?
a) ASCII
b) ISO-LATIN-1
c) UNICODE
d) None of the mentioned
a) 66
b) 67
c) 65
d) 64
14. What is the error in this code?
byte b = 50;
b = b * 50;
a) b cannot contain value 100, limited by its range.
b) * operator has converted b * 50 into int, which cannot be converted to byte
without casting.
c) b cannot contain value 50.
d) No error in this code
class char_increment {
public static void main(String args[])
{
char c1 = 'D';
char c2 = 84;
c2++;
c1++;
System.out.println(c1 + " " + c2);
}
}
a) E U
b) U E
c) V E
d) U F
class c {
public void main( String[] args )
{
System.out.println( "Hello" + args[0] );
}
}
a) Hello c
b) Hello
c) Hello world
d) Runtime Error
19. Can 8 byte long data type be automatically type cast to 4 byte float data type?
a) True
b) False
21. Which of these operators can skip evaluating right hand operand?
a) !
b) |
c) &
d) &&
class Output {
public static void main(String args[])
{
boolean a = true;
boolean b = false;
boolean c = a ^ b;
System.out.println(!c);
}
}
a) 0
b) 1
c) false
d) true
24. What is the stored in the object obj in following lines of code?
box obj;
a) Memory address of allocated memory of object.
b) NULL
c) Any arbitrary pointer
d) Garbage
a) 12
b) 200
c) 400
d) 100
27. Which of the following is a method having same name as that of its class?
a) finalize
b) delete
c) class
d) constructor
30. Which keyword is used by method to refer to the object that invoked it?
a) import
b) catch
c) abstract
d) this
31. Which operator is used by Java run time implementations to free the memory of an object
when it is no longer needed?
a) delete
b) free
c) new
d) None of the mentioned
32. Which function is used to perform some action when the object is to be destroyed?
a) finalize()
b) delete()
c) main()
d) None of the mentioned
36. Which of these is used to access member of class before object of that class is created?
a) public
b) private
c) static
d) protected
37. What is the process by which we can control what parts of a program can access the
members of a class?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Recursion
46. . Which of these methods of String class is used to obtain character at specified index?
a) char()
b) Charat()
c) charat()
d) charAt()
47. Which of these keywords is used to refer to member of base class from a sub class?
a) upper
b) super
c) this
d) None of the mentioned
48. Which of these methods of String class can be used to test to strings for equality?
a) isequal()
b) isequals()
c) equal()
d) equals()
class string_class {
public static void main(String args[])
{
String obj = "hello";
String obj1 = "world";
String obj2 = "hello";
System.out.println(obj.equals(obj1) + " " + obj.equals(obj2));
}
}
a) false false
b) true true
c) true false
d) false true
51.