MCQ OF JAVA PROGRAMMING FOR BCA SY
a) -128 to 127 b) -32768 to 32767 c) -2147483648 to 2147483647 d) None of the mentioned
if (x == 9)
1. 1. Java is developed by
a)Dennise
Rittchie b) Bjarne Stroutstrup c)James Gosling d) None of the above
2. 2.
What is the range of
short data type in Java?
a) -128 to 127 b) -32768 to 32767 c) -2147483648 to 2147483647 d) None of the mentioned
3.
3. 3. Which of the
following is not OOPS concept in Java?
a) Inheritance b) Encapsulation c) Polymorphism d) Compilation
a) Inheritance b) Encapsulation c) Polymorphism d) Compilation
4. 4.
Which component is
used to compile, debug and execute java program?
a) JVM b) JDK c) JIT d) JRE
a) JVM b) JDK c) JIT d) JRE
5.
5 Which statement is true
about java?
a) Platform independent programming language
b) Platform dependent programming language
c) Code dependent programming language
d) Sequence dependent programming language
a) Platform independent programming language
b) Platform dependent programming language
c) Code dependent programming language
d) Sequence dependent programming language
6.
6. What is the extension
of java bytecode files?
a) .class b) .java c) .txt d) .js
a) .class b) .java c) .txt d) .js
7.
7 Which of the
following is a valid declaration of an object of class Box?
a) Box obj = new Box(); b) Box obj = new Box;
c) obj = new Box(); d) new Box obj;
a) Box obj = new Box(); b) Box obj = new Box;
c) obj = new Box(); d) new Box obj;
8.
8 What
is the output of this program?
class
main_class
{
public static void main(String args[])
{
int x = 9;
{
int x = 8;
System.out.println(x);
}
}
}
a ) 9 b) 8 c) Compilation error d)
Runtime error
9. What
is the output of this program?
class box
{
int width;
int height;
int length;
}
class mainclass
{
public static void main(String args[])
{
box obj = new box();
obj.width = 10;
obj.height = 2;
obj.length = 10;
int y = obj.width * obj.height * obj.length;
System.out.print(y);
}
}
a)12 b) 200 c) 400
d) 100
10.
What is expected output?
public
class Profile
{
private
Profile(int w)
{
System.out.print(w);
}
public
static Profile()
{
System.out.print(10);
}
public
static void main(String args[])
{
Profile
obj=new Profile(50);
}
}
a)Won't compile
because of line (1), constructor can't be private
b)
10 50
c) 50 d) Won't compile
because of line (5), constructor can't be static
111. java arrays are
12. Which
one of the following is valid statement
a)char[]
c = new char(); b) char[]
c = new char[5];
c)char[]
c = new char(4); d) char[]
c = new char[];
13 .Given the following piece of code
public class School
{
public abstract double NumberOfStudent();
}
}
which of the following statement is true.
a)
The keywords public and abstract cannot be used
together.
b)
The method numberOfStudent() in class School must have
a body.
c)
You must add a return statement in method
numberOfStudent().
d)
Class School must be defined abstract
14. The
class at the top of exception class hierarchy is --------
a)ArithmeticException b)Throwable
c)Object d)Exception
15.
In which of the following package the class
Exception exists
a)java.util b)java.file c) java.io d)java.lang
16.
Exception generated in try block is caught in ------ block.
a)catch b)throw c) throws d)finally
17. What will be the output of the
following program
public class Test
{
public static void main(String args[])
{
String s1=”java”;
String s2=”java”;
System.out.println(s1.equals(s2));
System.out.println(s1==s2);
}
}
a)false true b)false false c) true
false d) true true
18 What is the output of the
following program
class
Test
{
public
void display(int x,double y)
{System.out.println(x+y);
}
public
double display(int p,double q)
{
return(p+q);
}
public
static void main(String args[])
{Test
test=new Test();
test.display(4,5.0);
System.out.println(“add=”test.display(4,5.0));
}
}
}
a)9.0 9.0 b)9 9 c) Compilation Error d)None of these
19.
What is the result of the following code
public
class Person
{
void
talk()
{
System.out.println(“I
am a Person”);
}}
public
class Student extends Person
{void
talk()
{System.out.println(“I
am Student”);
} }
public
class Test
{
public
static void main(String args[])
{
Person
p=new Student();
p.talk();
}}
a)I
am a Person b)I am a Student
c)I
am a Person I am a Student d)I
am a Student I am a Person
20.What will be the
output
interface
A
{
public void method1()
{
System.out.println(“Class
one method1”);
}
}
class
One implements A
{public
void method1()
{
System.out.println(“Class One method1”);
}
}
class
Two extends One
{public
void method1()
{
System.out.println(“Class Two method1”);
}
}
public
class Test extends Two
{
public
static void main (String args[])
{
A
a=new Two();
a.method1();
}
}
a)
Class One method1 b)Class Two method1
b)
Nothing will be printed d)Compilation Error
21. What
is the use of final keyword in Java?
a)When a class is made final, a
sublcass of it can not be created.
|
|
b)When a method is final, it can
not be overridden.
|
|
c)When a variable is final, it can
be assigned value only once.
|
|
d)All of the above
|
22 . Output of follwoing Java program
class Main {
public static void main(String
args[]){
final int i;
i = 20;
System.out.println(i);
}
}
(A) 20 (B) Compiler Error (C) 0 (D) Garbage value
23. Which of the following is/are
advantages of packages?
A
|
Packages avoid name
clashes
|
B
|
Classes, even though
they are visible outside their package, can have fields visible to packages
only
|
C
|
We can have hidden
classes that are used by the packages, but not visible outside.
|
D
|
All of the above
|
24. To prevent any method
from overriding, we declare the method as,
(a)
static (b) const (c) final (d) abstract (e) none of the above.
25. The fields in an interface are implicitly
specified as,
(a)
static only (b) protected (c) private (d) both static and final (e) none of the above.
26.
What is the output of the following
program:
public
class testmeth
{
static int i = 1;
public static void main(String args[])
{
System.out.println(i+” , “);
m(i);
System.out.println(i);
}
public void m(int i)
{
i += 2;
}
}
{
static int i = 1;
public static void main(String args[])
{
System.out.println(i+” , “);
m(i);
System.out.println(i);
}
public void m(int i)
{
i += 2;
}
}
(a)
1 , 3 (b) 3 , 1 (c) 1 , 1 (d) 1 , 0 (e) none of the above.
27.
Which of the following is not true?
a)
An
interface can extend another interface.
(b) A class which is implementing an interface must implement all the methods of the interface.
(c) An interface can implement another interface.
(d) An interface is a solution for multiple inheritance in java.
(e) None of the above.
(b) A class which is implementing an interface must implement all the methods of the interface.
(c) An interface can implement another interface.
(d) An interface is a solution for multiple inheritance in java.
(e) None of the above.
28.
Which of the following is true?
a)
A
finally block is executed before the catch block but after the try block.
(b) A finally block is executed, only after the catch block is executed.
(c) A finally block is executed whether an exception is thrown or not.
(d) A finally block is executed, only if an exception occurs.
(e) None of the above.
(b) A finally block is executed, only after the catch block is executed.
(c) A finally block is executed whether an exception is thrown or not.
(d) A finally block is executed, only if an exception occurs.
(e) None of the above.
29. The java run time system automatically calls
this method while garbage collection.
(a)
finalizer() (b) finalize() (c) finally() (d) finalized() (e) none of the above.
30. An overloaded method
consists of,
a)The
same method name with different types of parameters
(b) The same method name with different number of parameters
(c) The same method name and same number and type of parameters with different return type
(d) Both (a) and (b) above
(e) (a), (b) and (c) above.
(b) The same method name with different number of parameters
(c) The same method name and same number and type of parameters with different return type
(d) Both (a) and (b) above
(e) (a), (b) and (c) above.
31. When an overridden
method is called from within a subclass, it will always refer to the version of
that method defined by the
(a)
Super class (b)
Subclass
(c) Compiler will choose randomly (d) Interpreter will choose randomly
(c) Compiler will choose randomly (d) Interpreter will choose randomly
32. Which of the following contains both date
and time?
a) java.io.date b) java.sql.date c) java.util.date d) java.util.dateTime
a) java.io.date b) java.sql.date c) java.util.date d) java.util.dateTime
33. What JDBC stands for?
34.
Which of the following is used to create statement and execute sql queries on
the database?
35.
Which of the following function is used to register the driver class?
a) getconnection() b)
CreateStatement()
c) Class.forName() d) one of the
above
36)
To retrieve record from database by using SELECT query which of the following
Statement method is used
a) execute() b) executeQuery()
37. which of the following stream class is used
to input and output byte data.
a)Byte sream class
b) character stream class
c)
both a and b d)none of these
38. ---------------- is a mechanisam to convert the
object into byte stream .
a)
Deserialization b)
Centralizaton c)Serialization d)Conversion
39. --------method is used for deserialization.
a)
writeObject() b)readObject c) both a and b d)none of these
40. --------method is used for serialization.
a)
writeObject() b)readObject c) both a and b d)none of these
Answers :
1-c 2-b 3-d 4-b 5-a 6-a 7-a
8-c 9-b
10 –d 11-a 12-b 13-d 14-d 15-d
16-a 17-d 18-c 19-b 20-b 21-d 22-a 23-d 24-c 25-d 26-a 27-a 28-c
29-b 30-d 31-b 32-c 33-a 34-a 35-c 36-b 37-a 38-c 39-b 40-a
KING CASINO, LLC GIVES A $100 FREE BET
ReplyDeleteKING CASINO, LLC GIVES A $100 FREE communitykhabar BET to try. Visit us today herzamanindir.com/ and receive a $100 microtouch solo titanium FREE BET! poormansguidetocasinogambling Sign kadangpintar up at our new site!