Question 1 of 20
5.0/ 5.0 Points
Which is(are) the message level will be logged with the logger level "info"? A. info, error, fatal, warn B. info, debug, warn C. info, debug, warn, fatal D. info, trace, debug, warn Question 2 of 20
5.0/ 5.0 Points
The rolling output file type is an output file of which the content is A. replaced at each running of the logged target B. put in a history file when the file size attends a predefined size C. replaced after a predefined period of time Question 3 of 20
5.0/ 5.0 Points
The logger declaration order is A. from most generic case to specific case B. from most specific case to generic case C. No order at all Question 4 of 20
5.0/ 5.0 Points
Which of the following platforms does Log4j run on? A. Cross-platform Cross-platform B. Windows Server 2008 C. Debian Question 5 of 20
Which config section define the format of log message?
5.0/ 5.0 Points
A. layout section B. display section C. format section D. output section Question 6 of 20
5.0/ 5.0 Points
What is a log4j logger? A. A log output file B. A configuration configuration section C. Java class that logs a log message Question 7 of 20
5.0/ 5.0 Points
Which of the following genres does Log4j produce? A. Action game B. Avant-rock C. Gospel music D. Logging Tool Question 8 of 20
5.0/ 5.0 Points
Which action is not a logging implement action? A. Define logger B. Define log schedule C. Define appender D. Define log message Question 9 of 20
What is a log4j logger used for? A. To logs a log message
5.0/ 5.0 Points
B. To define which log message will be caught C. To receive the log message
Question 10 of 20
5.0/ 5.0 Points
A logger cannot be defined for A. A package B. A project C. A method D. A class
Question 11 of 20
5.0/ 5.0 Points
What part of log4J config file defines the log message output A. log message file B. output C. output file D. appender Question 12 of 20
5.0/ 5.0 Points
What part of log4J config file defines the level of log message A. logger B. log message level C. log level D. message level Question 13 of 20
The most generic logger is
5.0/ 5.0 Points
A. base B. ceil C. root D. floor Question 14 of 20
5.0/ 5.0 Points
Which is syntax used to log a message? A. logger.message(loglevel, "log message"); B. logger.message("log message"); C. message.log(); D. logger.info("log message"); Part 2 of 2 - Part 2
Question 15 of 20
30.0/ 30.0 Points 5.0/ 5.0 Points
How to bypass a method in the debugging with Eclipse debug function A. Use step over function B. Use step return function C. Use step into function
Question 16 of 20
How to pause the debugging at a statement in Eclipse debug function A. Use break point function B. Use pause line function
5.0/ 5.0 Points
C. Use pause statement function
Question 17 of 20
5.0/ 5.0 Points
How to ignore the rest of debugging of a method with Eclipse debug function A. Use continue debugging function B. Use step over function C. Use step return function
Question 18 of 20
5.0/ 5.0 Points
How to run the debugging statement by statement with Eclipse debug function A. Use step return function B. Use step into function C. Use step over function
Question 19 of 20
5.0/ 5.0 Points
How to ignore the debugging until the next check point with Eclipse debug function A. Use continue debugging function B. Use step return function C. Use step over function
Question 20 of 20
How to ignore the rest of debugging with Eclipse debug function
5.0/ 5.0 Points
A. Use continue debugging function B. Use step return function C. Use stop debugging function function Question 1 of 20
5.0/ 5.0 Points
Choose incorrect sentence
A. All communication with a database has to occur inside a transaction B. Transaction is a set of database operations which must be executed in entirely or not at all C. Transaction should and either with a commit or a rollback D. Transaction cannot rollback
Question 2 of 20
5.0/ 5.0 Points
Hibernate provides following types of configurations
A. Criteria B. hibernate.properties & programatic configuration C. Hibernate Query Language D. Transaction
Question 3 of 20
hibernate.cfg.xml is used for
A. Building the mapping between class and table
5.0/ 5.0 Points
B. Is a generated file at runtime C. No such file is required for hibernate D. Contains the configuration like database details
Question 4 of 20
5.0/ 5.0 Points
When several entities points to the target entity, that is achieved by?
A. @OneToOne B. @ManyToOne C. @ManyToMany
Question 5 of 20
5.0/ 5.0 Points
The
tag is used for :
A. Generating primary key values B. Generating table automatically C. Mapping property to column in table D. Generating column automatically
Question 6 of 20
Mapping Java classes to database tables is accomplished through the configuration file
A. Properties B. Xhtml
5.0/ 5.0 Points
C. Html D. Xml
Question 7 of 20
5.0/ 5.0 Points
ORM stands for
A. Object Relational Mapping B. Over related Mapping C. Over related Matching D. Object Relational Matching
Question 8 of 20
5.0/ 5.0 Points
What is the root level element in a hibernate mapping file?
A. B. C. D. None of the above
Question 9 of 20
Which property are used to configure diver class in hibernate?
A.getParameters("name"); B.getParameterValues("name");
5.0/ 5.0 Points
C.hibernate.connection.datasource D.hibernate.connection.driver_class
Question 10 of 20
5.0/ 5.0 Points
Which of the following is not a Session method? Select ONE
A. Session.saveorupdate() B. Session.save() C. Session.load() D. Session.remove() E. Session.persist()
Question 11 of 20
5.0/ 5.0 Points
What does hibernate.hbm2ddl.auto create this means?
A. None B. Create session object automatically C. Create tables automatically D. Create SessionFactory object automatically
Question 12 of 20
Which of following is NOT a property in hibernate.cfg.xml file?
A. connection.url
5.0/ 5.0 Points
B. None of above C. connection.username D. oracle_dialect
Question 13 of 20
5.0/ 5.0 Points
"Is this configuration correct in hibernate? "
A. None of the above B. No C. Yes
Question 14 of 20
5.0/ 5.0 Points
What happens when both hibernate.properties and hibernate.cfg.xml are in the classpath?
A. The settings of the properties file will override the settings used in the XML configuration B. DuplicateConfigurationException C. The settings of the XML configuration file will override the settings used in the properties D. None
Question 15 of 20
Using Criteria Query to
A. Delete object
5.0/ 5.0 Points
B. Update object C. Insert Object D. Query that are built up using lots of conditional logic, avoid messy string manipulation
Question 16 of 20
5.0/ 5.0 Points
If the property of a class should not take part in persistence mechanism than the property should be marked as
A. @Temporary B. @Lob C. @Enum D. @Transient
Question 17 of 20
5.0/ 5.0 Points
Which of the following is a tag NOT used in hibernate.cfg.xml ?
A. B. C. D.
Question 18 of 20
Which interface are not the core interfaces of Hibernate framework?
A. Query and Criteria interfaces
5.0/ 5.0 Points
B. Session interface C. SessionFactory interface D. User Interface E. Configuration interface
Question 19 of 20
5.0/ 5.0 Points
Hibernate configuration is managed by
A. org.hibernate.cfg.Configuration B. org.hibernate.Session C. org.hibernate.Transaction D. org.hibernate.SessionFactory
Question 20 of 20
5.0/ 5.0 Points
How can get a session object ?
A. SessionFactory.getObject(); B. SessionFactory.getSession(); C. SessionFactory.get(); D. SessionFactory.openSession();
Question 1 of 20 Conn = Driver Manager.getConnection(“jdbc:odbc:Employee”,“”,“”);
What does the above statement do?
5.0/ 5.0 Points
A. Gets a database connection with the Employee data source. B. Gets connectioned to the employee database. C. Retrieves data from the employee table. D. Inidicates that jdbc is to be used in the application.
Question 2 of 20
5.0/ 5.0 Points
The JDBC-ODBC Bridge supports multiple concurrent open statements per connection
A. No B. Yes Question 3 of 20
5.0/ 5.0 Points
Which packages contain the JDBC classes
A. java.rdb and javax.rdb B. java.jdbc and javax.jdbc C. java.jdbc and java.jdbc.sql D. java.sql and javax.sql
Question 4 of 20
5.0/ 5.0 Points
What happens if you call the method close() on a ResultSet object
A. The database and JDBC resources are released B. The ResultSet, together with the Statement which created it and the Connection from which the Statement was retrieved, will be closed and release all database and JDBC resources
C. You will get a SQLException, because only Statement objects can close ResultSets D. The method close() does not exist for a ResultSet. Only Connections can be closed.
Question 5 of 20
5.0/ 5.0 Points
When you code an inner join in a SELECT statement you do not need to specify ?
A. a join column for the first table B. a join column for the second table C. the name of the second table D. an ORDER BY clause
Question 6 of 20
5.0/ 5.0 Points
What statements are correct about JDBC transactions (2 correct answers)?
A.A transaction is finished when commit() or rollback() is called on the Connection object, B.A transaction is a set of successfully executed statements in the database C.A transaction is finished when close() is called on the Connection object D.A transaction is finished when commit() or rollback() is called on the Transaction object
Question 7 of 20
The class java.sql.Timestamp has its super class as
A. java.sql.Time B. java.util.Date
5.0/ 5.0 Points
C. java.util.Time D. None of the above
Question 8 of 20
5.0/ 5.0 Points
Which java.sql class provides the getConnection() method?
A. ResultSet 71 B. Connection C. Driver D. DriverManager
Question 9 of 20
5.0/ 5.0 Points
A transaction is a set of one or more statements t hat is executed as a unit, it means ______________
A. You must sure that all statements are OK before executing it, otherwise, you can not execute this transaction. B. No problem, even in case some statements are committed and the others are rolled back, it's OK to JDBC. C. All of the statements are executed or none of the statements is executed D. All of the statements are executed or some of the statements are executed, it's OK to JDBC.
Question 10 of 20
5.0/ 5.0 Points
Before your application can create a Connection object, it must use the forName method of the Class class to load ?
A. an ODBC data source
B. JDBC C. a DBMS D. a database driver
Question 11 of 20
5.0/ 5.0 Points
What happens if you call deleteRow() on a ResultSet object
A. You will get a compile error: the method does not exist because you can not delete rows from a ResultSet B. The row you are positioned on is deleted from the ResultSet, but not from the database. C. The row you are positioned on is deleted from the ResultSet and from the database D. The result depends on whether the property synchronizeWithDataSource is set to true or false
Question 12 of 20 When the message “No Suitable Driver” occurs
5.0/ 5.0 Points
A. When the driver is not registered by Class.forname() method B. When the user name, password and the database does not match C. When the type 4 driver is used D. When the JDBC database URL passed is not constructed properly
Question 13 of 20
What is, in terms of JDBC, a DataSource
5.0/ 5.0 Points
A. A DataSource is a registry point for JNDI-services B. A DataSource is the basic service for managing a set of JDBC drivers C. A DataSource is a factory of connections to a physical data source D. A DataSource is the Java representation of a physical data source
Question 14 of 20
5.0/ 5.0 Points
The ______ interface communicates with the database, either directly or thought another database specific driver. ?
A. Driver B. DirectManager C. Connection D. Statement
Question 15 of 20
5.0/ 5.0 Points
A __________ result set has a cursor that moves both f orward and backward and can be moved to a particular row
A. nonscrollable B. Unscrollable C. scrollable
Question 16 of 20
What is type-1 of JDBC drivers
A. JDBC-ODBC Bridge driver (Bridge)
5.0/ 5.0 Points
B. Native-API/partly Java driver (Native) C. All Java/Net-protocol driver (Middleware) D. All Java/Native-protocol driver (Pure)
Question 17 of 20
5.0/ 5.0 Points
Which method is used to perform DML statements in JDBC
A. execute() B. executeUpdate() C. executeResult() D. executeQuery()
Question 18 of 20
5.0/ 5.0 Points
Which driver is efficient and always preferable for using JDBC applications
A. Type – 1 B. Type – 4 C. Type – 3 D. Type – 2
Question 19 of 20
Which of the following is false as far as type 4 driver is concern
A. Type 4 driver is “native protocol, pure java” driver
5.0/ 5.0 Points
B. Type 4 drivers uses Socket class to connect to the database C. Type 4 drivers are 100% Java compatible D. Type 4 drivers cannot be used with Netscape
Question 20 of 20
5.0/ 5.0 Points
The JDBC-ODBC bridge is
A. Three tiered B. Multithreaded C. Best for any platform D. All of the above Question 1 of 20
class B { public static void main (String args[]) { Long i1 = new Long(1); Long i2 = new Long(i1); System.out.print((i1==i2) + "," + i1.equals(i2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above
5.0/ 5.0 Points
Question 2 of 20
5.0/ 5.0 Points
class A { public static void main (String args[]) { Integer i1 = new Integer(1); Integer i2 = new Integer(i1); System.out.print(i1.equals(i2)); } } What is the result of attempting to compile and run the program?
A. Prints: false B. Prints: true C. Compile-time error D. Run-time error E. None of the above Question 3 of 20
class B { public static void main (String args[]) { Byte b1 = new Byte(1); // 1 Byte b2 = new Byte('2'); // 2 Byte b3 = new Byte("3"); // 3 byte i1 = b1.byteValue()+b2.byteValue()+b3.byteValue(); // 4 System.out.print(i1); } } What is the result of attempting to compile and run the program? (Multi choice)
A.Compile-time error at 3 B.Compile-time error at 2 C.Compile-time error at 4 D.Run-time error E.Compile-time error at 1 F.Prints: 6
5.0/ 5.0 Points
Question 4 of 20 • Entries are organized as key/value pairs. • Duplicate entries replace old entries.
5.0/ 5.0 Points
Which interface of the java.util package offers the specified behavior?
A. List B. Map C. Set D. None of the above Question 5 of 20 • Entries are not organized as key/value pairs. • Duplicate entries are rejected.
5.0/ 5.0 Points
Which interface of the java.util package offers the specified behavior?
A. List B. Map C. Set D. None of the above Question 6 of 20
class M { static void m1(StringBuffer s1) { s1 = s1.append("B"); System.out.print(s1); } static void m2(StringBuffer s1) { s1.append("C"); System.out.print(s1); } public static void main(String[] s) { StringBuffer s1 = new StringBuffer("A"); m1(s1); m2(s1); System.out.print(s1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABAA
5.0/ 5.0 Points
C. Prints: ABACA D. Prints: ABABAB E. Prints: ABABCAB F. Prints: ABABCABC G. Prints: ABCABCABC H. Compile-time error I. Run-time error J. None of the above Question 7 of 20
5.0/ 5.0 Points
class M { public static void main(String[] s) { String s1 = "A", s2 = " B ", s3 = "C"; s2.trim(); s3.concat("D"); System.out.print(s1 + s2 + s3); } } What is the result of attempting to compile and run the program?
A. Prints: ABC B. Prints: A B C C. Prints: ABCD D. Prints: ABDC E. Prints: A B CD F. Prints: A B DC G. Compile-time error H. Run-time error I. None of the above Question 8 of 20 • Entries are organized as key/value pairs. • Duplicate entries replace old entries. • Entries are sorted using a Comparator or the Comparable interface.
Which interface of the java.util package offers the specified behavior?
5.0/ 5.0 Points
A. List B. Map C. Set D. SortedSet E. SortedMap F. None of the above Question 9 of 20
5.0/ 5.0 Points
class E { public static void main (String[] args) { Byte b1 = new Byte("1"), b2 = new Byte("1"); System.out.print((b1==b2)+","+(b1.equals(b2))); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Question 10 of 20
class M { public static void main(String[] args) { String s1 = "A", s2 = "a", s3 = "b"; s1.toLowerCase(); s3.replace('b','a'); System.out.print((s1.equals(s2)) + "," + (s2.equals(s3))); } } What is the result of attempting to compile and run the program?
5.0/ 5.0 Points
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Question 11 of 20
class D { public static void main (String[] args) { Boolean b1 = new Boolean("trUE"); // 1 Boolean b2 = new Boolean("What's This?"); // 2 Boolean b3 = new Boolean(null); // 3 System.out.print(b1 + "," + b2 + "," + b3); } } What is the result of attempting to compile and run the program?
A. Prints: false,false,false B. Prints: false,false,true C. Prints: false,true,false D. Prints: false,true,true E. Prints: true,false,false F. Prints: true,false,true G. Prints: true,true,false H. Prints: true,true,true I. Compile-time error J. Run-time error K. None of the above
5.0/ 5.0 Points
Question 12 of 20
5.0/ 5.0 Points
class M { public static void main(String[] s) { String s1 = new String("ABCDEFG"), s2 = new String("EFGHIJ"); String s3 = s1.substring(4,7), s4 = s2.substring(0,3); System.out.println((s3 == s4) + "," + (s3 + s4).equals(s4 + s3)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Question 13 of 20
class M { public static void main (String[] args) { String s1 = new String("ABC"), s2 = new String("ABC"); StringBuffer sb1 = new StringBuffer(s1); StringBuffer sb2 = new StringBuffer(s2); System.out.print(s1.equals(s2) + "," + sb1.equals(sb2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error
5.0/ 5.0 Points
F. Run-time error G. None of the above Question 14 of 20
5.0/ 5.0 Points
class ColorException extends Exception {} class WhiteException extends ColorException {} class White { void m1() throws ColorException {throw new WhiteException();} void m2() throws WhiteException {} public static void main (String[] args) { White white = new White(); int a,b,d,f; a = b = d = f = 0; try {white.m1(); a++;} catch (ColorException e) {b++;} try {white.m2(); d++;} catch (WhiteException e) {f++;} System.out.print(a+","+b+","+d+","+f); } } What is the result of attempting to compile and run the program?
A. Prints: 0,1,0,0 B. Prints: 1,1,0,0 C. Prints: 0,1,1,0 D. Prints: 1,1,1,0 E. Prints: 1,1,1,1 F. Compile-time error G. Run-time error H. None of the above Question 15 of 20
class A { public static void main (String[] args) { Error error = new Error(); Exception exception = new Exception(); System.out.print((exception instanceof Throwable) + ","); System.out.print(error instanceof Throwable); } } What is the result of attempting to compile and run the program?
5.0/ 5.0 Points
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Question 16 of 20
class M { static void m1(StringBuffer s1) { s1 = s1.append("B"); System.out.print(s1); } static void m2(StringBuffer s1) { s1.append("C"); System.out.print(s1); } public static void main(String[] s) { StringBuffer s1 = new StringBuffer("A"); m1(s1); m2(s1); System.out.print(s1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABAA C. Prints: ABACA D. Prints: ABABAB E. Prints: ABABCAB F. Prints: ABABCABC G. Prints: ABCABCABC H. Compile-time error I. Run-time error
5.0/ 5.0 Points
J. None of the above Question 17 of 20 • Stores key/value pairs. • Allows null elements, keys, and values. • Duplicate entries replace old entries. • Entries are not sorted.
5.0/ 5.0 Points
Which of these classes provides the specified features?
A. LinkedList B. TreeMap C. TreeSet D. HashMap E. HashSet F. Hashtable G. None of the above Question 18 of 20
5.0/ 5.0 Points
class A { public static void main (String args[]) { Double d1 = new Double(1.0); Double d2 = new Double(d1); System.out.print(d1.equals(d2)); } } What is the result of attempting to compile and run the program?
A. Prints: false B. Prints: true C. Compile-time error D. Run-time error E. None of the above Question 19 of 20
class M { public static void main (String[] args) {
5.0/ 5.0 Points
StringBuffer sb1 = new StringBuffer("ABC"); StringBuffer sb2 = new StringBuffer("ABC"); System.out.print((sb1==sb2)+","+sb1.equals(sb2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Question 20 of 20
5.0/ 5.0 Points
class G { public static void main (String[] args) { Integer i1 = new Integer("1"), i2 = new Integer("1"); StringBuffer sb1 = new StringBuffer("1"); StringBuffer sb2 = new StringBuffer("1"); System.out.print(sb1.equals(sb2)+","+i1.equals(i2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Part 1 of 1 -
100.0/ 100.0 Points
Question 1 of 20
5.0/ 5.0 Points
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A c1 = new C(); B c2 = new C(); C c3 = new C(); C c4 = new C(); c4.m1(c1); c4.m1(c2); c4.m1(c3); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above Question 2 of 20
class G { static String m(float i) {return "float";} static String m(double i) {return "double";} public static void main (String[] args) { char a1 = 1; long b1 = 2; System.out.print(m(a1)+","+ m(b1)); } } What is the result of attempting to compile and run the program?
A. Prints: float,float B. Prints: float,double
5.0/ 5.0 Points
C. Prints: double,float D. Prints: double,double E. Compile-time error F. Run-time error G. None of the above Question 3 of 20
5.0/ 5.0 Points
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A a1 = new A(); B b1 = new B(); C c1 = new C(); C c2 = new A(); c2.m1(a1); c2.m1(b1); c2.m1(c1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above Question 4 of 20
class G { static String m(float i) {return "float";} static String m(double i) {return "double";} public static void main (String[] args) { int a1 = 1; long b1 = 2; System.out.print(m(a1)+","+ m(b1)); }
5.0/ 5.0 Points
} What is the result of attempting to compile and run the program?
A. Prints: float,float B. Prints: float,double C. Prints: double,float D. Prints: double,double E. Compile-time error F. Run-time error G. None of the above Question 5 of 20
5.0/ 5.0 Points
Which of the following modifiers can not be applied to a method? A. abstract B. private C. protected D. public E. volatile F. None of the above. Question 6 of 20
class Red { public int a; public static int b; public static void main (String[] in) { Red r1 = new Red(), r2 = new Red(); r1.a++; r1.b++; System.out.print(r1.a+", "+r1.b+", "+r2.a+", "+r2.b); } } What is the result of attempting to compile and run the program?
5.0/ 5.0 Points
A. Prints: 0, 0, 0, 0 B. Prints: 0, 1, 1, 1 C. Prints: 1, 1, 1, 0 D. Prints: 1, 1, 0, 1 E. Prints: 1, 1, 0, 0 F. Prints: 1, 1, 1, 1 G. Compile-time error H. Run-time error I. None of the above Question 7 of 20
5.0/ 5.0 Points
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A a1 = new A(); A b1 = new B(); A c1 = new C(); C c4 = new C(); a1.m1(c4); b1.m1(c4); c1.m1(c4); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above Question 8 of 20
5.0/ 5.0 Points
class G { int x; // 1 public static void main(String[] args) { // 2 int y = 0; // 3 System.out.print(x+","); // 4 System.out.print(y); // 5 } } What is the result of attempting to compile and run the program?
A. Prints: 0,0 B. Compile-time error at line 1. C. Compile-time error at line 1. D. Compile-time error at line 2. E. Compile-time error at line 3. F. Compile-time error at line 4. G. Compile-time error at line 5. H. Run-time error I. None of the above Question 9 of 20
5.0/ 5.0 Points
Which of the following modifiers can be applied to a class that is not a nested class? (Multi choice) A.public B.protected C.private D.abstract E.static F.Final Question 10 of 20
5.0/ 5.0 Points
Which of the following statements is true? A. An abstract method can not be overridden by an abstract method. B. An instance method that is not abstract can not be overridden by an abstract method. C. An abstract method declaration can not include a throws clause. D. The body of an abstract method is represented by a set of empty brackets. E. None of the above. Question 11 of 20
5.0/ 5.0 Points
class G { static void m(Object x) {System.out.print("Object");} static void m(String x) {System.out.print("String");} public static void main(String[] args) {m(null);} } What is the result of attempting to compile and run the program?
A. Prints: Object B. Prints: String C. Compile-time error D. Run-time error E. None of the above Question 12 of 20
5.0/ 5.0 Points
Which of the following modifiers can not be used with the abstract modifier in a method declaration? (Multi choice) A.final B.private C.protected D.public E.static F.synchronized
G.native Question 13 of 20
5.0/ 5.0 Points
class A {} class B extends A {} class C extends B {} class D { void m1(A a) {System.out.print("A");} void m1(B b) {System.out.print("B");} void m1(C c) {System.out.print("C");} public static void main(String[] args) { A c1 = new C(); B c2 = new C(); C c3 = new C(); D d1 = new D(); d1.m1(c1); d1.m1(c2); d1.m1(c3); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above Question 14 of 20
5.0/ 5.0 Points
public class Basics {} // 1 class Basics1 {} // 2 protected class Basics2 {} // 3 private class Basics3 {} // 4 Class Basics4 {} // 5 Suppose these are top-level class declarations and not nested class declarations; and suppose that all of the declarations are contained in one file named Basics.java. Compile-time errors are generated at which lines? (Multi choice) A.1 B.2
C.3 D.4 E.5 Question 15 of 20
5.0/ 5.0 Points
class A { static int x; // 1 public static void main(String[] args) { // 2 int y; // 3 System.out.println("x="+x); // 4 System.out.println("y="+y); // 5 } } What is the result of attempting to compile and run the program?
A. Compile-time error at line 1. B. Compile-time error at line 2. C. Compile-time error at line 3. D. Compile-time error at line 4. E. Compile-time error at line 5. F. Run-time error G. None of the above Question 16 of 20
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D extends C { void m1(D d) {System.out.print("D");} public static void main(String[] args) { A a1 = new A(); B b1 = new B(); C c1 = new C(); D d1 = new D(); d1.m1(a1); d1.m1(b1); d1.m1(c1); }
5.0/ 5.0 Points
} What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: DDD D. Prints: ABCD E. Compile-time error F. Run-time error G. None of the above Question 17 of 20
5.0/ 5.0 Points
Which of the following modifiers can be applied to a constructor? (Multi choice) A.protected B.public C.static D.synchronized E.Transient Question 18 of 20
5.0/ 5.0 Points
abstract class A {} // 1 transient class G {} // 2 private class C {} // 3 static class E {} // 4 Suppose these are top-level class declarations and not nested class declarations. Which of these declarations would not produce a compile-time error? A. 1 B. 2 C. 3 D. 4
E. None of the above Question 19 of 20
5.0/ 5.0 Points
Which of the following modifiers can be applied to the declaration of a field? (Multi choice) A.abstract B.final C.private D.protected E.Public Question 20 of 20
5.0/ 5.0 Points
class Basics { int x = 1, y = 2; public static void main (String[] args) {System.out.println(x+y);} } What is the result of attempting to compile and run the program?
A. Prints: x+y B. Prints: 12 C. Prints: 3 D. Run-time error E. Compile-time error F. None of the above Question 1 of 20
class T { public static void main (String[] args) { byte b = 1; // 1 long l = 1000; // 2 b += l; // 3 }
5.0/ 5.0 Points
} A compile-time error is generated at which line?
A. 1 B. 2 C. 3 D. None of the above Question 2 of 20
5.0/ 5.0 Points
class M { public static void main(String[] s) { String s1 = "1", s2 = "2", s3 = s1 + s2; s1 += s2; s3 += s1; System.out.println(s3); } } What is the result of attempting to compile and run the program?
A. Prints: 3 B. Prints: 6 C. Prints: 33 D. Prints: 1212 E. Compile-time error F. Run-time error G. None of the above Question 3 of 20
class M { public static void main(String args[]) { String a = "A", b = "B", c = a+b, d = a+b; System.out.print(((a+b)==(a+b)) + ","); System.out.print((c==d) + ","); System.out.print(c.equals(d)); }
5.0/ 5.0 Points
} What is the result of attempting to compile and run the program?
A. Prints: false,true,false B. Prints: true,false,false C. Prints: true,false,true D. Prints: false,false,true E. Prints: false,true,true F. Prints: true,true,false G. Prints: false,false,false H. Prints: true,true,true Question 4 of 20
5.0/ 5.0 Points
class E { static int m(int i) {System.out.print(i + ","); return 0;} public static void main (String[] args) { int i = 0; i = i++ + m(i); System.out.print(i); } } What is the result of attempting to compile and run the above program?
A. Prints: 0,0 B. Prints: 1,0 C. Prints: 0,1 D. Prints: 1,1 E. Run-time error F. Compile-time error G. None of the above Question 5 of 20
class M { static int i; public static void main(String args[]) {
5.0/ 5.0 Points
for (i=1; i<3; i++) {System.out.print(i);} // 1 for (int i=1; i<3; i++) {System.out.print(i);} // 2 int i; // 3 for (i=0; i<2; i++) {System.out.print(i);} // 4 System.out.print(M.i); } } What is the result of attempting to compile and run the program?
A. Prints: 1212010 B. Prints: 1212013 C. Compile-time error at line 1 D. Compile-time error at line 2 E. Compile-time error at line 4 F. Run-time error G. None of the above Question 6 of 20
class E { public static void main(String args[]) { int a = 1; a += ++a + a++; System.out.print(a); } } What is the result of attempting to compile and run the above program?
A. Prints: 3 B. Prints: 4 C. Prints: 5 D. Prints: 6 E. Prints: 7 F. Run-time error G. Compile-time error H. None of the above
5.0/ 5.0 Points
Question 7 of 20
5.0/ 5.0 Points
class M { public static void main (String[] args) { // Insert code here. } } Which of the following lines can be inserted at the specified location without generating a compile-time error?
A. char a = a; B. char b = abc; C. char c = \u0041; D. char d = \uabcd; E. None of the above Question 8 of 20
class A { public static void main(String args[]) { for (int i = 0; i<5 ;i++) { switch(i) { case 0: System.out.print("v ");break; case 1: System.out.print("w "); case 2: System.out.print("x ");break; case 3: System.out.print("y "); case 4: System.out.print("z ");break; default: System.out.print("d "); } } } } What is the result of attempting to compile and run the program?
A. Prints: v w x y z B. Prints: v w x y z d C. Prints: v w x x y z z D. Prints: v w w x y y z d
5.0/ 5.0 Points
E. Prints: d d d d d d F. Run-time error G. Compile-time error H. None of the above Question 9 of 20
5.0/ 5.0 Points
class M { public static void main(String[] args) { boolean b; if (b = false) {System.out.print("A"); } else if (b) {System.out.print("B"); } else if (!b) {System.out.print("C"); } else {System.out.print("D");} } } What is the result of attempting to compile and run the program?
A. Prints: A B. Prints: B C. Prints: C D. Prints: D E. Run-time error F. Compile-time error G. None of the above Question 10 of 20
class E { static int m(int i) {System.out.print(i + ", "); return i;} public static void main(String s[]) { int i = 1; m(m(++i) + m(i++) + m(-i) + m(i++)); } } What is the result of attempting to compile and run the above program?
A. Prints: 1, 2, 3, 4, 10,
5.0/ 5.0 Points
B. Prints: 1, 2, -3, 4, 4, C. Prints: 2, 2, -3, -3, -2, D. Prints: 2, 2, -3, 3, 4, E. Prints: 2, 3, -3, -2, 0, F. Prints: 2, 3, -3, 4, 6, G. Prints: 2, 3, 4, 5, 14, H. Run-time error I. Compile-time error J. None of the above Question 11 of 20
5.0/ 5.0 Points
class E { public static void main (String[] args) { byte x = 3, y = 5; System.out.print((y % x) + ","); System.out.print(y == ((y/x)*x + (y%x))); } } What is the result of attempting to compile and run the program?
A. Prints: 1,true B. Prints: 2,true C. Prints: 1,false D. Prints: 2,false E. Run-time error F. Compile-time error G. None of the above Question 12 of 20
class A { public static void main(String[] args) {
5.0/ 5.0 Points
boolean b = true; if (b = false) {System.out.print("A"); } else if (b) {System.out.print("B"); } else {System.out.print("C");} } } What is the result of attempting to compile and run the program?
A. Prints: A B. Prints: B C. Prints: C D. Run-time error E. Compile-time error F. None of the above Question 13 of 20
5.0/ 5.0 Points
class M { public static void main(String[] args) { boolean b = true; if (b = false) {System.out.print("A"); } else if (b) {System.out.print("B"); } else {System.out.print("C");} } } What is the result of attempting to compile and run the program?
A. Prints: A B. Prints: B C. Prints: C D. Run-time error E. Compile-time error F. None of the above Question 14 of 20
5.0/ 5.0 Points
class M { public static void main(String[] s) { String s1 = new String("ABCDEFG"), s2 = new String("EFGHIJ"); String s3 = s1.substring(4,7), s4 = s2.substring(0,3); System.out.println((s3 == s4) + "," + (s3 + s4).equals(s4 + s3)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Question 15 of 20
class E { static int m(int i) {System.out.print(i + ", "); return i;} public static void main(String s[]) { m(m(1) + m(2) % m(3) * m(4)); } } What is the result of attempting to compile and run the program?
A. Prints: 1, 2, 3, 4, 0, B. Prints: 1, 2, 3, 4, 3, C. Prints: 1, 2, 3, 4, 9, D. Prints: 1, 2, 3, 4, 12, E. Prints: 2, 3, 4, 1, 9, F. Prints: 2, 3, 4, 1, 3, G. Run-time error
5.0/ 5.0 Points
H. Compile-time error I. None of the above Question 16 of 20
5.0/ 5.0 Points
class E { static boolean a, b, c; public static void main (String[] args) { boolean x = a || (b = true) && (c = true); System.out.print(a + "," + b + "," + c); } } What is the result of attempting to compile and run the program?
A. Prints: true,true,true B. Prints: false,true,true C. Run-time error D. Prints: false,true,false E. Prints: true,false,false F. Prints: false,false,true G. Prints: false,false,false H. Compile-time error I. Prints: true,false,true J. Prints: true,true,false Question 17 of 20
class M { public static void main (String[] args) { String s = null; System.out.print(s); } } What is the result of attempting to compile and run the program?
A. Prints nothing.
5.0/ 5.0 Points
B. Prints: null C. Compile-time error D. Run-time error E. None of the above Question 18 of 20
5.0/ 5.0 Points
class M { public static void main (String[] args) { // Insert code here. } } Which of the following lines can be inserted at the specified location without generating a compile-time error?
A. String a = 'a'; B. String b = 'abc'; C. String c = '\u0041'; D. String d = '\uabcd'; E. None of the above Question 19 of 20
class M { public static void main (String[] args) { int i = 0, j = 9; do { i++; if (j-- < i++) {break;} } while (i < 5); System.out.print(i + "," + j); } } What is the result of attempting to compile and run the program?
A. Prints: 5,4 B. Prints: 6,3 C. Prints: 6,6
5.0/ 5.0 Points
D. Prints: 7,2 E. Run-time error F. Compile-time error G. None of the above Question 20 of 20
5.0/ 5.0 Points
class E { static int m(int i) {System.out.print(i + ", "); return i;} public static void main(String s[]) { m(m(1) - m(2) + m(3) * m(4)); } } What is the result of attempting to compile and run the program?
A. Prints: 1, 2, 3, 4, 8, B. Prints: 1, 2, 3, 4, 11, C. Prints: 3, 4, 1, 2, 11, D. Run-time error E. Compile-time error F. None of the above 05_BTJB_Quiz1_Java Basics &OOP in Java Returnto AssessmentList
Part 1 of 1 -
Question 1 of 20
class E { static int m(int i) {System.out.print(i + ", "); return i;} public static void main(String s[]) { m(m(1) + m(2) % m(3) * m(4)); }
100.0/ 100.0 Points 5.0/ 5.0 Points
} What is the result of attempting to compile and run the program?
A. Prints: 1, 2, 3, 4, 0, B. Prints: 1, 2, 3, 4, 3, C. Prints: 1, 2, 3, 4, 9, D. Prints: 1, 2, 3, 4, 12, E. Prints: 2, 3, 4, 1, 9, F. Prints: 2, 3, 4, 1, 3, G. Run-time error H. Compile-time error I. None of the above Question 2 of 20
5.0/ 5.0 Points
class M { public static void main (String[] args) { String a1 = null; // 1 String b1 = 'null'; // 2 String c1 = "null"; // 3 String d1 = "'null'"; // 4 } } A compile-time error is generated at which line?
A. 1 B. 2 C. 3 D. 4 E. None of the above Question 3 of 20
5.0/ 5.0 Points
class E { public static void main(String args[]) { int a = 1; a += ++a + a++; System.out.print(a); } } What is the result of attempting to compile and run the above program?
A. Prints: 3 B. Prints: 4 C. Prints: 5 D. Prints: 6 E. Prints: 7 F. Run-time error G. Compile-time error H. None of the above Question 4 of 20
class A { public static void main(String[] args) { boolean b = true; if (b = false) {System.out.print("A"); } else if (b) {System.out.print("B"); } else {System.out.print("C");} } } What is the result of attempting to compile and run the program?
A. Prints: A B. Prints: B C. Prints: C D. Run-time error
5.0/ 5.0 Points
E. Compile-time error F. None of the above Question 5 of 20
5.0/ 5.0 Points
class A { public static void main(String[] args) { for (int i = 0; i < 4; i++) { switch (i) { case 0: System.out.print("A"); case 1: System.out.print("B"); case 2: System.out.print("C"); } } } } A. Prints: ABC B. Prints: ABCC C. Prints: CBA D. Prints: ABCBCC E. Run-time error F. Compile-time error G. None of the above Question 6 of 20
class M { public static void main (String[] args) { System.out.print(String.valueOf(1) + String.valueOf(2)); String s1 = "S1"; String s2 = s1.toString(); System.out.print("," + (s1==s2)); }
5.0/ 5.0 Points
} What is the result of attempting to compile and run the program?
A. Prints: 3,false B. Prints: 3,true C. Prints: 12,false D. Prints: 12,true E. Compile-time error F. Run-time error G. None of the above Question 7 of 20
5.0/ 5.0 Points
class M { public static void main (String[] args) { // Insert code here. } } Which of the following lines can be inserted at the specified location without generating a compile-time error?
A. boolean b1 = true; B. boolean b2 = TRUE; C. boolean b3 = 'true'; D. boolean b4 = "TRUE"; E. boolean b5 = 0; F. None of the above Question 8 of 20
class M { public static void main (String[] args) { String s1 = "ABCDE"; System.out.print(s1.substring(1,2)+s1.substring(3));
5.0/ 5.0 Points
}} What is the result of attempting to compile and run the program? A. Prints: AABC B. Prints: ACDE C. Prints: ABABC D. Prints: ABCDE E. Prints: BABCD F. Prints: BDE G. None of the above Question 9 of 20
class M { static boolean b; public static void main(String[] args) { if (b) {System.out.print("A"); } else if (b = false) {System.out.print("B"); } else if (b) {System.out.print("C"); } else if (!b) {System.out.print("D"); } else {System.out.print("E");} } } What is the result of attempting to compile and run the program?
A. Prints: A B. Prints: B C. Prints: C D. Prints: D E. Prints: E F. Run-time error G. Compile-time error H. None of the above
5.0/ 5.0 Points
Question 10 of 20
5.0/ 5.0 Points
class M { public static void main(String[] args) { int[][] a1 = {{1,2,3},{4,5,6},{7,8,9,10}}; System.out.print(a1[0][2]+","+a1[1][0]+","+a1[2][1]); } } What is the result of attempting to compile and run the program?
A. Prints: 3,4,8 B. Prints: 7,2,6 C. Compile-time error D. Run-time error E. None of the above Question 11 of 20
class A { public static void main(String[] args) { char a = 'a', b = 'b'; // 'a' = 97, 'b' = 98 System.out.print(a + b + "" + a + b); } } What is the result of attempting to compile and run the program?
A. Prints: 390 B. Prints: 195195 C. Prints: 195ab D. Prints: ab195 E. Prints: abab F. Run-time error
5.0/ 5.0 Points
G. Compile-time error H. None of the above Question 12 of 20
5.0/ 5.0 Points
class M { public static void main(String[] args) { int[] a1 = {1,2,3}; int []a2 = {4,5,6}; int a3[] = {7,8,9}; System.out.print(a1[1]+","+a2[1]+","+a3[1]); } } What is the result of attempting to compile and run the program?
A. Prints: 12 B. Prints: 2,5,8 C. Prints: 18 D. Prints: 1,4,7 E. Compile-time error F. Prints: 3,6,9 G. Prints: 15 Question 13 of 20
class M { public static void main(String[] args) { boolean b = true; if (b = false) {System.out.print("A"); } else if (b) {System.out.print("B"); } else {System.out.print("C");} } } What is the result of attempting to compile and run the program?
5.0/ 5.0 Points
A. Prints: A B. Prints: B C. Prints: C D. Run-time error E. Compile-time error F. None of the above Question 14 of 20
5.0/ 5.0 Points
class E { static boolean a, b, c; public static void main (String[] args) { boolean x = (a = true) || (b = true) && (c = true); System.out.print(a + "," + b + "," + c); } } What is the result of attempting to compile and run the program?
A. Prints: false,false,false B. Prints: false,false,true C. Prints: false,true,false D. Prints: false,true,true E. Prints: true,false,false F. Prints: true,false,false G. Prints: true,true,false H. Prints: true,true,true I. Run-time error J. Compile-time error Question 15 of 20
5.0/ 5.0 Points
class M { public static void main(String[] s) { String s1 = new String("ABCDEFG"), s2 = new String("EFGHIJ"); String s3 = s1.substring(4,7), s4 = s2.substring(0,3); System.out.println((s3 == s4) + "," + (s3 + s4).equals(s4 + s3)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Question 16 of 20
class M { public static void main(String args[]) { int x = 6; int success = 0; do { switch(x) { case 0: System.out.print("0"); x += 5; break; case 1: System.out.print("1"); x += 3; break; case 2: System.out.print("2"); x += 1; break; case 3: System.out.print("3"); success++; break; case 4: System.out.print("4"); x -= 1; break; case 5: System.out.print("5"); x -= 4; break; case 6: System.out.print("6"); x -= 5; break; } } while ((x != 3) || (success < 2)); } } What is the result of attempting to compile and run the program?
5.0/ 5.0 Points
A. Prints: 6152433 B. Prints: 60514233 C. Prints: 6143 D. Run-time error E. Compile-time error F. Prints: 61433 Question 17 of 20
5.0/ 5.0 Points
class M { static int i; public static void main(String args[]) { for (i=1; i<3; i++) {System.out.print(i);} // 1 for (int i=1; i<3; i++) {System.out.print(i);} // 2 int i; // 3 for (i=0; i<2; i++) {System.out.print(i);} // 4 System.out.print(M.i); } } What is the result of attempting to compile and run the program?
A. Prints: 1212010 B. Prints: 1212013 C. Compile-time error at line 1 D. Compile-time error at line 2 E. Compile-time error at line 4 F. Run-time error G. None of the above Question 18 of 20
Which of these lists contains at least one word that is not a Java keyword?
5.0/ 5.0 Points
A. abstract, default, if, private, this B. do, implements, protected, boolean, throw C. case, extends, int, short, try D. import, break, double, exception, throws E. byte, else, instanceof, return, transient F. None of the above Question 19 of 20
5.0/ 5.0 Points
class M { public static void main (String args[]) { char c = 'b'; switch(c) { case 'a': System.out.print("1"); case 'b': System.out.print("2"); case 'c': System.out.print("3"); default: System.out.print("4"); } } } What is the result of attempting to compile and run the program?
A. Prints: 3 B. Prints: 34 C. Prints: 234 D. Prints: 1234 E. Run-time error F. Compile-time error G. None of the above Question 20 of 20
5.0/ 5.0 Points
class A { public static void main(String[] args) { int[] a1 = new int[]; // 1 int a2[] = new int[5]; // 2 int[] a3 = new int[]{1,2}; // 3 int []a4 = {1,2}; // 4 int[] a5 = new int[5]{1,2,3,4,5}; // 5 } } Compile-time errors are generated at which lines? (Multi choice)
A.2 B.4 C.3 D.1 E.5
05_BTJB_Quiz2_Advanced OOP in Java Returnto AssessmentList
Part 1 of 1 -
Question 1 of 20
100.0/ 100.0 Points 5.0/ 5.0 Points
abstract class A {} // 1 transient class G {} // 2 private class C {} // 3 static class E {} // 4 Suppose these are top-level class declarations and not nested class declarations. Which of these declarations would not produce a compile-time error? A. 1
B. 2 C. 3 D. 4 E. None of the above Question 2 of 20
5.0/ 5.0 Points
Which of the following statements is true? A. An abstract method can not be overridden by an abstract method. B. An instance method that is not abstract can not be overridden by an abstract method. C. An abstract method declaration can not include a throws clause. D. The body of an abstract method is represented by a set of empty brackets. E. None of the above. Question 3 of 20
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A c1 = new C(); B c2 = new C(); C c3 = new C(); C c4 = new C(); c4.m1(c1); c4.m1(c2); c4.m1(c3); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above
5.0/ 5.0 Points
Question 4 of 20
5.0/ 5.0 Points
class G { static String m(float i) {return "float";} static String m(double i) {return "double";} public static void main (String[] args) { char a1 = 1; long b1 = 2; System.out.print(m(a1)+","+ m(b1)); } } What is the result of attempting to compile and run the program?
A. Prints: float,float B. Prints: float,double C. Prints: double,float D. Prints: double,double E. Compile-time error F. Run-time error G. None of the above Question 5 of 20
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A c1 = new C(); C c2 = new C(); c1.m1(c2); } } What is the result of attempting to compile and run the program?
A. Prints: A B. Prints: B
5.0/ 5.0 Points
C. Prints: C D. Compile-time error E. Run-time error F. None of the above Question 6 of 20
5.0/ 5.0 Points
Which of the following modifiers can be applied to a constructor? A. private B. abstract C. final D. volatile E. native F. None of the above. Question 7 of 20
5.0/ 5.0 Points
class Basics { int x = 1, y = 2; public static void main (String[] args) {System.out.println(x+y);} } What is the result of attempting to compile and run the program?
A. Prints: x+y B. Prints: 12 C. Prints: 3 D. Run-time error E. Compile-time error F. None of the above Question 8 of 20
5.0/ 5.0 Points
class G { static String m(int i) {return "int";} static String m(float i) {return "float";} public static void main (String[] args) { long a1 = 1; double b1 = 2; System.out.print(m(a1)+","+ m(b1)); } } What is the result of attempting to compile and run the program?
A. Prints: float,float B. Prints: float,double C. Prints: double,float D. Prints: double,double E. Compile-time error F. Run-time error G. None of the above Question 9 of 20
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A a1 = new A(); A b1 = new B(); A c1 = new C(); C c4 = new C(); a1.m1(c4); b1.m1(c4); c1.m1(c4); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC
5.0/ 5.0 Points
D. Compile-time error E. Run-time error F. None of the above Question 10 of 20
5.0/ 5.0 Points
class Red { public int a; public static int b; public static void main (String[] in) { Red r1 = new Red(), r2 = new Red(); r1.a++; r1.b++; System.out.print(r1.a+", "+r1.b+", "+r2.a+", "+r2.b); } } What is the result of attempting to compile and run the program?
A. Prints: 0, 0, 0, 0 B. Prints: 0, 1, 1, 1 C. Prints: 1, 1, 1, 0 D. Prints: 1, 1, 0, 1 E. Prints: 1, 1, 0, 0 F. Prints: 1, 1, 1, 1 G. Compile-time error H. Run-time error I. None of the above Question 11 of 20
5.0/ 5.0 Points
Which of the following modifiers can be applied to the declaration of a field? (Multi choice) A.abstract B.final C.private D.protected
E.Public Question 12 of 20
5.0/ 5.0 Points
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A a1 = new A(); B b1 = new B(); C c1 = new C(); A c2 = new C(); c2.m1(a1); c2.m1(b1); c2.m1(c1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above Question 13 of 20
5.0/ 5.0 Points
Which of the following modifiers can not be applied to a method? A. abstract B. private C. protected D. public E. volatile F. None of the above. Question 14 of 20
5.0/ 5.0 Points
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A a1 = new A(); B b1 = new B(); C c1 = new C(); C c2 = new A(); c2.m1(a1); c2.m1(b1); c2.m1(c1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above Question 15 of 20
5.0/ 5.0 Points
Which of the following modifiers can be applied to a class that is not a nested class? (Multi choice) A.public B.protected C.private D.abstract E.static F.Final Question 16 of 20
class G { static String m(float i) {return "float";} static String m(double i) {return "double";}
5.0/ 5.0 Points
public static void main (String[] args) { int a1 = 1; long b1 = 2; System.out.print(m(a1)+","+ m(b1)); } } What is the result of attempting to compile and run the program?
A. Prints: float,float B. Prints: float,double C. Prints: double,float D. Prints: double,double E. Compile-time error F. Run-time error G. None of the above Question 17 of 20
5.0/ 5.0 Points
class G { static void m(Object x) {System.out.print("Object");} static void m(String x) {System.out.print("String");} public static void main(String[] args) {m(null);} } What is the result of attempting to compile and run the program?
A. Prints: Object B. Prints: String C. Compile-time error D. Run-time error E. None of the above Question 18 of 20
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}}
5.0/ 5.0 Points
class D { public static void main(String[] args) { A a1 = new A(); B b1 = new A(); C c1 = new A(); C c2 = new C(); c2.m1(a1); c2.m1(b1); c2.m1(c1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above Question 19 of 20
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D extends C { void m1(D d) {System.out.print("D");} public static void main(String[] args) { A a1 = new A(); B b1 = new B(); C c1 = new C(); D d1 = new D(); d1.m1(a1); d1.m1(b1); d1.m1(c1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: DDD D. Prints: ABCD E. Compile-time error
5.0/ 5.0 Points
F. Run-time error G. None of the above Question 20 of 20
5.0/ 5.0 Points
class A {} class B extends A {} class C extends B {} class D { void m1(A a) {System.out.print("A");} void m1(B b) {System.out.print("B");} void m1(C c) {System.out.print("C");} public static void main(String[] args) { A c1 = new C(); B c2 = new C(); C c3 = new C(); D d1 = new D(); d1.m1(c1); d1.m1(c2); d1.m1(c3); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above
05_BTJB_Quiz3_Exception Handli ng & Util ity Class es Returnto AssessmentList
Part 1 of 1 -
100.0/ 100.0 Points
5.0/ 5.0 Points Question 1 of 20
• Entries are organized as key/value pairs. • Duplicate entries replace old entries. • Entries are sorted using a Comparator or the Comparable interface. Which interface of the java.util package offers t he specified behavior?
A. List B. Map C. Set D. SortedSet E. SortedMap F. None of the above 5.0/ 5.0 Points Question 2 of 20
class G { public static void main (String[] args) { Integer i1 = new Integer("1"), i2 = new Integer("1"); StringBuffer sb1 = new StringBuffer("1"); StringBuffer sb2 = new StringBuffer("1"); System.out.print(sb1.equals(sb2)+","+i1.equals(i2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false
D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above 5.0/ 5.0 Points Question 3 of 20
class M { public static void main (String[] args) { String s1 = new String("ABC"), s2 = new String("ABC"); StringBuffer sb1 = new StringBuffer(s1); StringBuffer sb2 = new StringBuffer(s2); System.out.print(s1.equals(s2) + "," + sb1.equals(sb2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above 5.0/ 5.0 Points Question 4 of 20
Which implementation of the List interface provides for t he fastest insertion of a new element into the middle of the list?
A. Vector B. ArrayList C. LinkedList D. None of the above 5.0/ 5.0 Points Question 5 of 20
class M { static void m1(StringBuffer s1) { s1.append("B"); System.out.print(s1); } static void m2(StringBuffer s1) { s1 = new StringBuffer("C"); System.out.print(s1); } public static void main(String[] s) { StringBuffer s1 = new StringBuffer("A"); m1(s1); m2(s1); System.out.print(s1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABCA C. Prints: ABCAB D. Prints: ABCABC
E. Prints: ABCAC F. Prints: ABABCABC G. Compile-time error H. Run-time error I. None of the above 5.0/ 5.0 Points Question 6 of 20
class M { public static void main(String[] args) { String s1 = "A", s2 = "a", s3 = "b"; s1.toLowerCase(); s3.replace('b','a'); System.out.print((s1.equals(s2)) + "," + (s2.equals(s3))); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above 5.0/ 5.0 Points Question 7 of 20
class M { public static void void main (String[] (String[] args) { String s1 = "ABC"; StringBuffer StringBuffer s2 = new StringBuffer(s1); StringBuffer(s1); System.out.print(s2.equals System.out.print(s2.equals(s1) (s1) + "," + s1.equals(s2)); s1.equals(s2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above 5.0/ 5.0 Points Question 8 of 20
• Stores key/value pairs. • Duplicate entries replace old entries. • Entries are sorted using a Comparator C omparator or the Comparable interface. Which of these classes provides the specified features?
A. LinkedList B. TreeMap C. TreeSet
D. HashMap E. HashSet F. Hashtable G. None of the above 5.0/ 5.0 Points Question 9 of 20
class M { public static void void main (String[] (String[] args) { String s1 = "ABC"; StringBuffer StringBuffer s2 = new StringBuffer(s1); StringBuffer(s1); System.out.print(s2.equals System.out.print(s2.equals(s1) (s1) + "," + s1.equals(s2)); s1.equals(s2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above 5.0/ 5.0 Points Question 10 of 20
class M { static void m1(StringBuffer s1) {
s1 = s1.append("B"); System.out.print(s1); System.out.print(s1); } static void m2(StringBuffer s1) { s1.append("C"); s1.append("C"); System.out.print(s1); System.out.print(s1); } public static void void main(String[] main(String[] s) { StringBuffer StringBuffer s1 = new StringBuffer("A"); StringBuffer("A"); m1(s1); m2(s1); System.out.print(s1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABAA C. Prints: ABACA D. Prints: ABABAB E. Prints: ABABCAB F. Prints: ABABCABC G. Prints: ABCABCABC H. Compile-time error I. Run-time error J. None of the above 5.0/ 5.0 Points Question 11 of 20
• Stores key/value pairs. • Allows null elements, keys, and values. • Duplicate entries replace old entries.
• Entries are not sorted. Which of these classes provides the specified features?
A. LinkedList B. TreeMap C. TreeSet D. HashMap E. HashSet F. Hashtable G. None of the above 5.0/ 5.0 Points Question 12 of 20
class A { public static void main(String[] args) { Boolean b1 = new Boolean(true); // 1 Boolean b2 = new Boolean(false); // 2 Boolean b3 = new Boolean(TRUE); // 3 Boolean b4 = new Boolean(FALSE); // 4 Boolean b5 = new Boolean("TrUe"); // 5 Boolean b6 = new Boolean("fAlSe"); // 6 } } Compile-time errors are generated at which lines? (Multi choice)
A.1 B.5 C.4
D.2 E.3 F.6 5.0/ 5.0 Points Question 13 of 20
• Entries are organized as key/value pairs. • Duplicate entries replace old entries. Which interface of the java.util package offers t he specified behavior?
A. List B. Map C. Set D. None of the above 5.0/ 5.0 Points Question 14 of 20
class M { public static void main(String[] s) { String s1 = "A", s2 = " B ", s3 = "C"; s2.trim(); s3.concat("D"); System.out.print(s1 + s2 + s3); } } What is the result of attempting to compile and run the program?
A. Prints: ABC B. Prints: A B C
C. Prints: ABCD D. Prints: ABDC E. Prints: A B CD F. Prints: A B DC G. Compile-time error H. Run-time error I. None of the above 5.0/ 5.0 Points Question 15 of 20
class M { public static void main (String[] args) { StringBuffer sb1 = new StringBuffer("ABC"); StringBuffer sb2 = new StringBuffer("ABC"); System.out.print((sb1==sb2)+","+sb1.equals(sb2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error
G. None of the above 5.0/ 5.0 Points Question 16 of 20
class A { public static void main (String[] args) { Error error = new Error(); Exception exception = new Exception(); System.out.print((exception instanceof Throwable) + ","); System.out.print(error instanceof Throwable); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above 5.0/ 5.0 Points Question 17 of 20
class M { public static void main(String[] s) { String s1 = new String("ABCDEFG"), s2 = new String("EFGHIJ"); String s3 = s1.substring(4,7), s4 = s2.substring(0,3); System.out.println((s3 == s4) + "," + (s3 + s4).equals(s4 + s3)); }
} What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above 5.0/ 5.0 Points Question 18 of 20
class B { public static void main (String args[]) { Long i1 = new Long(1); Long i2 = new Long(i1); System.out.print((i1==i2) + "," + i1.equals(i2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true
E. Compile-time error F. Run-time error G. None of the above 5.0/ 5.0 Points Question 19 of 20
class A { public static void main (String args[]) { Integer i1 = new Integer(1); Integer i2 = new Integer(i1); System.out.print(i1.equals(i2)); } } What is the result of attempting to compile and run the program?
A. Prints: false B. Prints: true C. Compile-time error D. Run-time error E. None of the above 5.0/ 5.0 Points Question 20 of 20
class B { public static void main (String args[]) { Long i1 = new Long(1); Long i2 = new Long(i1); System.out.print((i1==i2) + "," + i1.equals(i2)); }
} What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above
05_BTJB_Quiz4_Database Progr amming wit h JDBC Returnto AssessmentList
Part 1 of 1 -
100.0/ 100.0 Points
5.0/ 5.0 Points Question 1 of 20
What statements are correct about batched insert and updates? (2 correct answers)
A.To execute a batched update/insert, you call the executeBatch() method on a Statement object
B.Batch insert and updates are only possible when making use of parameterized queries.
C.To do a batched update/insert, you call addBatch(String statement) on a Statement object for each statement you want to execute in the batch
D.To create a batch of insert and update statements, you create an o bject of type Batch, and call the method addStatement(String statement) for each statement you want to execute in the batch
5.0/ 5.0 Points Question 2 of 20
The different types of JDBC driver are
A.Native-API, pure Java driver
B.Native-API, partly Java driver
C.Jdbc-net, pure Java driver
D.Jdbc-odbc bridge, plus odbc driver
5.0/ 5.0 Points Question 3 of 20
Which of the following methods are needed for loading a database driver in JDBC
A. getConnection()
B. Class.forName()
C. registerDriver() method
D. Both A and B
5.0/ 5.0 Points Question 4 of 20
What happens if you call the method close() on a ResultSet object
A. The database and JDBC resources are released
B. You will get a SQLException, because only Statement objects can close ResultSets
C. The method close() does not exist for a ResultSet. Only Connections can be closed.
D. The ResultSet, together with the Statement which created it and the Connection from which the Statement was retrieved, will be closed and release all database and JDBC resources
5.0/ 5.0 Points Question 5 of 20
Which java.sql class or interface contains methods that enable you to find out the number of columns this is returned in a ResultSet and the name or label for a given column? ?
A. Statement
B. MetaData
C. CallableStatement
D. ResultSetMetaData
5.0/ 5.0 Points Question 6 of 20
Which of the following describes a JDBC type 4 driver?
A. Native-protocol pure Java driver
B. JDBC-Net pure Java driver
C. Native-API partly Java driver
D. JDBC-ODBC bridge plus ODBC driver
5.0/ 5.0 Points Question 7 of 20
What is the meaning of ResultSet.TYPE_SCROLL_INSENSITIVE
A. This means that the ResultSet is sensitive to scrolling, but insensitive to changes made by others
B. The meaning depends on the type of data source, and the type and version of the driver you use with this data source
C. This means that the Resultset is se nsitive to scrolling, but insensitive to updates, i.e. not updateable
D. This means that the ResultSet is insensitive to scrolling
5.0/ 5.0 Points Question 8 of 20
Which method is used to perform DML statements in JDBC
A. executeQuery()
B. executeUpdate()
C. executeResult()
D. execute()
5.0/ 5.0 Points Question 9 of 20
Are prepared statements actually compiled
A. Yes, they compiled
B. No, they are bound by the JDB C driver
5.0/ 5.0 Points Question 10 of 20
All raw data types (including binary documents or images) should be read and uploaded to the database as an array of
A. Char
B. int
C. byte
D. Boolean
5.0/ 5.0 Points Question 11 of 20
How do you know in your Java program that a SQL warning is generated as a result of executing a SQL statement in the database
A. You must catch the checked SQLException which is thrown by the method which executes the statement
B. You must catch the unchecked SQLWarningException which is t hrown by the method which executes the statement
C. You must invoke the getWarnings() method on the S tatement object (or a sub interface thereof)
D. You must query the ResultSet objec t about possible warnings generated by the database
5.0/ 5.0 Points Question 12 of 20
You need a ____ to access a database from a Java program. ?
A. Servlet
B. JDBC
C. ResultSet
D. Connection
5.0/ 5.0 Points Question 13 of 20
What is the meaning of the transaction isolation level TRANSACTION_REPEATABLE_READ
A. Dirty reads are prevented; non-repeatable reads and phantom reads can occur
B. Dirty reads, non-repeatable reads and phantom reads can occur
C. Dirty reads and non-repeatable reads are prevented; phantom reads can occur
D. Dirty reads, non-repeatable reads and phantom reads are prevented
5.0/ 5.0 Points Question 14 of 20
What statements are correct about JDBC transactions (2 correct answers)?
A.A transaction is finished when commit() or rollback() is called on the Connection object,
B.A transaction is finished when commit() or rollback() is called on the Transaction object
C.A transaction is finished when close() is called on the Connection object
D.A transaction is a set of successfully executed statements in the database
5.0/ 5.0 Points Question 15 of 20
The JDBC-ODBC Bridge supports multiple concurrent open statements per connection
A. No B. Yes 5.0/ 5.0 Points Question 16 of 20
"Which of the following will get the data from the first column of ResultSet rs, returned from executing the following SQL statement: SELECT name, rank, serialNo FROM employee;"
A.rs.getString(0)
B.rs.getString(“name”)
C.rs.getString(1)
5.0/ 5.0 Points Question 17 of 20
Which of the following statements will delete all re cords from the Invoices table that have a v alue of 0 in the InvoiceTotal field? String query = ""DELETE FROM Invoices "" + ""WHERE InvoiceTotal = 0 ""; Statement statement = connection.createStatement();
A. statement.deleteRows(query);
B. statement.executeQuery(query);
C. statement.executeUpdate(query);
D. statement.delete(query);
5.0/ 5.0 Points Question 18 of 20
How many transaction isolation levels are defined in java.sql.Connection interface
A. 2
B. 3
C. 4
D. 5
5.0/ 5.0 Points Question 19 of 20
Conn = Driver Manager.getConnection(“jdbc:odbc:Employee”,“”,“”); What does the above statement do?
A. Gets a database connection with the Employee data source.
B. Gets connectioned to the employee database.
C. Inidicates that jdbc is to be used in the application.
D. Retrieves data from the employee table.
5.0/ 5.0 Points Question 20 of 20
How can you execute DML statements (i.e. insert, delete, update) in the database
A. By making use of the InsertStatement, DeleteStatement or UpdateStatement classes
B. By invoking the executeInsert(...), executeDelete(...) or execute Update(...) methods of the DataModificationStatement object
C. By making use of the execute(...) statement of the DataModificationStatement object
D. By invoking the execute(...) or executeUpdate(...) method of a normal St atement object or a sub-interface object thereof
05_BTJB_Quiz5_Database Progr amming wit h Hibernate Returnto AssessmentList
Part 1 of 1 -
100.0/ 100.0 Points
5.0/ 5.0 Points Question 1 of 20
"Is this configuration correct in hibernate? "
A. None of the above
B. No
C. Yes
5.0/ 5.0 Points Question 2 of 20
What does session.createCriteria().uniqueResult() return?
A. String
B. HibernateResultSet
C. Object
D. ResultSet
5.0/ 5.0 Points Question 3 of 20
Which interface are not the core interfaces of Hibernate framework?
A. User Interface
B. Query and Criteria interfaces
C. Session interface
D. Configuration interface
E. SessionFactory interface
5.0/ 5.0 Points Question 4 of 20
What is true for session.get() method?
A. Will return null if there is no data in db or cache.
B. None of the above
C. Will throw exception if there is no data in db or cache
D. May return a lazily initiliazed proxy
5.0/ 5.0 Points Question 5 of 20
Hibernate configuration is managed by
A. org.hibernate.cfg.Configuration
B. org.hibernate.SessionFactory
C. org.hibernate.Session
D. org.hibernate.Transaction
5.0/ 5.0 Points Question 6 of 20
What happens when both hibernate.properties and hibernate.cfg.xml are in the classpath?
A. The settings of the properties file will override the settings used in the XML configuration
B. DuplicateConfigurationException
C. The settings of the XML configuration file will override the settings used in the properties
D. None
5.0/ 5.0 Points Question 7 of 20
To obtain a SessionFactory with custom config file, we can use the following :
A. new Configuration("mycfg.cfg.xml").buildSessionFactory()
B. new Configuration("mycfg.cfg").buildSessionFactory()
C. new Configuration().configure("myfile.cfg.xml").buildSessionFactory()
D. new Configuration().configure().buildSessionFactory()
5.0/ 5.0 Points Question 8 of 20
hibernate.cfg.xml is used for
A. Contains the configuration like database details
B. Is a generated file at runtime
C. Building the mapping between class and table
D. No such file is required for hibernate
5.0/ 5.0 Points Question 9 of 20
An object emp can be saved to database using method save(emp) of following :
A. Session
B. Transaction
C. Configuration
D. SessionFactory
5.0/ 5.0 Points Question 10 of 20
Which of the following is not a Session method? Select ONE
A. Session.saveorupdate()
B. Session.load()
C. Session.persist()
D. Session.remove()
E. Session.save()
5.0/ 5.0 Points Question 11 of 20
What is the root level element in a hibernate mapping file?
A.
B.
C.
D. None of the above
5.0/ 5.0 Points Question 12 of 20
Which property are used to configure diver class in hibernate?
A.hibernate.connection.driver_class
B.hibernate.connection.datasource
C.getParameterValues("name");
D.getParameters("name");
5.0/ 5.0 Points Question 13 of 20
How do you map Java Objects with Database table?
A. Anotation
B. Both
C. XML mapping hbm.xml
5.0/ 5.0 Points Question 14 of 20
Hibernate Query Language
A. Is native SQL
B. Is naming query language
C. Uses class name instead of table name, and property names instead of column name
D. Is JPA Query language
5.0/ 5.0 Points Question 15 of 20
Choose incorrect sentence
A. All communication with a database has to occur inside a transaction
B. Transaction should and either with a commit or a rollback
C. Transaction cannot rollback
D. Transaction is a set of database operations which must be executed in entirely or not at all
5.0/ 5.0 Points Question 16 of 20
Mapping Java classes to database tables is accomplished through the configuration file
A. Properties
B. Html
C. Xhtml
D. Xml
5.0/ 5.0 Points Question 17 of 20
Which of the following are most common configuration methods of Hibernate Configuation?
A. persistence.xml
B. http.conf
C. hibernate.cfg.xml
5.0/ 5.0 Points Question 18 of 20
Which of following is NOT a property in hibernate.cfg.xml file?
A. connection.username
B. oracle_dialect
C. None of above
D. connection.url
5.0/ 5.0 Points Question 19 of 20
Java type ‘String’ is mapped to following SQL type in hibernate :
A. VARCHAR
B. CHAR
C. CLOB
D. VARBINARY
5.0/ 5.0 Points Question 20 of 20
How can get a session object ?
A. SessionFactory.openSession();
B. SessionFactory.get();
C. SessionFactory.getObject();
D. SessionFactory.getSession();
05_BTJB_Quiz6_Loggi ng & Auto mation Uni t Test Returnto AssessmentList
Part 1 of 2 - Part 1
70.0/ 70.0 Points
5.0/ 5.0 Points Question 1 of 20
Which of the following genres does Log4j produce?
A. Logging Tool B. Gospel music C. Avant-rock D. Action game 5.0/ 5.0 Points Question 2 of 20
Which action is not a logging implement action?
A. Define logger B. Define log schedule C. Define appender
D. Define log message 5.0/ 5.0 Points Question 3 of 20
Which is(are) the message level will be logge d with the logger level "info"?
A. info, debug, warn B. info, trace, debug, warn C. info, error, fatal, warn D. info, debug, warn, fatal 5.0/ 5.0 Points Question 4 of 20
Which config section define the format of log message?
A. display section B. format section C. output section D. layout section 5.0/ 5.0 Points Question 5 of 20
The most generic logger is
A. floor B. root C. base
D. ceil 5.0/ 5.0 Points Question 6 of 20
What part of log4J config file defines t he level of log message
A. log level B. logger C. log message level D. message level 5.0/ 5.0 Points Question 7 of 20
The rolling output file type is an output file of which the content is
A. replaced at each running of the logged target B. put in a history file when the file size attends a predefined size C. replaced after a predefined period of time 5.0/ 5.0 Points Question 8 of 20
What is a log4j logger used for?
A. To define which log message will be c aught
B. To logs a log message
C. To receive the log message
5.0/ 5.0 Points Question 9 of 20
A logger cannot be defined for
A. A package
B. A method
C. A class
D. A project
5.0/ 5.0 Points Question 10 of 20
Which of the following platforms does Log4j run on?
A. Cross-platform B. Windows Server 2008 C. Debian 5.0/ 5.0 Points Question 11 of 20
What is a log4j logger?
A. A log output file
B. A configuration section C. Java class that logs a log message 5.0/ 5.0 Points Question 12 of 20
Which is syntax used to log a message?
A. message.log(); B. logger.message("log message"); C. logger.message(loglevel, "log message"); D. logger.info("log message"); 5.0/ 5.0 Points Question 13 of 20
The logger declaration order is
A. from most specific case to generic case
B. No order at all C. from most generic case to specific case 5.0/ 5.0 Points Question 14 of 20
What part of log4J config file defines t he log message output
A. output file B. appender
C. log message file D. output Part 2 of 2 - Part 2
30.0/ 30.0 Points
5.0/ 5.0 Points Question 15 of 20
How to ignore the debugging until the next check point with Eclipse debug function
A. Use step return function
B. Use continue debugging function
C. Use step over function
5.0/ 5.0 Points Question 16 of 20
How to run the debugging statement by statement with Eclipse debug function
A. Use step over function
B. Use step return function
C. Use step into function
5.0/ 5.0 Points Question 17 of 20
How to ignore the rest of debugging with Eclipse debug function
A. Use step return function
B. Use continue debugging function
C. Use stop debugging function
5.0/ 5.0 Points Question 18 of 20
How to ignore the rest of debugging of a method with Eclipse debug function
A. Use continue debugging function
B. Use step return function
C. Use step over function
5.0/ 5.0 Points Question 19 of 20
How to pause the debugging at a statement in Eclipse debug function
A. Use pause line function
B. Use break point function
C. Use pause statement function
5.0/ 5.0 Points Question 20 of 20
How to bypass a method in the debugging with Eclipse debug function
A. Use step over function
B. Use step into function
C. Use step return function
05_BTJB_Quiz6_Loggi ng & Auto mation Uni t Test Returnto AssessmentList
Part 1 of 2 - Part 1
Question 1 of 20
70.0/ 70.0 Points 5.0/ 5.0 Points
The most generic logger is A. ceil B. root C. base D. floor Question 2 of 20
Which config section define the format of log message?
5.0/ 5.0 Points
A. format section B. display section C. output section D. layout section Question 3 of 20
5.0/ 5.0 Points
Which of the following genres does Log4j produce? A. Action game B. Avant-rock C. Gospel music D. Logging Tool Question 4 of 20
5.0/ 5.0 Points
What part of log4J config file defines the log message output A. appender B. output C. log message file D. output file Question 5 of 20
5.0/ 5.0 Points
Which action is not a logging implement action? A. Define log message B. Define log schedule C. Define appender D. Define logger Question 6 of 20
What part of log4J config file defines the level of log message
5.0/ 5.0 Points
A. logger B. message level C. log message level D. log level Question 7 of 20
5.0/ 5.0 Points
The logger declaration order is A. No order at all B. from most generic case to specific case C. from most specific case to generic case
Question 8 of 20
5.0/ 5.0 Points
What is a log4j logger used for? A. To receive the log message B. To define which log message will be caught C. To logs a log message
Question 9 of 20
5.0/ 5.0 Points
What is a log4j logger? A. Java class that logs a log message B. A log output file C. A configuration section Question 10 of 20
Which is syntax used to log a message? A. logger.message(loglevel, "log message");
5.0/ 5.0 Points
B. message.log(); C. logger.message("log message"); D. logger.info("log message"); Question 11 of 20
5.0/ 5.0 Points
A logger cannot be defined for A. A class B. A project C. A package D. A method
Question 12 of 20
5.0/ 5.0 Points
Which of the following platforms does Log4j run on? A. Windows Server 2008 B. Debian C. Cross-platform Question 13 of 20
5.0/ 5.0 Points
The rolling output file type is an output file of which the content is A. replaced after a predefined period of time B. replaced at each running of the logged target C. put in a history file when the file size attends a predefined size Question 14 of 20
Which is(are) the message level will be logged with the logger level "info"? A. info, debug, warn, fatal
5.0/ 5.0 Points
B. info, debug, warn C. info, error, fatal, warn D. info, trace, debug, warn Part 2 of 2 - Part 2
Question 15 of 20
30.0/ 30.0 Points 5.0/ 5.0 Points
How to bypass a method in the debugging with Eclipse debug function A. Use step over function B. Use step return function C. Use step into function
Question 16 of 20
5.0/ 5.0 Points
How to ignore the debugging until the next check point with Eclipse debug function A. Use continue debugging function B. Use step return function C. Use step over function
Question 17 of 20
How to ignore the rest of debugging with Eclipse debug function A. Use step return function B. Use stop debugging function function C. Use continue debugging function
5.0/ 5.0 Points
Question 18 of 20
5.0/ 5.0 Points
How to pause the debugging at a statement in Eclipse debug function A. Use pause line function B. Use break point function C. Use pause statement function
Question 19 of 20
5.0/ 5.0 Points
How to run the debugging statement by statement with Eclipse debug function A. Use step over function B. Use step into function C. Use step return function
Question 20 of 20
How to ignore the rest of debugging of a method with Eclipse debug function A. Use continue debugging function B. Use step return function C. Use step over function
05_BTJB_Quiz5_ 05_ BTJB_Quiz5_Data Database base Progr amming wit h Hibernate Returnto AssessmentList
5.0/ 5.0 Points
Part 1 of 1 -
Question 1 of 20
100.0/ 100.0 Points 5.0/ 5.0 Points
Which of the following is a tag NOT used in hibernate.cfg.xml ? A. B. C. D.
Question 2 of 20
5.0/ 5.0 Points
Once hibernate creates a table for an Object we cannot add a property to the class for saving again A. Always True B. True if property size is small C. Always False D. None of above
Question 3 of 20
Hibernate configuration is managed by A. org.hibernate.SessionFactory org.hibernate.SessionFactory B. org.hibernate.cfg.Configurat org.hibernate.cfg.Configuration ion C. org.hibernate.Session org.hibernate.Session
5.0/ 5.0 Points
D. org.hibernate.Transaction
Question 4 of 20
5.0/ 5.0 Points
The tag is used for : A. Generating column automatically B. Generating table automatically C. Mapping property to column in table D. Generating primary key values
Question 5 of 20
5.0/ 5.0 Points
How can get a session object ? A. SessionFactory.getObject(); B. SessionFactory.getSession(); C. SessionFactory.get(); D. SessionFactory.openSession();
Question 6 of 20
How to begin a unit of work and return the associated Transaction object A. Session.beginTransaction() B. SessionFactory.beginTransaction() C. Session.openTransaction()
5.0/ 5.0 Points
D. SessionFactory.openTransaction()
Question 7 of 20
5.0/ 5.0 Points
Which annotation is used to achieve optimistic locking in hibernate? A. @Version B. @V C. @Lock D. @Release
Question 8 of 20
5.0/ 5.0 Points
Load child object automatically when parent object is loaded? A. lazy=yes B. lazy=no C. lazy=true D. lazy=fasle
Question 9 of 20
What are the main advantages of ORM like hibernate? A.Support for Query Language B.Mapping Java class to table C.Support multi databases
5.0/ 5.0 Points
D.Steep learning curve
Question 10 of 20
5.0/ 5.0 Points
When several entities points to the target entity, that is achieved by? A. @OneToOne B. @ManyToMany C. @ManyToOne
Question 11 of 20
5.0/ 5.0 Points
What does session.createCriteria().uniqueResult() return? A. ResultSet B. HibernateResultSet C. Object D. String
Question 12 of 20
Which of following is NOT a property in hibernate.cfg.xml file? A. oracle_dialect B. connection.url C. connection.username D. None of above
5.0/ 5.0 Points
Question 13 of 20
5.0/ 5.0 Points
How do you map Java Objects with Database table? A. Anotation B. XML mapping hbm.xml C. Both
Question 14 of 20
5.0/ 5.0 Points
Which of the following is not a Session method? Select ONE A. Session.load() B. Session.persist() C. Session.saveorupdate() D. Session.remove() E. Session.save()
Question 15 of 20
5.0/ 5.0 Points
Choose incorrect sentence A. All communication with a database has to occur inside a transaction B. Transaction cannot rollback C. Transaction is a set of database operations which must be executed in entirely or not at all
D. Transaction should and either with a commit or a rollback
Question 16 of 20
5.0/ 5.0 Points
To obtain a SessionFactory with custom config file, we can use the following : A. new Configuration("mycfg.cfg.xml").buildSessionFactory() B. new Configuration("mycfg.cfg").buildSessionFactory() C. new Configuration().configure().buildSessionFactory() D. new Configuration().configure("myfile.cfg.xml").buildSessionFactory()
Question 17 of 20
5.0/ 5.0 Points
What does hibernate.hbm2ddl.auto create this means? A. Create tables automatically B. Create SessionFactory object automatically C. None D. Create session object automatically
Question 18 of 20
5.0/ 5.0 Points
If the property of a class should not take part in persistence mechanism than the property should be marked as A. @Transient B. @Lob
C. @Temporary D. @Enum
Question 19 of 20
5.0/ 5.0 Points
Which of following is NOT an annotation used with a class in hibernate? A. @Entity B. @Column C. @Table
D. None of the above
Question 20 of 20
What was Hibernate written in? A. Ruby B. C C. Java D. Assembly language
05_BTJB_Quiz4_ 05_ BTJB_Quiz4_Data Database base Progr amming wit h JDBC Returnto AssessmentList
5.0/ 5.0 Points
Part 1 of 1 -
100.0/ 100.0 Points
Question 1 of 20
5.0/ 5.0 Points
Which of the following is NOT a way to insert data into a table? A. a configuration configuration file B. a LOAD command C. a SQL script D. an INSERT statement
Question 2 of 20
5.0/ 5.0 Points
A __________ object contains information information about a result set like the numbers and names of the columns in the result set. ? A. ResultSetMetaData B. prepared statements C. OR mapping (object to relational) D. connection pooling
Question 3 of 20
5.0/ 5.0 Points
What statements are correct about JDBC transactions (2 correct answers)? A.A transaction is finished when commit() or rollback() is called on the Connection object, B.A transaction is a set of successfully executed statements statements in the database
C.A transaction is finished when commit() or rollback() is called on the Transaction object D.A transaction is finished when close() is called on the Connection object
Question 4 of 20
5.0/ 5.0 Points
How is the forName() method of the "Class" class used with JDBC? A. To execute a SQL statementresses B. To load a result set C. To establish a database connection D. To load a JDBC driver
Question 5 of 20
5.0/ 5.0 Points
What happens if you call deleteRow() on a ResultSet object A. The row you are positioned on is deleted from the ResultSet, but not from the database. B. You will get a compile error: the method does not exist because you can not delete rows from a ResultSet C. The result depends on whether the property synchronizeWithDataSource is set to true or false D. The row you are positioned on is deleted from the ResultSet and from the database
Question 6 of 20
5.0/ 5.0 Points
When you code an inner join in a SELECT SE LECT statement you do not need to specify ?
A. a join column for the first table B. the name of the second table C. an ORDER BY clause D. a join column for the second table
Question 7 of 20
5.0/ 5.0 Points
Which packages contain the JDBC classes A. java.sql and javax.sql B. java.jdbc and java.jdbc.sql C. java.jdbc and javax.jdbc D. java.rdb and javax.rdb
Question 8 of 20
5.0/ 5.0 Points
What is, in terms of JDBC, a DataSource A. A DataSource is the basic service for managing a set of JDBC drivers B. A DataSource is a factory of connections to a physical data source C. A DataSource is a registry point for JNDI-services D. A DataSource is the Java representation of a physical data source
Question 9 of 20
5.0/ 5.0 Points
Conn = Driver Manager.getConnection(“jdbc:odbc:Employee”,“”,“”);
What does the above statement do? A. Inidicates that jdbc is to be used in the application. B. Gets a database connection with the Employee data source. C. Gets connectioned to the employee database. D. Retrieves data from the employee table.
Question 10 of 20
5.0/ 5.0 Points
When the message “No Suitable Driver” occurs
A. When the user name, password and the database does not match B. When the type 4 driver is used C. When the driver is not registered by Class.forname() method D. When the JDBC database URL passed is not constructed properly
Question 11 of 20
5.0/ 5.0 Points
The _______ class is traditional management layer of JDBC, working between the user and the drivers A. Resultset B. Connection C. DriverManager
Question 12 of 20
5.0/ 5.0 Points
Which character is used to represent an input parameter in a CallableStatement? A. ? B. # C. % D. *
Question 13 of 20
5.0/ 5.0 Points
To improve the performance of database operations, an application can use _________ where a limited number of connections are opened and are shared by users of the database. ? A. ResultSetMetaData B. init C. connection pooling D. OR mapping (object to relational)
Question 14 of 20
Which method is used to perform DML statements in JDBC A. execute() B. executeUpdate() C. executeResult() D. executeQuery()
5.0/ 5.0 Points
Question 15 of 20
5.0/ 5.0 Points
Which of the following methods are needed for loading a database driver in JDBC A. getConnection() B. Class.forName() C. registerDriver() method D. Both A and B
Question 16 of 20
5.0/ 5.0 Points
The methods of what type of object can be used to move the cursor through a result set? ? A. Connection B. ResultSet C. URL D. Statement
Question 17 of 20
Which of following interface isn’t used by JDBC
A. java.sql.DriverManager B. java.sql.DatabaseMetaData C. java.sql.Connection D. java.sql.Driver
5.0/ 5.0 Points
Question 18 of 20
5.0/ 5.0 Points
The column index of ResultSet object is numbered from _________ A. No B. Yes Question 19 of 20
5.0/ 5.0 Points
The class java.sql.Timestamp has its super class as A. java.sql.Time B. java.util.Date C. java.util.Time D. None of the above
Question 20 of 20
5.0/ 5.0 Points
Before your application can create a Connection object, it must use the forName method of the Class class to load ? A. an ODBC data source B. a DBMS C. JDBC D. a database driver
05_BTJB_Quiz3_Exception Handli ng & Util ity Class es Returnto AssessmentList
Part 1 of 1 -
Question 1 of 20
100.0/ 100.0 Points 5.0/ 5.0 Points
Which implementation of the List interface produces the slowest access to an element in the middle of the list by means of an index? A. Vector B. LinkedList C. None of the above D. ArrayList Question 2 of 20
5.0/ 5.0 Points
class B { public static void main (String args[]) { Long i1 = new Long(1); Long i2 = new Long(i1); System.out.print((i1==i2) + "," + i1.equals(i2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Question 3 of 20
5.0/ 5.0 Points
• Stores key/value pairs. • Duplicate entries replace old entries. • Entries are sorted using a Comparator or the Comparable interface.
Which of these classes provides the specified features? A. LinkedList B. TreeMap C. TreeSet D. HashMap E. HashSet F. Hashtable G. None of the above Question 4 of 20
5.0/ 5.0 Points
• Entries are organized as key/value pairs. • Duplicate entries replace old entries.
Which interface of the java.util package offers the specified behavior? A. List B. Map C. Set D. None of the above Question 5 of 20
5.0/ 5.0 Points
• Entries are not organized as key/value pairs. • Duplicate entries are rejected.
Which interface of the java.util package offers the specified behavior? A. List B. Map C. Set D. None of the above Question 6 of 20
5.0/ 5.0 Points
class M { public static void main(String[] s) { String s1 = "1", s2 = "2", s3 = s1 + s2; s1 += s2; s3 += s1; System.out.println(s3); } } What is the result of attempting to compile and run the program?
A. Prints: 3 B. Prints: 6 C. Prints: 33 D. Prints: 1212 E. Compile-time error F. Run-time error G. None of the above Question 7 of 20
class M { public static void main (String[] args) { String s1 = "ABC"; StringBuffer s2 = new StringBuffer(s1); System.out.print(s2.equals(s1) + "," + s1.equals(s2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true
5.0/ 5.0 Points
E. Compile-time error F. Run-time error G. None of the above Question 8 of 20
5.0/ 5.0 Points
class ColorException extends Exception {} class WhiteException extends ColorException {} class White { void m1() throws ColorException {throw new WhiteException();} void m2() throws WhiteException {} public static void main (String[] args) { White white = new White(); int a,b,d,f; a = b = d = f = 0; try {white.m1(); a++;} catch (ColorException e) {b++;} try {white.m2(); d++;} catch (WhiteException e) {f++;} System.out.print(a+","+b+","+d+","+f); } } What is the result of attempting to compile and run the program?
A. Prints: 0,1,0,0 B. Prints: 1,1,0,0 C. Prints: 0,1,1,0 D. Prints: 1,1,1,0 E. Prints: 1,1,1,1 F. Compile-time error G. Run-time error H. None of the above Question 9 of 20
5.0/ 5.0 Points
• Each element must be unique. • Contains no duplicate elements. • Elements are not key/value pairs. • Accessing an element can be almost as fast as performing a similar operation on an array.
Which of these classes provides the specified features?
A. LinkedList B. TreeMap C. TreeSet D. HashMap E. HashSet F. LinkedHashMap G. Hashtable H. None of the above Question 10 of 20
5.0/ 5.0 Points
class M { public static void main(String[] args) { String s1 = "A", s2 = "a", s3 = "b"; s1.toLowerCase(); s3.replace('b','a'); System.out.print((s1.equals(s2)) + "," + (s2.equals(s3))); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Question 11 of 20
5.0/ 5.0 Points
Which implementation of the List interface provides for the fastest insertion of a new element into the middle of the list?
A. Vector B. ArrayList C. LinkedList D. None of the above Question 12 of 20
5.0/ 5.0 Points
class A { public static void main (String[] args) { Error error = new Error(); Exception exception = new Exception(); System.out.print((exception instanceof Throwable) + ","); System.out.print(error instanceof Throwable); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error G. None of the above Question 13 of 20
class M { static void m1(StringBuffer s1) { s1 = s1.append("B"); System.out.print(s1); } static void m2(StringBuffer s1) { s1.append("C"); System.out.print(s1); }
5.0/ 5.0 Points
public static void main(String[] s) { StringBuffer s1 = new StringBuffer("A"); m1(s1); m2(s1); System.out.print(s1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABAA C. Prints: ABACA D. Prints: ABABAB E. Prints: ABABCAB F. Prints: ABABCABC G. Prints: ABCABCABC H. Compile-time error I. Run-time error J. None of the above Question 14 of 20
class M { public static void main(String[] s) { String s1 = "A", s2 = " B ", s3 = "C"; s2.trim(); s3.concat("D"); System.out.print(s1 + s2 + s3); } } What is the result of attempting to compile and run the program?
A. Prints: ABC B. Prints: A B C
5.0/ 5.0 Points
C. Prints: ABCD D. Prints: ABDC E. Prints: A B CD F. Prints: A B DC G. Compile-time error H. Run-time error I. None of the above Question 15 of 20
5.0/ 5.0 Points
class B { public static void main (String args[]) { Byte b1 = new Byte(1); // 1 Byte b2 = new Byte('2'); // 2 Byte b3 = new Byte("3"); // 3 byte i1 = b1.byteValue()+b2.byteValue()+b3.byteValue(); // 4 System.out.print(i1); } } What is the result of attempting to compile and run the program? (Multi choice)
A.Compile-time error at 2 B.Run-time error C.Compile-time error at 3 D.Prints: 6 E.Compile-time error at 4 F.Compile-time error at 1 Question 16 of 20
class H { public static void main (String[] args) { int i1, i2; Integer i3, i4; i1=new Integer(Integer.parseInt("1")).intValue(); // 1
5.0/ 5.0 Points
i3=new Integer(Integer.parseInt("1")).intValue(); // 2 i2=Integer.parseInt(Integer.valueOf("1").toString()); // 3 i4=Integer.parseInt(Integer.valueOf("1").intValue()); // 4 } } What is the result of attempting to compile and run the program? (Multi choice)
A.Compile-time error at 3. B.Compile-time error C.Compile-time error at 4. D.Compile-time error at 2. E.Compile-time error at 1. F.Run-time error Question 17 of 20
class G { public static void main (String[] args) { Integer i1 = new Integer("1"), i2 = new Integer("1"); StringBuffer sb1 = new StringBuffer("1"); StringBuffer sb2 = new StringBuffer("1"); System.out.print(sb1.equals(sb2)+","+i1.equals(i2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error F. Run-time error
5.0/ 5.0 Points
G. None of the above Question 18 of 20
5.0/ 5.0 Points
• Stores key/value pairs. • Allows null elements, keys, and values. • Duplicate entries replace old entries. • Entries are not sorted.
Which of these classes provides the specified features? A. LinkedList B. TreeMap C. TreeSet D. HashMap E. HashSet F. Hashtable G. None of the above Question 19 of 20
class M { public static void main (String[] args) { String s1 = "ABC"; StringBuffer s2 = new StringBuffer(s1); System.out.print(s2.equals(s1) + "," + s1.equals(s2)); } } What is the result of attempting to compile and run the program?
A. Prints: false,false B. Prints: false,true C. Prints: true,false D. Prints: true,true E. Compile-time error
5.0/ 5.0 Points
F. Run-time error G. None of the above Question 20 of 20
5.0/ 5.0 Points
class D { public static void main (String[] args) { Boolean b1 = new Boolean("trUE"); // 1 Boolean b2 = new Boolean("What's This?"); // 2 Boolean b3 = new Boolean(null); // 3 System.out.print(b1 + "," + b2 + "," + b3); } } What is the result of attempting to compile and run the program?
A. Prints: false,false,false B. Prints: false,false,true C. Prints: false,true,false D. Prints: false,true,true E. Prints: true,false,false F. Prints: true,false,true G. Prints: true,true,false H. Prints: true,true,true I. Compile-time error J. Run-time error K. None of the above 05_BTJB_Quiz2_Advanced OOP in Java Returnto AssessmentList
Part 1 of 1 -
91.25/ 100.0 Points
Question 1 of 20
5.0/ 5.0 Points
class G { int x; // 1 public static void main(String[] args) { // 2 int y = 0; // 3 System.out.print(x+","); // 4 System.out.print(y); // 5 } } What is the result of attempting to compile and run the program?
A. Prints: 0,0 B. Compile-time error at line 1. C. Compile-time error at line 1. D. Compile-time error at line 2. E. Compile-time error at line 3. F. Compile-time error at line 4. G. Compile-time error at line 5. H. Run-time error I. None of the above Question 2 of 20
class Red { public int a; public static int b; public static void main (String[] in) { Red r1 = new Red(), r2 = new Red(); r1.a++; r1.b++; System.out.print(r1.a+", "+r1.b+", "+r2.a+", "+r2.b); } } What is the result of attempting to compile and run the program?
5.0/ 5.0 Points
A. Prints: 0, 0, 0, 0 B. Prints: 0, 1, 1, 1 C. Prints: 1, 1, 1, 0 D. Prints: 1, 1, 0, 1 E. Prints: 1, 1, 0, 0 F. Prints: 1, 1, 1, 1 G. Compile-time error H. Run-time error I. None of the above Question 3 of 20
5.0/ 5.0 Points
class G { static String m(float i) {return "float";} static String m(double i) {return "double";} public static void main (String[] args) { int a1 = 1; long b1 = 2; System.out.print(m(a1)+","+ m(b1)); } } What is the result of attempting to compile and run the program?
A. Prints: float,float B. Prints: float,double C. Prints: double,float D. Prints: double,double E. Compile-time error F. Run-time error G. None of the above Question 4 of 20
5.0/ 5.0 Points
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A a1 = new A(); B b1 = new B(); C c1 = new C(); A c2 = new C(); c2.m1(a1); c2.m1(b1); c2.m1(c1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above Question 5 of 20
3.33/ 5.0 Points
public class Basics {} // 1 class Basics1 {} // 2 protected class Basics2 {} // 3 private class Basics3 {} // 4 Class Basics4 {} // 5 Suppose these are top-level class declarations and not nested class declarations; and suppose that all of the declarations are contained in one file named Basics.java. Compile-time errors are generated at which lines? (Multi choice) A.1 B.2 C.3 D.4 E.5
Question 6 of 20
5.0/ 5.0 Points
class Basics { int x = 1, y = 2; public static void main (String[] args) {System.out.println(x+y);} } What is the result of attempting to compile and run the program?
A. Prints: x+y B. Prints: 12 C. Prints: 3 D. Run-time error E. Compile-time error F. None of the above Question 7 of 20
5.0/ 5.0 Points
class G { static void m(Object x) {System.out.print("Object");} static void m(String x) {System.out.print("String");} public static void main(String[] args) {m(null);} } What is the result of attempting to compile and run the program?
A. Prints: Object B. Prints: String C. Compile-time error D. Run-time error E. None of the above Question 8 of 20
5.0/ 5.0 Points
Which of the following modifiers can be applied to the declaration of a field?(Multi choice)
A.abstract B.final C.private D.protected E.Public Question 9 of 20
2.5/ 5.0 Points
Which of the following modifiers can be applied to a constructor? (Multi choice) A.protected B.public C.static D.synchronized E.Transient Question 10 of 20
class G { static String m(int i) {return "int";} static String m(float i) {return "float";} public static void main (String[] args) { long a1 = 1; double b1 = 2; System.out.print(m(a1)+","+ m(b1)); } } What is the result of attempting to compile and run the program?
A. Prints: float,float B. Prints: float,double C. Prints: double,float D. Prints: double,double E. Compile-time error F. Run-time error
5.0/ 5.0 Points
G. None of the above Question 11 of 20
5.0/ 5.0 Points
class A { static int x; // 1 public static void main(String[] args) { // 2 int y; // 3 System.out.println("x="+x); // 4 System.out.println("y="+y); // 5 } } What is the result of attempting to compile and run the program?
A. Compile-time error at line 1. B. Compile-time error at line 2. C. Compile-time error at line 3. D. Compile-time error at line 4. E. Compile-time error at line 5. F. Run-time error G. None of the above Question 12 of 20
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A a1 = new A(); B b1 = new A(); C c1 = new A(); C c2 = new C(); c2.m1(a1); c2.m1(b1); c2.m1(c1); } } What is the result of attempting to compile and run the program?
5.0/ 5.0 Points
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above Question 13 of 20
5.0/ 5.0 Points
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D extends C { void m1(D d) {System.out.print("D");} public static void main(String[] args) { A a1 = new A(); B b1 = new B(); C c1 = new C(); D d1 = new D(); d1.m1(a1); d1.m1(b1); d1.m1(c1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: DDD D. Prints: ABCD E. Compile-time error F. Run-time error G. None of the above Question 14 of 20
Which of the following statements is true? A. An abstract method can not be overridden by an abstract method.
5.0/ 5.0 Points
B. An instance method that is not abstract can not be overridden by an abstract method. C. An abstract method declaration can not include a throws clause. D. The body of an abstract method is represented by a set of empty brackets. E. None of the above. Question 15 of 20
3.75/ 5.0 Points
Which of the following modifiers can be applied to the declaration of a field? (Multi choice) A.abstract B.final C.private D.protected E.Public Question 16 of 20
1.67/ 5.0 Points
Which of the following modifiers can be applied to a class that is not a nested class? (Multi choice) A.public B.protected C.private D.abstract E.static F.Final Question 17 of 20
class A {void m1(A a) {System.out.print("A");}} class B extends A {void m1(B b) {System.out.print("B");}} class C extends B {void m1(C c) {System.out.print("C");}} class D { public static void main(String[] args) { A a1 = new A(); A b1 = new B(); A c1 = new C(); C c4 = new C();
5.0/ 5.0 Points
a1.m1(c4); b1.m1(c4); c1.m1(c4); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: ABC C. Prints: CCC D. Compile-time error E. Run-time error F. None of the above Question 18 of 20
5.0/ 5.0 Points
Which of the following modifiers can not be applied to a method? A. abstract B. private C. protected D. public E. volatile F. None of the above. Question 19 of 20
5.0/ 5.0 Points
abstract class A {} // 1 transient class G {} // 2 private class C {} // 3 static class E {} // 4 Suppose these are top-level class declarations and not nested class declarations. Which of these declarations would not produce a compile-time error? A. 1 B. 2
C. 3 D. 4 E. None of the above Question 20 of 20
5.0/ 5.0 Points
Which of the following modifiers can be applied to a constructor? A. private B. abstract C. final D. volatile E. native F. None of the above.
05_BTJB_Quiz1_Java Basics &OOP in Java Returnto AssessmentList
Part 1 of 1 -
Question 1 of 20
100.0/ 100.0 Points 5.0/ 5.0 Points
class M { public static void main (String[] args) { // Insert code here. } } Which of the following lines can be inserted at the specified location without generating a compile-time error?
A. char a = a;
B. char b = abc; C. char c = \u0041; D. char d = \uabcd; E. None of the above Question 2 of 20
5.0/ 5.0 Points
class M { public static void main (String[] args) { // Insert code here. } } Which of the following lines can be inserted at the specified location without generating a compile-time error?
A. boolean b1 = true; B. boolean b2 = TRUE; C. boolean b3 = 'true'; D. boolean b4 = "TRUE"; E. boolean b5 = 0; F. None of the above Question 3 of 20
class E { static int m(int i) {System.out.print(i + ", "); return i;} public static void main(String s[]) { m(m(1) + m(2) % m(3) * m(4)); } } What is the result of attempting to compile and run the program?
A. Prints: 1, 2, 3, 4, 0,
5.0/ 5.0 Points
B. Prints: 1, 2, 3, 4, 3, C. Prints: 1, 2, 3, 4, 9, D. Prints: 1, 2, 3, 4, 12, E. Prints: 2, 3, 4, 1, 9, F. Prints: 2, 3, 4, 1, 3, G. Run-time error H. Compile-time error I. None of the above Question 4 of 20
5.0/ 5.0 Points
class G { static int m1(int x) {return ++x;} public static void main (String[] args) { int x = 1; int y = m1(x); System.out.println(x + "," + y); } } What is the result of attempting to compile and run the program?
A. Prints: 1,1 B. Prints: 1,2 C. Prints: 2,1 D. Prints: 2,2 E. Run-time error F. Compile-time error G. None of the above Question 5 of 20
class M { public static void main (String args[]) {
5.0/ 5.0 Points
char c = 'b'; switch(c) { case 'a': System.out.print("1"); case 'b': System.out.print("2"); case 'c': System.out.print("3"); default: System.out.print("4"); } } } What is the result of attempting to compile and run the program?
A. Prints: 3 B. Prints: 34 C. Prints: 234 D. Prints: 1234 E. Run-time error F. Compile-time error G. None of the above Question 6 of 20
5.0/ 5.0 Points
class M { public static void main (String[] args) { // Insert code here. } } Which of the following lines can be inserted at the specified location without generating a compile-time error?
A. String a = 'a'; B. String b = 'abc'; C. String c = '\u0041'; D. String d = '\uabcd';
E. None of the above Question 7 of 20
5.0/ 5.0 Points
class M { public static void main(String[] args) { int[][] a1 = {{1,2,3},{4,5,6},{7,8,9,10}}; System.out.print(a1[0][2]+","+a1[1][0]+","+a1[2][1]); } } What is the result of attempting to compile and run the program?
A. Prints: 3,4,8 B. Prints: 7,2,6 C. Compile-time error D. Run-time error E. None of the above Question 8 of 20
class E { static boolean a, b, c; public static void main (String[] args) { boolean x = a || (b = true) && (c = true); System.out.print(a + "," + b + "," + c); } } What is the result of attempting to compile and run the program?
A. Prints: true,true,false B. Prints: false,false,true C. Run-time error D. Prints: true,false,false
5.0/ 5.0 Points
E. Prints: true,true,true F. Prints: false,false,false G. Prints: false,true,false H. Prints: false,true,true I. Prints: true,false,true J. Compile-time error Question 9 of 20
5.0/ 5.0 Points
class M { public static void main(String args[]) { String a = "A", b = "B", c = a+b, d = a+b; System.out.print(((a+b)==(a+b)) + ","); System.out.print((c==d) + ","); System.out.print(c.equals(d)); } } What is the result of attempting to compile and run the program?
A. Prints: true,false,false B. Prints: false,false,false C. Prints: true,false,true D. Prints: false,true,false E. Prints: true,true,false F. Prints: false,false,true G. Prints: false,true,true H. Prints: true,true,true Question 10 of 20
class E { static boolean a, b, c; public static void main (String[] args) { boolean x = (a = true) || (b = true) && (c = true);
5.0/ 5.0 Points
System.out.print(a + "," + b + "," + c); } } What is the result of attempting to compile and run the program?
A. Prints: false,false,false B. Prints: false,false,true C. Prints: false,true,false D. Prints: false,true,true E. Prints: true,false,false F. Prints: true,false,false G. Prints: true,true,false H. Prints: true,true,true I. Run-time error J. Compile-time error Question 11 of 20
class M { public static void main (String[] args) { int j = 0; for (int i = 0; i < 2; i++) do System.out.print(i); while (j++ < 2); } } What is the result of attempting to compile and run the program?
A. Prints: 0001 B. Prints: 012 C. Prints: 012012 D. Prints: 012345
5.0/ 5.0 Points
E. Prints: 001122 F. Prints: 1112 G. Prints: 111222 H. Prints: 121212 I. Run-time error J. Compile-time error Question 12 of 20
5.0/ 5.0 Points
Which of these lists contains at least one word that is not a Java keyword? A. abstract, default, if, private, this B. do, implements, protected, boolean, throw C. case, extends, int, short, try D. import, break, double, exception, throws E. byte, else, instanceof, return, transient F. None of the above Question 13 of 20
class A { public static void main(String[] args) { boolean b = true; if (b = false) {System.out.print("A"); } else if (b) {System.out.print("B"); } else {System.out.print("C");} } } What is the result of attempting to compile and run the program?
A. Prints: A B. Prints: B C. Prints: C
5.0/ 5.0 Points
D. Run-time error E. Compile-time error F. None of the above Question 14 of 20
5.0/ 5.0 Points
class JMM122 { public static void main (String[] args) { for (int i = 0; i < 4; i++) { switch (i) { case 0: System.out.print("A"); case 1: System.out.print("B"); case 2: System.out.print("C"); } } } } What is the result of attempting to compile and run the program?
A. Prints: ABC B. Prints: ABCC C. Prints: CBA D. Prints: ABCBCC E. Run-time error F. Compile-time error G. None of the above Question 15 of 20
class A { public static void main(String[] args) { char a = 'a', b = 'b'; // 'a' = 97, 'b' = 98
5.0/ 5.0 Points
System.out.print(a + b + "" + a + b); } } What is the result of attempting to compile and run the program?
A. Prints: 390 B. Prints: 195195 C. Prints: 195ab D. Prints: ab195 E. Prints: abab F. Run-time error G. Compile-time error H. None of the above Question 16 of 20
5.0/ 5.0 Points
class M { public static void main (String[] args) { String s = null; System.out.print(s); } } What is the result of attempting to compile and run the program?
A. Prints nothing. B. Prints: null C. Compile-time error D. Run-time error E. None of the above Question 17 of 20
5.0/ 5.0 Points
class M { static void m1(String s1) { s1.replace('A','Y'); System.out.print(s1); } static void m2(String s1) { s1 = s1.replace('A','Z'); System.out.print(s1); } public static void main(String[] s) { String s1 = "A"; m1(s1); m2(s1); System.out.print(s1); } } What is the result of attempting to compile and run the program?
A. Prints: AAA B. Prints: YZA C. Prints: YAA D. Prints: AZA E. Compile-time error F. Run-time error G. None of the above Question 18 of 20
class A { public static void main(String args[]) { for (int i = 0; i<5 ;i++) { switch(i) { case 0: System.out.print("v ");break; case 1: System.out.print("w "); case 2: System.out.print("x ");break; case 3: System.out.print("y "); case 4: System.out.print("z ");break; default: System.out.print("d "); } }
5.0/ 5.0 Points
} } What is the result of attempting to compile and run the program?
A. Prints: v w x y z B. Prints: v w x y z d C. Prints: v w x x y z z D. Prints: v w w x y y z d E. Prints: d d d d d d F. Run-time error G. Compile-time error H. None of the above Question 19 of 20
class E { public static void main(String args[]) { int a = 1; a += ++a + a++; System.out.print(a); } } What is the result of attempting to compile and run the above program?
A. Prints: 3 B. Prints: 4 C. Prints: 5 D. Prints: 6 E. Prints: 7 F. Run-time error G. Compile-time error H. None of the above
5.0/ 5.0 Points