java ques for practice useful
DESCRIPTION
Java QuestionsTRANSCRIPT
![Page 1: Java Ques for Practice Useful](https://reader035.vdocuments.mx/reader035/viewer/2022080103/577c778b1a28abe0548c8696/html5/thumbnails/1.jpg)
What is true about thread
Thread is a ligthweight Process
Threads shares heap memory of the Process
A Thread maintains its own stack
What is the difference between yield and sleep
sleep changes the state of the thread from Running to Waiting whereas yield changes the state of the thread for Running to Runnable
thread.sleep(1000) will sleep for 1 sec whereas with yield there is no such guarantee
both are static methods defined in the Thread class
Which two of the following methods are defined in class Thread start() run()Select state of the Thread New Runnable Running Dead
Select what is true about ExecutorService
It is used to create, invoke and schedule Asynchronous threads
It is used to create and manage Thread pool
It is used to submit a thread that can be completed in future
Select the type of thread pools that can be created using Executors class
Executors.newSingleThreadExecutor
Executors.newCachedThreadPool
Executors.newFixedThreadPool
Select the methods provided by the ExecutorService
execute(Runnable)
submit(Runnable) invokeAny()
What is true about shutdown() method
when shutdown method of the executorservice is called it will no
executorSerive.shutdown() waits till all the submitted
executorSerive.shutdown() is used for graceful
![Page 2: Java Ques for Practice Useful](https://reader035.vdocuments.mx/reader035/viewer/2022080103/577c778b1a28abe0548c8696/html5/thumbnails/2.jpg)
ExecutorService
more take any new task
tasks are completed
shutdown of the service
Select the components of JDBC DriverManager Statement Connection
Difference between Statement and PreparedStatement
Statement has to be compiled everytime whereas PreparedStatement are precompiled cached
Statement is suitable for DDL Operations, PreparedStatement is suitable for DML Operations
What is true about ResultSet interface
ResultSet returns one or more rows from the database table
When ResultSet is returned, it is positioned before first row
Select the ResultSet types in JDBC
TYPE_FORWARD_ONLY
TYPE_SCROLL_SENSITIVE
TYPE_SCROLL_INSENSITIVE
Select the JDBC driver types
Type 1: JDBC-ODBC driver
Type 2: Native-API driver
Type3: JDBC net driver
Type4: JDBC pure java driver
How the connection object is obtained in JDBC
getConnection(String url)
getConnection(String url, Properties prop)
getConnection(String url, String username, String password)
JDBC-ODBC Bridge support multiple concurrent open statements per connection? True or False FALSE
![Page 3: Java Ques for Practice Useful](https://reader035.vdocuments.mx/reader035/viewer/2022080103/577c778b1a28abe0548c8696/html5/thumbnails/3.jpg)
Select Junit Test classes Assert TestCase TestResult TestSuitWhat methods can be tested using Junit Default Public
Select the Junit assert statements
assertEquals(String message, String expected, String actual)
assertTrue(String message, boolean condition)
assertFalse(String message, boolean condition)
Select what is true about Junit Test case
Junit test case extends junit.framework.TestCase
All the Test methods are annotated with @Test
All the Test cases methods run independent of each other
All the Test cases methods should be declared void
Select the correct statement
If Junit Test method is declared to return a String it will compile without any issue
You can also pass parameter to a Junit Test method
Select the utility Java provides to implement L18N and L10N java.util.locale
java.util.resourcebundle
What Localization relates to
Numeric, date and time formats Use of Currency
Keyboard usage
Symbols, icons and colors
Select the type of java.util.ResourceBundle provided by java
PropertyResourceBundle
ListResourceBundle
Select the methods of java.util.Locale
getAvailableLocales()
getDisplayLanguage() getLanguage()
Select the Locale constants Locale.CANADA
Locale.CANADA_FRENCH Locale.ITALY
![Page 4: Java Ques for Practice Useful](https://reader035.vdocuments.mx/reader035/viewer/2022080103/577c778b1a28abe0548c8696/html5/thumbnails/4.jpg)
Which of the following allows non repeatable read in JDBC Connection
TRANSACTION_REPEATABLE_READ
Which type of driver provides JDBC access via one or more ODBC drivers? Type 1When the message “No Suitable Driver” occurs?
When the JDBC database URL passed is not constructed properly
What is, in terms of JDBC, a DataSource?
A DataSource is a factory of connections to a physical data source
Which method is static and synchronized in JDBC API? getConnection()Which two of the following methods are defined in class Thread? start() run()Which three guarantee that a thread will
wait() sleep(1000) aLiveThread.join()
![Page 5: Java Ques for Practice Useful](https://reader035.vdocuments.mx/reader035/viewer/2022080103/577c778b1a28abe0548c8696/html5/thumbnails/5.jpg)
leave the running state?Which of these method is used to find out that a thread is still running or not? Alive()What is the default value of priority variable MIN_PRIORITY AND MAX_PRIORITY 1 & 10Which of these method is used to explicitly set the priority of a thread setPriority()How To Compile a JUnit Test Class? javacWhat Happens If a JUnit Test Method Is Declared as "private"? Runtime errorWhat should be the return type of a testMethod
void
![Page 6: Java Ques for Practice Useful](https://reader035.vdocuments.mx/reader035/viewer/2022080103/577c778b1a28abe0548c8696/html5/thumbnails/6.jpg)
in JunitWhat Happens If a Test Method Throws an Exception Runtime test fails
Compilation Succeeds
Queue can be used to implement
quick sort radix sort
A binary search tree whose left subtree and right subtree differ in hight by at most 1 unit is called ……
AVL tree
……………….. in which the model becomes compatible executable code
Implementation level
Stack is also called as
Last in first out
Which of the following is true about the characteristics of abstract data types?(i) It exports a type. ii) It exports a set of operations True, True
…………… is not the component of data structure.
None of the above
Which of the following is not the part of ADT description?
None of the above
Inserting an item into the stack when stack is not full is called …………. Operation and deletion of item form the stack, when stack is not empty is called ………..operation.
push, pop
……………. Is a pile in which items are added at one end and removed from the other. Queue………… is very useful in situation when data have to stored and then retrieved in reverse order. Stack
![Page 7: Java Ques for Practice Useful](https://reader035.vdocuments.mx/reader035/viewer/2022080103/577c778b1a28abe0548c8696/html5/thumbnails/7.jpg)
A directed graph is ………………. if there is a path from each vertex to every other vertex in the digraph.
Strongly Connected
In the …………….. traversal we process all of a vertex’s descendents before we move to an adjacent vertex.
Depth First
Identify the acceptable properties of Graph i) Network is a graph that has weights or costs associated with it. ii) An undirected graph which contains no cycles is called a forest. iii) A graph is said to be complete if there is no edge between every pair of vertices.
True, True, False
The number of comparisons done by sequential search is ……………… (N+1)/2In ……………, search start at the beginning of the list and check every element in the list.
Linear search
State True or False. i) Binary search is used for searching in a sorted array. ii) The time complexity of binary search is O(logn).
True, True
Which of the following is not the internal sort? Merge SortState True or False. i) An undirected graph which contains no cycles is called forest. ii) A graph is said to be complete if there is an edge between every pair of vertices.
True, True
A graph is said to be ……………… if the vertices can be split into two sets V1 and V2 such there are no edges between two vertices of V1 or two vertices of V2. BipartiteIn a queue, the initial values of front pointer f rare pointer r
0 and -1
![Page 8: Java Ques for Practice Useful](https://reader035.vdocuments.mx/reader035/viewer/2022080103/577c778b1a28abe0548c8696/html5/thumbnails/8.jpg)
should be …….. and ……….. respectively.In a circular queue the value of r will be ..
r=(r+1)% QUEUE_SIZE