Java - Online Test - System - javasearch.buggybread.com


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'System' - 31 questions found


What is out in System.out.println ?Core Java
out is static inner class
out is the reference for static inner class object
out is the static reference to OutputStream object
out is the static reference to PrintStream object

  System.out.println

Semaphores are used to solve problem of ... Operating system
Race Condition
Process Synchronization
Mutual Exclusion
All of above

  Semaphore  Operating system

Which keyword is used to provide explicit access of a code block to single thread ?Core Java
Transient
Final
Explicit
Synchronized

  java  threads  multithreading

Which of the following class creates mutable objects ?Core Java
Boolean
File
String
StringBuffer

  java  immutable

Which of the following Java feature promotes access protection or Hiding ?Core Java
Inheritance
Encapsulation
Abstraction
Composition

  java  java concepts  java features  oops concepts  oops features  access protection  information hiding

Which of the following statement is not true ?Core Java
x==y means they are pointing to the same object
x==y means that they hold same information
x.equals(y) means they are pointing to the same object
x.equals(y) means that they hold same information

  

When String literals are compared using ==, they always returns true if the string values are same because .. Core Java
of overridden compareTo method
of overridden compare method
of String Pool
== means that the object contents are equal

  

Which of the following is true ?Core Java
Composition is Tightly Bound
Inheritance is Tightly Bound
Object can only hold reference of only one other object
A Class cannot be extended by multiple classes

  

In case of String Literals ..Core Java
x==y on all literals always returns false
x.equals(y) on all literals always returns false
if x.equals(y) returns true, x==y returns true too
if x.equals(y) returns false, x==y returns true

  

What will be the output of following ?

String str1 = new String("String1");
String str2 = new String("String1");
System.out.print(str1 == str2);
System.out.print(str1.equals(str2));
str1 = str2;
System.out.print(str1 == str2);
Core Java
falsetruetrue
truetruetrue
truetruefalse
falsetruefalse

  equals  object equality

What will be the output of following code ?

String str1 = "String1";
String str2 = "String1";
System.out.print(str1 == str2);
System.out.print(str1.equals(str2));
str1 = str2;
System.out.print(str1 == str2);
Core Java
falsetruetrue
falsefalsetrue
truetruetrue
falsefalsefalse

  equals  object equality  string pool

What will be the output of following code ?

String str1 = "String1";
String str2 = "String2";
str1.concat("String3");
System.out.print(str1);
System.out.print(str2);
Core Java
String1String2
String1String3String3
String1String3String1String3
String1String1

  

What will be the output of following code ?

String str1 = "String1";
String str2 = "String2";
str1=str1.concat("String3");
System.out.print(str1);
System.out.print(str2);
Core Java
String1String2
String1String3String2
String1String2String3
String1Stringg3String1

  

Which of the following is false ?Core Java
A Class cannot override both hashcode and equals method.
A class can override both hashcode and equals method.
A Class must override hashCode method if its overridding equal method.
A Class can override hashCode even if its not overridding equals method.

  hascode  equals method  overridding hashcode and equals method

With the following code, Which is a valid way to initialize ?
public class BuggyBread {

   private String element1;

   private String element2;

   private BuggyBread(String element1, String element2){
      this.element1 = element1;
      this.element2 = element2;
   }

   public static class Builder {
   
      private String element1;

      private String element2;

      Builder(BuggyBread buggybread){
         element1 = buggybread.element1;
         element2 = buggybread.element2;
      }

      Builder withElement1(String element1){
         this.element1 = element1;
         return this;
      }

      Builder withElement2(String element2){
         this.element2 = element2;
         return this;
      }

      BuggyBread build(){
         BuggyBread buggybread = new BuggyBread(element1,element2);
         return buggybread;
      }
   }
}
Core Java
BuggyBread buggybread = new BuggyBread();
BuggyBread buggybread = new BuggyBread("element1","element2");
BuggyBread.Builder builder = new BuggyBread.Builder();
BuggyBread.Builder builder = new BuggyBread.Builder("element1","element2");

  builder pattern

What will be the output of exceuting main method ?

public static void main(String[] args){
      List list = new ArrayList();
      list.add(1);
      list.add(2);
      list.add(3);
      System.out.println(list);
   }
Core Java
1,2,3
Order cannot be determined
compilation error
3,2,1

  collections  list  arraylist

What will be the output upon executing main method ?

public static void main(String[] args){
      Set set = new HashSet();
      set.add(1);
      set.add(2);
      set.add(3);
      System.out.println(set);
   }
Core Java
1,2,3
Order cannot be determined
Compilation error
3,2,1

  set  hashset  collections

What is Lazy Initialization in Hibernate ?Hibernate
Feature to load the dependencies from Cache
Feature to load all objects and relationships in advance before they can be used
Feature to not load dependencies and relationship in advance and load when required
Feature to not load the dependencies and relationships at all

  Lazy Initialization

Which of the following is not the benefit of Lazy Initialization in Hibernate ?Hibernate
Laod When required provides better performance
Object stays lighter
Less number of Database calls
Less load on Database

  Lazy Initialization  Lazy Fetching

What is the relationship between Vehicle and Engine in this example ?

public class Vehicle {
   Enginer engine;
   public void move(){
      engine = new Engine();
      engine.start();
   }
}
Core Java
Composition ( Vehicle has a Engine )
Composition ( Engine has a Vehicle )
Inheritance ( Vehicle is a Engine )
Inheritance ( Engine is a Vehicle )

  composition  inheritance  oops concepts

What is the relationship between Car and Vehicle in the following code ?

public class Car extends Vehicle{
   Engine engine;   
   
   public static void main(String[] args){
      Vehicle vehicle = new Car();
      car.move();
   }   

   public void move(){
      engine = new Engine();
      engine.start();
   }
}
Core Java
Composition ( Vehicle has a Car )
Composition ( Car has a Vehicle )
Inheritance ( Vehicle is a Car )
Inheritance ( Car is a Vehicle )

  Inheritance  Composition  Oops concepts

What is the problem with the following code ?

public class Car extends Vehicle{
   Vehicle vehicle;
   
   Car(){
      super();
      this.vehicle = new Vehicle();
   }
}
Core Java
There is an Inheritance as well as Composition relationship between Vehicle and Car which is not permitted
We cannot initialize the parent class instance within the constructor
Call to super is illegal
There is no problem

  Composition  Inheritance  OOPS concepts

Which of the following can be overridden ?Core Java
final instance methods
final static methods
non final instance methods
non final static methods

  overriding

Which of the following collections stores its elements in natural sorting order ?Core Java
HashMap
LinkedHashMap
TreeMap
EnumMap

  map  collections

What kind of thread is Garbage collection thread ?Core Java
Daemon Thread
User Thread
System Thread
Active Thread

  garbage collection  thread type

Which of following is Daemon Thread ?Core Java
Thread Scheduler
Daemon Thread
Both of above
None of above

  daemon thread   threads

Which of following is not the method of object class ?Core Java
run
notify
wait
clone

  object class

Which of following is not true ?XML
Dom Parser loads the whole doument at once in memory
A DOM Parser is much more memory efficient
Dom Parser doesn't load the whole doument at once in memory
A SAX Parser is much more memory efficient

  xml  xml parsers

Which of the following is not true ?Core Java
A Java class can extend multiple classes
A Java class can implement multiple interfaces
A Java interface can extend multiple interfaces
All of above are true

  inheritance  multiple inheritance

Which of following class types in MVC holds Business logic ?Java EE
Model
View
Controller
Accessor

  mvc

In Case a method is declared to throw an exception , We can only use a call to that method if ...Core Java
We use the call within try block and catch the exception
We declare that the method is expected to throw the exception using throws
Both 1 and 2
Either 1 or 2

  exception handling  throws







comments powered by Disqus