Java MCQ question and answers sheet - CodeTextPro | Web Tutorial | Technology

CodeTextPro.com Provides - Web design, Technology gyan, Digital marketing, Online earnings, Seo, Adsense, Technology news, Motivation and inspiration, Latest Technology Affairs, Gadgets, Blogging

Wednesday, December 19, 2018

Java MCQ question and answers sheet

Java Important Question with Answer

1)Which class cannot be subclassed (or extended) in java? 
a)abstract class
b)parent class 
c)Final class 
d)None of above

2)Can we access private class outside the package
a)Yes 
b)No 

3)Why we use array as a parameter of main method
a)It is syntax 
b)Can store multiple values 
c)Both of above 
d)None of above

4)Program which executes applet is known as 
a)applet engine 
b)virtual machine 
c)JVM 
d) None of above 

5)Which of the following statements about arrays is syntactically wrong
a)arrayName[] p = new arrayName[5]; 
b)arrayName p[5];
c)arrayName[] p []; 
d)arrayName p[][] = new arrayName[2][];

6)Thread class is available in
a)java.io package 
b)java.lang package
c)java.awt package 
d)java.util package

7)The extension name of a Java source code file is ? 
a).java 
b).class 
c).obj 
d).exe 

8)In Java arrays are 
a)Objects 
b)Object References 
c)Primitive data type 
d)None of the above 

9)Which one of the following is a valid statement? 
a)char[] c = new char(); 
b)char[] c = new char[5]; 
c)char[] c = new char(4); 
d)char[] c = new char[]; 

10)Size of int in Java is 
a)16 bit 
b)20 bit 
c)32 bit 
d)64 bit 






11) What is the output? 
class A{        
public static void main(String args[]){                
int x;                
x = 10;                
if(x == 10){                        
int y = 20;                        
System.out.print("x and y: "+ x + " " + y);                        
y = x*2;                
}                
y = 100;                
System.out.print("x and y: " + x + " " + y);        

}
a)10 20 10 100 
b)10 20 10 20 
c)10 20 10 10 
d)Error 

12) What will be the output? 
public class Test {        
static void test(float x){                
System.out.print("float");        
}
static void test(double x){                
System.out.print("double");        
}
public static void main(String[] args){                
test(99.9);        

}
a)float 
b)double 
c)Compilation Error 
d)None of the above 

13)A java class can have more than one constructor? 
a)Yes 
b)No 

14)If we don’t write any default constructor, then 
a)Java will incorporate a default constructor 
b)Compilation error 
c)Run Time Error 
d)None of the above 

15) In java Constructor can be overloaded 
a)Yes 
b)No 

16)The Inheritance keyword is
a)implement 
b)extend 
c)extends 
d)None of the above 

17)What will be the return type of a method that not returns any value? 
a)int 
b)void 
c)double 
d)None of the above 

18)In which area of memory, the system stores parameters and local variables whenever a method is invoked? 
a)Stack 
b)Heap 
c)Array 
d)None of the above 

19)Which of the modifier can't be used for constructors?
a)public 
b)private 
b)static 
d)protected

20)The variables declared in a class for the use of all methods of the class are called 
a)Reference variable 
b)object 
c)Instance variable 
d)None of the above.

21)The implicit return type of a constructor is 
a)void 
b)A class object in which it is defined. 
c)double 
d)None of the above 

22)The main method should be static for the reason 
a)It can be accessed easily by the class loader 
b)It can be accessed by every method or variable without any hindrance. 
c)It can be executing without creating any instance of the class 
d)None of the above. 

23)What is the default constructor for this class public class Test { }
a)public Test(void) 
b)public void Test() 
c)Test() 
d)public Test() 

24)Which is true? 
a)"X extends Y" is correct if and only if X is a class and Y is an interface. 
b)"X extends Y" is correct if and only if X is a interface and Y is a class. 
c)"X extends Y" is correct if X and Y are either both classes or both interface. 
d)"X extends Y" is correct for all combinations of X and Y being classes and/or interfaces. 

25)Which is not a valid statement based on given code? 
a)A a = new A(); 
b)B a = new B();
c)A a = new B(); 
d)B b = new B(); 

26)A class can extend 
a)A single Class 
b)Multiple Classes 
c)Exactly two classes 
d)None of the above. 

27)An Interface can have 
a) Abstract Functions 
b)Functions 
c)Variables 
d)All the above 

28) we can not instantiate 
a)a class 
b)an Interface 
c)an abstract class and an interface 
d) a class and an abstract class 

29)Which of the following tool used to execute java code. 
a)javac 
b)applet 
c)java 
d)rmic 

30)super keyword in Java is used for? 
a)To refer to immediate child class of a class.
b)To refer to immediate parent class of a class. 
c)To refer to current class object. 
d)To refer to static member of parent class


Click Here To Download Computer Architecture Note

No comments:

Post a Comment