Skip to main content

Sasken Technology objective Question || Java Written test online

     Sasken Technology objective Question in         Naresh IT

 ===============================================

1.

 class Test 

 {
public static void main(String[] args) 
{
int a=30;
System.out.println((float)a);
}
}

Ans: 30.0

2.
 class Test 
 {
public static void main(String[] args) 
{
int a=30;
System.out.println((Float)a);
}
}

Ans:Compile time error becouse. Compiler
  unable to convert int to Float Object


3. What is the  return type of the hashCode();

 Ans: Acutally hash code Returun type is int
      Prototype of hashCode() method is 
  int hashCode();
  It is declear in the Object class 


4. What is return type of the toString() method
Ans:  Return type of the toString() method is
      String object

5. What is Correct Prototype of finalize() method 
 Ans: finalize method is avilable in the class Object
      It is protected void finalize(); method is avilable

6. What is the output of this Question in java

  class P{
   public static void main(String args[]){

    for( ; ;){
       System.out.println("Hello");
   }
   }
 }

 Ans: Hello print Infinit time
  Hint- By default in side the loop statement Compiler will 
  put the true . it is not going to break so that 
   It will going on infint time.



7.What is the output of this Question in java

class P{
 public static void main(String args[]){

  String s1=new String("India");
  String s2=new String("India");
  String s3="India";
  String s4="India";
  System.out.println(s1.equals(s3));
  System.out.println(s3==s4);
 }
}

Ans: true
     true

Hint: equals method return true and false. if both Content
and Data are same in the both reference than we will 
retuen true if (data in not same than it will give you)
false .
But == operator is work on the Data store in the Refernce 
variable.
So variable store in only Address of the object.
  

8.What is the output of Code
 class P{
 public static void main(String args[]){
   int a=10, b=10;
  do{ 
    System.out.println("Hello");
  }while(a==b);
 }
}

Ans: Hello will print infinit time.

9.Waht is output of this Program

  class P{
 public static void main(String args[]){
   int a=2, b=3,c,d;
   c=++b;
   d=a++;
   c++;
   System.out.println("a="+a);//3
   System.out.println("b="+b);//4
   System.out.println("c="+c);//5
   System.out.println("d="+d);//2
   
}
}

Ans: a=3
     b=4
c=5
d=2

10.What is output of this program
   


11. String and StringBuffer is meutable or imutable
    String-- imutable
StringBuffer-- mutable

12.What is the output of thi program

  abstract class P1
{
public void m1(){
     System.out.println("Hello");
}
public abstract void m2();
}
class P extends P1{
public void m2(){
     System.out.println("SubClass");
   }
 public static void main(String args[]){
   P1 p=new P1();
   p.m2();
}
}

Ans:: error: P1 is abstract; cannot be instantiated
  
  
     
13. What is the output of this program.

  
class P 
 public static void main(String args[]){
   int total=0,n,x=1;
   while(x<=5){
     n=x+x;
total+=n;
x++;
   }
   System.out.println("Total:"+total);
 }
}

Ans:Total:30

14. What is the Marker interface   
 Ans: Serializable


 15. What is the work of the clone() method in java

  Ans: Create the Copy of the object in java.


16. In the class multiple method with same name but
  Different parameter is called a concept of what

  Ans: Method Overloading

17. In Object Oriented programming language Having a 
  Concept of Method overloading and method overriding 

Ans: polymorphism concept in java programming


18. What is output

   class P extends Thread{
 public static void main(String args[]){

    Thread th=new Thread();
th.run();
  }
}

Ans:Actually run method is declear in the Runnable 
 interface or Thread class is Implement this class that why
  Thread is also provide the run() method  body

   So , If you Run no probam but output is not printed anything
   on the display.



19. What is the output of this program

  class P1
{
public static void m1(){
     System.out.println("Parent");
}
}
class P extends P1{
public static void m1(){
      System.out.println("Child");
}
 public static void main(String args[]){
   P1 p=new P1();
   p.m1();
   
  }
}



Ans: Parent

20.What is the output of this program
  class P1
{
public static void m1(){
     System.out.println("Parent");
}
}
class P extends P1{
public  void m1(){
      System.out.println("Child");
}
 public static void main(String args[]){
   P1 p=new P1();
   p.m1();
   
  }
}



Ans: m1() Cannot be override in the p class 
   Hint: Static method of parent class cannot be override

       also final .same rull follow.




  

Comments

Popular posts from this blog

Generate Documentation for Spring Boot API with swagger and Open API 3

 ðŸ˜‚ How to Generate Documentation for Spring Boot API project Make sure your Project having a swagger or open API 3 Dependency then only you get proper Documentation for your Service. ---------------------------------------------------------------------------- Every method or API above you have to Write Like that then only you get proper Documentation If you do everything in your Application and Run your Application and go to browse and search. . http://localhost:8080/v3/api-docs/ if you want to learn more go with this one.  Open API-3   1. For Return List of Object then you have to use this API operation  @Operation(summary = "This will fetch List of Patient Detailas base on Hospital Name") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully fetch All Patient Details from Database ", content = {  @Content(mediaType = "application/json" ,array = @ArraySchema(schema =@Schema(implementation =PatientDe...

Spring Boot With MySQL Database connection with Examples | MySQl Database Configuration with Spring Boot Projects

 ðŸ˜ƒ MySQL Database Configuration with Spring Boot Projects  In this article, we are going to introduce How to connect MySQL Database with the Spring Boot project. pom.xml   org.springframework.boot spring-boot-starter-data-jpa org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-devtools runtime true mysql mysql-connector-java runtime org.projectlombok lombok true    application. properties   server.port=8025 spring.datasource.url=jdbc:mysql://localhost:3306/princedb spring.datasource.username=root spring.datasource.password=root spring.jpa.hibernate.ddl-auto=create-drop MySqlWithSpringBootApplication.java   package com.app; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class MySqlWithSpringBootApp...

Top 10 website for IT Job | Software developer job apply | Job platfrom to apply Job | Software Developer Job .

                        Top 10 website for IT Job If you want a job in an IT or software company then this blog for you. I will give you the top 10 websites where you can apply the job for the software industry. It is a very good website to apply for a job for a software company.