0% found this document useful (0 votes)
154 views

Quiz 1

1) The document contains a quiz with 26 multiple choice questions related to Java programming concepts. 2) The questions cover topics like data types, operators, loops, arrays, OOP concepts, inheritance, method overloading/overriding etc. 3) The candidate needs to choose the correct option for each question.

Uploaded by

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

Quiz 1

1) The document contains a quiz with 26 multiple choice questions related to Java programming concepts. 2) The questions cover topics like data types, operators, loops, arrays, OOP concepts, inheritance, method overloading/overriding etc. 3) The candidate needs to choose the correct option for each question.

Uploaded by

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

QUIZ 1 DATE –

NAME –
ROLL NO –

Question 1) Question 3)
What is the result of expression In java __(1)__ loop can only test for equality,
5.45 + "3.2"? whereas, ___(2)____ can evaluate any Boolean
expression.What is (1) and (2) ?
The long value 8.
A) (1) – if , (2) – switch
A)
The String "5.453.2"
B) (1) – switch , (2) – if
B)
The string "8.6"
C) (1) – if , (2) – break
C)
The double value 8.6
D) (1) – continue , (2) – if
D)

Question 2)
public class Question { Question 4)

public static void main(String args[]) { Find output –


String s1 = "abc"; public class Test {
String s2 = "def"; public static void main( ) {
String s3 = s1.concat(s2.toUpperCase( ) ); short x=10;
System.out.println(s1+s2+s3); x*=5;
} System.out.println(x);
} }
What is the output of this program ? }
None of the above 5
A) A)
abcdefabcdef 10
B) B)
abcabcDEFDEF 50
C) C)
abcdefabcDEF Compilation error
D) D)

Question 5)
Default value of Boolean data type is
A) True
B) False
C) Garbage value
D) None of these
A) for
Question 6) B) do-while
Find output –
C) while
public class IntTest { D) None of these
public static void main(String[] args) {
int a=10; Question 11)
int b=20; Choose incorrect statement
A) class String is used to display messages
a+=(a=4);
string created with StringBuffer class is of variable
b+=(b=5); B)
length
System.out.println(a+”,”+b); C) String is a class and keyword used in java
} D) atring created with StringBuffer cannot be modified
}
Question 12)
14 , 25 String is an object that is created using
A)
A) String class
4,5 B) StringBuffer class
B)
C) Both A and B
8 , 25
C) D) None of these

None of these Question 13)


D)
What is the size of float data type in java?
A) 8 byte
Question 7)
B) 4 byte
What is the size of int data type in java?
A) 1 byte C) 3 byte
B) 2 byte D) 2 byte
C) 3 byte
Question 14)
D) 4 byte If you try to store a value outside the range of
array, which error is generated?
Question 8) A) Compile time
Command line arguments are passed in a
B) Runtime
program
A) After program name C) Both A and B
B) Before program name D) None of these
C) Between program execution
Question 15)
D) After program execution Change in formal arguments affect the actual
arguments in
Question 9) A) Call by value
Process of link of function call to actual
B) Call by reference
code of the function at runtime is called
A) Static binding C) Both A and B
B) Dynamic binding D) None of these
C) Both A and B
D) None of these Question 16)
Instantiation is a process of
Question 10) A) Declaring class
Which of the following is a deterministic loop?
B) Declaring object
C) Declaring method Question 22)
D) Creating object A class which cannot be further inherited and
cannot have subclasses is called
Question 17) A) Super class
A class is B) Final class
A) Primitive data type C) Abstract class
B) Non-primitive data type D) None of these
C) In-built data type
D) None of these Question 23)
Choose the wrong statement
Question 18) A) An abstract class cannot be instantiated
Which is considered as the building block of B) Constructors cannot be declared as abstract
OOP’s? C) Abstract method must end with semicolon
A) objects D) None of these
B) classes
C) methods Question 24)
D) None of these Java Runtime Environment uses –
Question 19) Source
Which of the following is not a jump A)
statement?
Compiler and Interpreter
A) continue B)
B) default
Virtual Machine
C) return C)
D) break All of above
D)
Question 20) Question 25)
What is the correction required in following Which concept is not supported by java?
code? (considering that all necessary header
A) Multiple Inheritance
files are included)
B) Multilevel Inheritance
int[] x=new int[10]; C) Both A and B
for(p=0;x.length();p++) D) None of these
x[p] = 5;
Question 26)
A) x[p] = 5 should be x(p)=5 What is the full form of JDK?
B) p<x.length() should be p<=x.length() A) Java Development Knowledge
C) x.length() should be x.length B) Java Development Kit
D) None of these C) Java Developed Kit
D) None of these
Question 21)
Which is not a syntax error? Question 27)
A) Missing semicolon What command is used for compilation in java?
B) Use of undeclared variable
JavaP
C) Division by zero A)
D) None of these
JavaA
B)
C) JavaC
}
}
JavaD
D) What technique does this code show?
A) Inheritance
Question 28) B) Overriding
Find output of the following code – C) Overloading
class Over { D) None of these

void check(double c) { Question 30)


Consider the following object declaration:
System.out.println(c);
Box ob;
}
ob = new Box(  );
}
Here, what is the highlighted part?
class OverM {
None of these
public static void main(String[] args) { A)
Over ob=new Over(); Just the name of the class Box
B)
char i=W;
A normal method of the class Box
C)
ob.check(i);
The constructor of the Box class
ob.check(123.28); D)
} Question 31)
The ‘new’ operator dynamically allocates the
} memory for an object at
None of these A) Runtime
A) B) Compile time
W@76485649 C) Both A and B
D) None of these
B)
123.28
Question 32)
Will give an error Suppose that there is a program in which Box1
C) is a normal class with some data members and
W functions and Box2 is the class with main()
function. When this program is saved, which
D) of the following files will be created?
123.28

Question 29) A) Box1.class, Box2.class


Consider the following code – B) Box2.java, Box1.class, Box2.class
C) Box2.class, Box1.java, Box2.java
class First{ D) Box1.java, Box2.java
void check(){
System.out.println(“Nothing”); Question 33)
} What is the output of the given code ?
int check(a){
System.out.println(“a=”+a); public class test
return a+a; {
public static void main(String args[])
{
int i = 0; It is another name for a Java source file.
C)
i = i++ + i;
System.out.println(“I = ” +i);
} D) It is the code written within the instance methods of a cla
}

I=0 Question 37)


A)
What is garbage collection in the context of
I=1 Java?
B)
The operating system periodically deletes all the java file
I=2 A)
C)
Any package imported in a program and not used is autom
Compile-time Error B)
D)
Question 34) When all references to an object are gone, the memory us
To prevent any method from overriding, we C) reclaimed.
declare the method as :
The JVM checks the output of any Java program and dele
D)
static
A)
Question 38)
const The correct order of the declarations in a Java
B)
program is,
final
C)
abstract Package declaration, import statement, class declaration
D) A)
Import statement, package declaration, class declaration
B)
Question 35)
What is the type and value of the following Import statement, class declaration, package declaration
expression? (Notice the integer division) C)
-4 + 1/2 + 2*-3 + 5.0 Class declaration, import statement, package declaration
D)
int -5
A)
Question 39)
double -4.5 Use the following declaration and initialization
B)
to evaluate the Java expressions:
int -4
C) int a = 2, b = 3, c = 4, d = 5;
double -5.0 float k = 4.3f;
D)
System.out.println(a++);
Question 36) 4
What is byte code in the context of Java? A)
2
The type of code generated by a Java compiler.
B)
A)
B) The type of code generated by a Java Virtual C) 3
Machine.
Synatax error.
D)

Question 40)
Which of the following variable declaration
would NOT compile in a java program?

int var;
A)
int VAR;
B)
int 1_var;.
C)
int var1;
D)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy