Programming in Java

Faheem Ahmed
Quiz by Faheem Ahmed, updated more than 1 year ago
Faheem Ahmed
Created by Faheem Ahmed over 3 years ago
1536
0

Description

SecondYear Second Year Quiz on Programming in Java, created by Faheem Ahmed on 03/26/2018.

Resource summary

Question 1

Question
What modifier is to be used if you wish to declare that you want to no longer allow subclasses to override your variables or methods?
Answer
  • Finally
  • Abstract
  • Final
  • Synchronized
  • Volatile

Question 2

Question
AWT stands for
Answer
  • Advanced windowing tool kit
  • Abstract Windowing Term Kit
  • Abstract Windowing Tool Kit
  • Applet Window Tool Kit
  • Asynchronous windowing tool kit

Question 3

Question
Which operator is used for concatenation in java?
Answer
  • -
  • . (Dot)
  • *
  • %
  • +

Question 4

Question
What is the type and value of the following expression? -4 + 1/2 + 2*-3 + 5.0
Answer
  • int -5
  • double -4.5
  • int -4
  • double -5.0

Question 5

Question
In object-oriented programming, the process by which one object acquires the properties of another object is called
Answer
  • Encapsulation
  • Polymorphism
  • Overloading
  • Inheritance
  • Overriding

Question 6

Question
Java compiler javac translates Java source code into ………………………
Answer
  • Assembler language
  • Byte code
  • Bit code
  • Machine code
  • Platform dependent code

Question 7

Question
Which of the following statements about Java Threads is correct?
Answer
  • Java threads don’t allow parts of a program to be executed in parallel
  • Java is a single-threaded language
  • Java’s garbage collector runs as a high priority thread
  • Ready, running and sleeping are three states that a thread can be in during its life cycle
  • Every java application is not multithreaded

Question 8

Question
The wrapping up of data and functions into a single unit is called
Answer
  • Encapsulation
  • Abstraction
  • Data Hiding
  • Polymorphism
  • Message passing

Question 9

Question
In Java, declaring a class abstract is useful
Answer
  • To prevent developers from further extending the class
  • When it doesn't make sense to have objects of that class
  • When default implementations of some methods are not desirable
  • To force developers to extend the class not to use its capabilities
  • When it makes sense to have objects of that class

Question 10

Question
Which of the following is a member of the java.lang package?
Answer
  • List
  • Queue
  • Math
  • Stack
  • Process

Question 11

Question
URL stands for
Answer
  • Universal reader locator
  • Universal reform loader
  • Uniform resource loader
  • Uniform resource locator
  • Uniform reader locator

Question 12

Question
What is the sequence of major events in the life of an applet?
Answer
  • init, start, stop, destroy
  • start, init , stop , destroy
  • init, start , destroy, stop
  • init, start, destroy
  • destroy, start, init, stop

Question 13

Question
What will be the result of the expression 13 & 25?
Answer
  • 38
  • 25
  • 9
  • 12
  • 21

Question 14

Question
What information may be obtained from a ResultSetMetaData object?
Answer
  • Database URL and product name
  • JDBC driver name and version
  • Number of columns in the result set
  • Number of rows in the result set
  • Number of tables in the database

Question 15

Question
Which is a special file that contains information about the files packaged in a JAR file?
Answer
  • Class file
  • Source file
  • Text file
  • Manifest file
  • Image file

Question 16

Question
Evaluate the Java expressions: int i=3, j=7, k=11; j + k % i
Answer
  • 9
  • 0
  • 7
  • 12
  • 10

Question 17

Question
Which of the following provides the naming services for the server to register the object and for the client to locate the object?
Answer
  • Server object interface
  • Server implementation
  • RMI Registry
  • Server stub
  • Server Skeleton

Question 18

Question
Which is not a valid operator in Java?
Answer
  • <>
  • =>
  • <=
  • +=
  • !=

Question 19

Question
Which of the following is not an Applet method?
Answer
  • start()
  • init()
  • run()
  • stop()
  • destroy()

Question 20

Question
If ClassA extends ClassB, then
Answer
  • ClassA is a superclass
  • ClassB is a base class
  • ClassB is a subclass
  • ClassB is a derived class
  • ClassA is a base class

Question 21

Question
SSL stands for
Answer
  • Secure Server Layer 
  • Secure Socket Layer 
  • Server Socket Layer 
  • Session Service Layer 

Question 22

Question
Consider the following HTML page code: < html > < body > < a href='/servlet/HelloServlet' >POST< /a > < /body >< /html > Which method of HelloServIet will be invoked when the hyperlink is clicked?
Answer
  • doGet 
  • doPost 
  • doHref 
  • servicePost 

Question 23

Question
Stub is a ____________ proxy for the remote object.
Answer
  • Server side 
  • Client side 
  • Both side 
  • none of the above 

Question 24

Question
What is the Output: String s1 = new String("Test"); String s2 = new String("Test"); if (s1==s2) System.out.println("Same"); if (s1.equals(s2)) System.out.println("Equals");
Answer
  • Same Equals
  • Equals
  • Same
  • The code compiles, but nothing is displayed upon execution.
  • The code fails to compile

Question 25

Question
Which declaration of the main method below would allow a class to be started as a standalone program.
Answer
  • public static int main(char args[])
  • public static void main(String args[])
  • public static void main(string args[])
  • public static void main(String args)

Question 26

Question
Which of these are legal identifiers.
Answer
  • number_1
  • number_a
  • $1234
  • All of the above

Question 27

Question
Which of the following are keywords in Java.
Answer
  • implement
  • friend
  • NULL
  • synchronized

Question 28

Question
Given a one dimensional array arr, what is the correct way of getting the number of elements in arr.
Answer
  • arr.length
  • arr.length - 1
  • arr.size
  • arr.length()

Question 29

Question
A class can have many methods with the same name as long as the number of parameters or type of parameters is different. This OOP concept is known as
Answer
  • Method Invocating
  • Method Overriding
  • Method Labeling
  • Method Overloading

Question 30

Question
Is this True or False. In Java an abstract class cannot be sub-classed.
Answer
  • True
  • False

Question 31

Question
What is returned when the method substring(2, 4) is invoked on the string "example"? Include the answer in quotes as the result is of type String.
Answer
  • "xa"
  • "am"
  • "xm"
  • "xamp"

Question 32

Question
What is the result of evaluating the expression 14 ^ 23. Select the one correct answer.
Answer
  • 23
  • 24
  • 25
  • 26

Question 33

Question
Which of the following is not a return type?
Answer
  • boolean
  • void
  • public
  • Button

Question 34

Question
Which operator is used to perform bitwise exclusive or.
Answer
  • &
  • ^
  • |
  • !

Question 35

Question
If result = 2 + 3 * 5, what is the value and type of result variable?
Answer
  • 17, byte
  • 25, byte
  • 17, int
  • 25, int

Question 36

Question
All the wrapper classes (Integer, Boolean, Float, Short, Long, Double and Character) in java
Answer
  • are final
  • are private
  • are serializable
  • are immutatable

Question 37

Question
What is the result of compiling and running this program? Select the one correct answer. public class test { public static void main(String args[]) { int i, j; int k = 0; j = 2; k = j = i = 1; System.out.println(k); } }
Answer
  • The program does not compile as k is being read without being initialized.
  • The program does not compile because of the statement k = j = i = 1;
  • The program compiles and runs printing 1.
  • The program compiles and runs printing 2.

Question 38

Question
A program needs to store the name, salary, and age of employees in years. Which of the following data types should be used to create the Employee class. Select the three correct answers. a. char b. boolean c. Boolean d. String e. int f. double
Answer
  • a,d,f
  • a,e,f
  • d,e,f
  • d,a,e

Question 39

Question
When we go for thread synchronization?
Answer
  • to remove the lock on the thread
  • when there is a single thread
  • to make a thread in sleep mode
  • when we want to prevent any other multiple thread to act an same object

Question 40

Question
Which statement is true? public void test(int x) { int odd = 1; if(odd) { System.out.println("odd"); } else { System.out.println("even"); } }
Answer
  • "odd" will always be output.
  • "even" will always be output.
  • Compilation fails.
  • "odd" will be output for odd values of x, and "even" for even values.

Question 41

Question
Which code determines the int value data closer to, but not greater than, a double value b?
Answer
  • int data = (int) Math.floor(b);
  • int data = (int) Math.abs(b);
  • int data = (int) Math.ceil(b);
  • int data = (int) Math.min(b);

Question 42

Question
Which of the following statements is false as far as different type of statements is concern in JDBC?
Answer
  • Regular Statement
  • Interim Statement
  • Callable Statement
  • Prepared Statement

Question 43

Question
Which of the following describes the correct sequence of the steps involved in making a connection with a database. 1. Loading the driver 2. Process the results. 3. Making the connection with the database. 4. Executing the SQL statements.
Answer
  • 1,2,3,4
  • 1,3,4,2
  • 2,1,3,4
  • 4,1,2,3

Question 44

Question
Which one not a JDBC interface?
Answer
  • Connection
  • Statement
  • DriverManager
  • ResultSet

Question 45

Question
Which one is a correct MySql Driver class name?
Answer
  • com.mysql.jdbc.driver.Driver
  • com.jdbc.mysql.Driver
  • com.mysql.jdbc.Driver
  • none of these

Question 46

Question
Which one correct JDBC statements?
Answer
  • Statement
  • PreparedStatement
  • CallableStatement
  • all of above

Question 47

Question
Where the stored procedures reside?
Answer
  • In side server memory
  • In side cache
  • In side database
  • In side browser

Question 48

Question
By default cursor pointing to-
Answer
  • Column Header
  • First Record
  • Last Record
  • Middle Record

Question 49

Question
By default "auto commit" option is -
Answer
  • true
  • false

Question 50

Question
We can get the column names using?
Answer
  • ResultSetColumnData
  • ResultSetMetaData
  • ResultSetHeaderData
  • ResultSetTableData

Question 51

Question
SELECT, INSERT, DELETE, UPDATE, COMMIT and ROLLBACK comes under ?
Answer
  • DML
  • DDL
  • DCL
Show full summary Hide full summary

Similar

HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
Useful String Methods
Shannon Anderson-Rush
Java Week 5 Object Oriented Programming
Troy Bowlin
Historical Development of Computer Languages
Shannon Anderson-Rush
Flvs foundations of programming dba 2
mariaha vassar
Programming Review
Shannon Anderson-Rush
computer systems and programming quiz
Molly Batch
Python Quiz
karljmurphy
Think Python
tsilvo2001
C Programming
Miki Rana