0% found this document useful (0 votes)
8 views14 pages

Bits

The document consists of a series of multiple-choice questions related to Java programming, covering topics such as Java features, operators, methods, and inheritance. Each question is assigned a mark, and the document is structured to test knowledge on Java concepts. It includes questions about the Java Development Kit (JDK), constructors, string manipulation, and access modifiers.

Uploaded by

Amrutha Varshini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views14 pages

Bits

The document consists of a series of multiple-choice questions related to Java programming, covering topics such as Java features, operators, methods, and inheritance. Each question is assigned a mark, and the document is structured to test knowledge on Java concepts. It includes questions about the Java Development Kit (JDK), constructors, string manipulation, and access modifiers.

Uploaded by

Amrutha Varshini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 14

Answer all questions and each question carries 1Mark.

1 Which component is used to compile, debug and


execute the java programs? CO1
a) JRE Remember
( )
b) JIT
c) JDK
d) JVM
2 Which one of the following is not a Java feature?
a) Object-oriented CO1
b) Use of pointers Remember ( )
c) Platform independent
d) Robust
3 What is the extension of java code files?
a) .js CO1
b) .txt Remember ( )
c) .class
d) .java
4 Which of these are selection statements in Java?
a) break CO1
b) continue Remember ( )
c) for()
d) if()
5 Modulus operator, %, can be applied to which of these?
a) Integers CO1
b) Floating – point numbers Understand ( )
c) Both Integers and floating – point numbers
d) None of the mentioned
6 Decrement operator (−−) decreases the value of variable by what
number?
a) 1 CO1
b) 2 Remember ( )
c) 3
d) 4
7 What will be the output of the following Java program?
class Boxing
{
public static void main(String args[])
{
CO1
Integer a=new Integer(10);
Apply
int b=a; ( )
System.out.println(a+” “+b);
}
}
a) Unboxing
b) Autoboxing
c) 10
d) compile time error
8 What will be the output of the following Java program? ( )
class Test
{
public static void main(String args[])
{
int number=20;
if(number%2==0)
{ CO1
System.out.println(“even number”); Apply
}
}
}
a)compile time error
b)run time error
c)even number
d)20

9 What will be the output of the following Java program?


class Casting
{
public static void main(String args[])
{
double num=10.99;
CO1
int data=(int) num;
Apply ( )
System.out.println(“the integer value: “+data);
}
}
a)10
b)10.99
c)compile time error
d)run time error
10 What will be the output of the following Java program?
class Casting
{
public static void main(String args[])
{
int num=10;
CO1
double data=num;
Apply ( )
System.out.println(“the double value: “+data);
}
}
a)10.99
b)10.0
c)compile time error
d)run time error
11 Which of the following is a method having same name as that of its
class? CO2
Remember
a) finalize
b) delete ( )
c) class
d) constructor

12 Which method can be defined only once in a program?


a) main method
CO2
b) finalize method ( )
Understand
c) static method
d) private method

13 What is the return type of Constructors? ( )


a) int
b) float CO2
c) void Remember
d) none of the mentioned

14 What is constructor in java?


a) A special method to create instances of classes
b) A method used for mathematical calculations CO2 ( )
c) A method to perform String manipulations
d) An exception handling mechanism Remember

15 What is true about constructor?


a) It can contain return type
b) It can take any number of parameters CO2
c) It can have any non access modifiers ( )
d) Constructor cannot throw an exception Remember

16 Which of this method of class StringBuffer is used to find the length of


current character sequence?
a) length() CO3
b) Length() Remember ( )
c) capacity()
d) Capacity()

17 What will be the output of the following Java program?


class MainProgram
{
public static void main(String args[])
{
StringBuffer s = new StringBuffer("Hello"); CO3
Apply
s.delete(0,2); ( )
System.out.println(s);
}
}
a) He
b) Hel
c) lo
d) llo

How do you convert a string to lowercase in Java?


18
a) str.toLower() CO3
b) str.toLowerCase() Remember

c) str.convertToLower() ( )

d) str.makeLowerCase()

19 What is the purpose of the trim() method of a String object in Java? ( )


a) To remove all spaces from the string
b) To concatenate two strings CO3
Remember
c) To extract a substring from the string
d) Removes whitespace from both ends of a string

20 Which of the following is the correct way to compare two strings in a


case-insensitive manner in Java?
a) str1.equals(str2)
CO3
b) str1.compareToIgnoreCase(str2) Remember ( )
c) str1.equalsIgnoreCase(str2)
d) str1.compare(str2)

Answer all questions and each question carries 1Mark.


1 Which of these are selection statements in Java?
a) break CO1,
b) continue Remember ( )
c) for()
d) if()
2 Modulus operator, %, can be applied to which of these?
CO1,
a) Integers Remember ( )
b) Floating – point numbers
c) Both Integers and floating – point numbers
d) None of the mentioned
3 Decrement operator (−−) decreases the value of variable by what
number? CO1,
a) 1 Remember
( )
b) 2
c) 3
d) 4
4 Which of the following loops will execute the body of loop even when
condition controlling the loop is initially false?

a)do-while CO1,
Remember ( )
b)while
c)for
d) none of the mentioned

5 What is an interpreter?

A) An interpreter converts instructions line by line


CO1,
B) An Interpreter converts source code to low-level code Remember ( )
C) Interpreters are slow to execute

D) All the above

6 Which of the following is used with the switch statement?


a) Continue CO1,
b) Exit Remember ( )
c) break
d) do
7 Which of the following is not a valid jump statement? ( )
a) break CO1,
Remember
b) goto
c) continue
d) return

8 What will be the output of the following Java program?


class Boxing
{
public static void main(String args[])
CO1,
{
Apply
int a=10;
Integer b=a;
System.out.println(a+” “+b);
} ( )
}
a) Unboxing
b) Autoboxing
c) 10
d) compile time error
9 Which of these access specifiers must be used for main () method?
a) private
b) public CO2,
c) protected ( )
Remember
d) none of the mentioned

10 Which of these is used to access a member of class before object of that


class is created?
a) public CO2,
b) private Remember ( )
c) static
d) protected

11 What will be the output of the following Java code? ( )

class Parent

void show()

System.out.println("Parent's show method");

}
CO2,
class Child extends Parent Apply

void show()

System.out.println("Child's show method)");

}
}

class Main

public static void main(String[] args)

Parent obj1 = new Parent();

obj1.show();

a)compile time error


b)Parent's show method
c)Child’s show method
d)run time error
12 Which one of the following is not an access modifier?
a) Public
b) Private CO2,
c) Protected ( )
Remember
d) Void

13 Which keyword is used to prevent method overriding in java?


a) final
b) abstract CO2,
c) static ( )
Remember
d) override

14 Which of these is correct way of inheriting class A by class B?


a) class B + class A {}
b) class B inherits class A {} CO2,
c) class B extends A {} ( )
Remember
d) class B extends class A {}

15 What is not type of inheritance?

a) Single inheritance CO2,


b) Double inheritance Remember ( )
c) Hierarchical inheritance
d) Multiple inheritance

16 Using which of the following, multiple inheritance in Java can be


implemented?
a) Interfaces CO2,
b) Multithreading Remember ( )
c) Protected methods
d) Private methods

17 Which of this method of class StringBuffer is used to find the length of ( )


current character sequence?
a) length() CO2,
b) Length() Remember
c) capacity()
d) Capacity()

What will be the output of the following Java program?


18 CO3,
class MainProgram Apply
{
public static void main(String args[])
{
StringBuffer s = new StringBuffer("Hello");
s.delete(0,2);
System.out.println(s); ( )

}
}
a) He
b) Hel
c) lo
d) llo

19 How do you convert a string to lowercase in Java?


a) str.toLower()
b) str.toLowerCase() CO3,
Remember ( )
c) str.convertToLower()
d) str.makeLowerCase()

20 What is the purpose of the trim() method of a String object in Java?


a) To remove all spaces from the string
b) To concatenate two strings CO3,
Remember ( )
c) To extract a substring from the string
d) Removes whitespace from both ends of a string
Answer all questions and each question carries 1Mark.
1 Which statement is true about Java?
a) Java is a sequence-dependent programming language
b) Java is a code dependent programming language CO1 ( )
c) Java is a platform-dependent programming language Remember
d) Java is a platform-independent programming language
2 Which component is used to compile, debug and execute
the java programs?
a) JRE CO1
Remember ( )
b) JIT
c) JDK
d) JVM
3 Which one of the following is not a Java feature?
a) Object-oriented
b) Use of pointers CO1 ( )
c) Platform independent Remember
d) Robust
4 What will be the output of the following Java program?
class Test
{
public static void main(String args[])
{
int number=20;
if(number%2==0)
{ CO1
System.out.println(“even number”); Apply ( )
}
}
}
a)compile time error
b)run time error
c)even number
d)20

5 What is the return type of a method that does not return any value?
a) int
CO1
b) float ( )
Remember
c) void
d) double

6 Which of these jump statements can skip processing the remainder of the CO1
code in its body for a particular iteration? Remember
a) break
b) return ( )
c) exit
d) continue
7 Which of the following is not a valid jump statement? ( )
a) break CO1
b) goto Remember
c) continue
d) return
8 Which one of the following is not an access modifier?
a) Public CO2
b) Private Remember
c) Protected ( )
d) Void

9 Which keyword is used to prevent method overriding in java?


a) final CO2
b) abstract Remember
c) static ( )
d) override

10 Which of these is correct way of inheriting class A by class B?


a) class B + class A {} CO2
b) class B inherits class A {} Remember
c) class B extends A {} ( )
d) class B extends class A {}

11 What is not type of inheritance?

a) Single inheritance CO2


b) Double inheritance Remember ( )
c) Hierarchical inheritance
d) Multiple inheritance

12 Using which of the following, multiple inheritance in Java can be


implemented?
a) Interfaces CO2
b) Multithreading Remember ( )
c) Protected methods
d) Private methods

13 Which of the following is a super class of every class in Java?


a) ArrayList
b) Abstract class CO2
c) Object class Remember ( )
d) String

14 Which of these keywords is used to define interfaces in Java?

a)intf CO2
b)Intf Remember ( )
c)interface
d)Interface

What will be the output of the following program? ( )


15 public class Test

{
public static void main(String args[])
{
String s1 = "java";
String s2 = "java"; CO3
Apply
System.out.println(s1.equals(s2));
}
}
a)false
b)true
c)compile time error
d)run time error

16 What is the output of the following println statement?

String s1 = "Hello World";

System.out.println(s1.indexOf('W'));
a)1 CO3 ( )
Apply
b)true
c)6
d)false

17 What will be the output of the following program?

class MainProgram

{
public static void main(String args[])
{
CO3
StringBuffer s1 = new StringBuffer("Hello"); Apply
s1.insert(1,"Java");
System.out.println(s1); ( )
}
}

a) hello
b) java
c) Hello Java
d) HJavaello

18 What will be the output of the following program? ( )


class MainProgram
{
public static void main(String args[])
{
String s1=”varri “;
String s2=”naidu” CO3
System.out.println(s1.concat(s2)); Apply

}
}
a)varri
b)naidu
c)varri naidu
d)compile time error

19 Which of this method of class StringBuffer is used to find the length of


current character sequence?

a) length()
CO3
Remember ( )
b) Length()
c) capacity()
d) Capacity()
20 How do you convert a string to lowercase in Java?
a) str.toLower()
b) str.toLowerCase() CO3
( )
Remember
c) str.convertToLower()
d) str.makeLowerCase()
Answer all questions and each question carries 1Mark.
1 Who invented Java Programming?
a) Guido van Rossum CO1,
b) James Gosling Remember ( )
c) Dennis Ritchie
d) Bjarne Stroustrup
2 Which statement is true about Java?
a) Java is a sequence-dependent programming language CO1
b) Java is a code dependent programming language Remember ( )
c) Java is a platform-dependent programming language
d) Java is a platform-independent programming language
3 Which component is used to compile, debug and execute
the java programs?
a) JRE CO1
Remember ( )
b) JIT
c) JDK
d) JVM
4 Which one of the following is not a Java feature?
a) Object-oriented CO1
b) Use of pointers Remember ( )
c) Platform independent
d) Robust
5 What is the extension of java code files?
a) .js CO1
b) .txt Remember ( )
c) .class
d) .java
6 Which of these are selection statements in Java?
a) break CO1
b) continue Remember ( )
c) for()
d) if()
7 Modulus operator, %, can be applied to which of these?
a) Integers CO1
b) Floating – point numbers Understand ( )
c) Both Integers and floating – point numbers
d) None of the mentioned
8 Decrement operator (−−) decreases the value of variable by what
number? CO1
a) 1 Remember
b) 2 ( )
c) 3
d) 4

Which of the following is used with the switch statement?


9 CO1
a) Continue Remember
b) Exit
c) break ( )
d) do
10 What is a Type Casting in Java? ( )

a) Higher data type value is to be converted to lower Data type. CO1


b) Lower data type value is to be converted to higher Data type. Remember
c) Conversion of data from any data type to any data type
d) None of the above
11 Which of these jump statements can skip processing the remainder of the
code in its body for a particular iteration?
a) break CO1
( )
b) return Remember
c) exit
d) continue
12 Which of the following is not a valid jump statement?
a) break CO1
b) goto Remember ( )
c) continue
d) return
13 What will be the output of the following Java program?
class Boxing
{
public static void main(String args[])
{
int a=10;
CO1
Integer b=a; ( )
Apply
System.out.println(a+” “+b);
}
}
a) Unboxing
b) Autoboxing
c) 10
d) compile time error
14 What is the size of int data type in java?
a)1 byte
b)2 bytes CO1 ( )
c)4 bytes Remember
d)8 bytes
15 Which of the following is not OOPS concept in Java?

a) Inheritance CO2
( )
b) Encapsulation Remember
c) Polymorphism
d) Compilation
16 What will be the output of the following Java program? ( )
class Test
{
public static void main(String args[]) CO2
{ Apply
int number=20;
if(number%2==0)
{
System.out.println(“even number”);
}
}
}
a)compile time error
b)run time error
c)even number
d)20
17 What is the return type of a method that does not return any value?
a) int
CO2
b) float ( )
Remember
c) void
d) double

18 What is the process of defining more than one method in a class


differentiated by method signature?
a) Method overriding
CO2 ( )
b) Method overloading Analyze
c) Function doubling
d) None of the mentioned

19 Which of the following is a method having same name as that of its class?
a) finalize
CO2
b) delete ( )
Remember
c) class
d) constructor

20 What is true about constructor?


a) It can contain return type CO3
b) It can take any number of parameters Remember ( )
c) It can have any non access modifiers
d) Constructor cannot throw an exception

You might also like