JAVA Quiz Cognizant QE&A
The java compiler
Creates Executable
Translates java source code to byte code
Creates classes
Produces java interpreter
Command to execute a compiled program in java is
Javac
Java
Run
Execute
Java language has support for which of the following types of comment ?
Block, line and javadoc
Javadoc, literal and string
Javadoc, char and string
Single, multiple and quote
The new operator
Returns a pointer to a variable
Creates a variable called new
Obtains memory for a new variable
Tells how much memory is available
Java programs are
Platform-dependent
Interpreter-dependent
Platform-independent
Interpreter-independent
Integer is a
Adapter class
Inner Class
Not a class
Wrapper Class
Which of the following variable declaration would not compile in Java program?
IntVAR;
Intvar1;
Int 1_var;
All are correct
Among these expressions, which is(are) of type String?
"0"
'0'
[A] and [B]
None of these
Which of the following is NOT an example of a data type?
Int
Public
Boolean
Double
Evaluate the value of the expression? 6 - 2 + 10 % 4 + 7
10
12
13
14
What is/are highest order precedence operator(s) in Java?
()
{}
Both [A] & [B]
None of these
Which of the following is TRUE about the switch statement in Java?
A default send execution immediately to the end of the switch statement.
A break send execution immediately to the end of the switch statement.
A case send execution immediately to the end of the switch statement.
The statements in a switch continue to execute as long as the condition at the top of the switch remains true.
Which of the following is a loop construct that will always be executed once?
Switch
For
While
Do...while
Which one is not a valid jump statement?
Return
Goto
Continue
Break
The break statement causes an exit
Only from the innermost loop.
Only from the innermost switch.
From innermost loops or switches.
Terminates a program.
Which of the following is an invalid declaration for the main method in java program?
Public static void main (String [ ] args)
Public static strictfp void main(String args[ ])
Final static public void main (String args[ ])
All are Correct
A top level class may have which one of the following access modifiers?
Package
Private
Public
Protected
A subclass is also called as
Inner class
Nested class
Derived class
Hidden class
Attribute of an object can include information about
State
Method
Behaviour
Procedure
Which of the following is not a wrapper class?
Vector
Character
Boolean
Integer
Which of the following method is used to initialize the instance variable of a class?
Class
Public
Constructor
Interface
The last statement in a finalize method should always be
Super (finalize)
Super finalize()
Finalize(method name)
No restrictions
Which of the following is not true about constructors?
It initializes an object immediately upon creation
It is syntactically similar to a method
The return type of class constructor is the class type itself
All of the above
A default constructor
Has no arguments
Has no return type
Has one argument but no return type
Has two arguments
In Java, main() method rteturns a value of type
Void
Int
Real
String
A method cannot be overridden if it is qualified by which one of the following modifier?
Final
Static
Public
None of these above
Which exception is thrown by read() method ?
Exception
FileNotFoundException
ReadException
IOException
Exception and Error are immediate subclasses of a class called
Object
Throwable
AWT
Panel
Can we declare a class as protected?
Yes
No
Can a protected field of a class be inherited to subclass outside the package?
Yes
No
How many public classes a .java file can have?
Only one
More than one but less than 3
Maximum two
No limits
Private method can be overridden as public method. True or False?
True
False
Which of the following statement is false?
Variables declared inside of interface declaration may be changed by implementing class
Interfaces are designed to support dynamic method resolution at run time
When an interface method is implemented it must be declared as public
Variables declaration are implicitly final
Is is possible to declare abstract method as static?
Yes
No
Is it possible to declare abstract method as private?
Yes
No
Is it possible to declare abstract method with protected modifier?
Yes
No
Why we need to use Inheritance?
For Code Reusablity
For Method Overriding
For Method Overloading
A & B
B & C
The first statement in a java source file is,
Import statement
Package statement
Main statement
Try{} and catch{}
A package is a collection of
Classes
Interfaces
Editing tools
Classes and interfaces
Which of these class is superclass of String and StringBuffer class?
Java.util
Java.lang
Arraylist
None of these
Which of these operators can be used to concatenate two or more String objects?
+
&
||
+=
Which of the following are incorrect form of StringBuffer class constructor?
StringBuffer()
StringBuffer(int size)
StringBuffer(String str)
StringBuffer(int size , String str)
Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string?
Concat()
Append()
Join()
Concatenate()
Which of these is an incorrect Statement?
It is necessary to use new operator to initialize an array
Array can be initialized using comma separated expressions surrounded by curly braces.
Array can be initialized when they are declared.
None of the mentioned
When does Exceptions in Java arises in code sequence?
Run Time
Compilation Time
Can Occur Any time
None of these
{"name":"JAVA Quiz Cognizant QE&A", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"The java compiler, Command to execute a compiled program in java is, Java language has support for which of the following types of comment ?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}