{"id":150,"date":"2026-03-21T07:25:03","date_gmt":"2026-03-21T07:25:03","guid":{"rendered":"https:\/\/alpeshconnect.in\/blog\/?p=150"},"modified":"2026-03-21T07:30:24","modified_gmt":"2026-03-21T07:30:24","slug":"java-program-to-create-student-class","status":"publish","type":"post","link":"https:\/\/alpeshconnect.in\/blog\/2026\/03\/21\/java-program-to-create-student-class\/","title":{"rendered":"Java OOP Practical for BCA Sem 2: Student Class with Display Method Explained"},"content":{"rendered":"\n<p>Create Student class with attributes: name,rollno,marks. Implement method disply() to show student details. Create two student objects and display their details.<\/p>\n\n\n\n<p>class Student {<br>String name;<br>int rollno;<br>float marks;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Constructor\nStudent(String name, int rollno, float marks) {\n    this.name = name;\n    this.rollno = rollno;\n    this.marks = marks;\n}\n\n\/\/ Method to display student details\nvoid display() {\n    System.out.println(\"Name: \" + name);\n    System.out.println(\"Roll No: \" + rollno);\n    System.out.println(\"Marks: \" + marks);\n    System.out.println(\"----------------------\");\n}<\/code><\/pre>\n\n\n\n<p>}<\/p>\n\n\n\n<p>public class Main {<br>public static void main(String[] args) {<br>\/\/ Creating two student objects<br>Student s1 = new Student(&#8220;Amit&#8221;, 1, 85.5f);<br>Student s2 = new Student(&#8220;Priya&#8221;, 2, 92.0f);<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    \/\/ Displaying details\n    s1.display();\n    s2.display();\n}<\/code><\/pre>\n\n\n\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create Student class with attributes: name,rollno,marks. Implement method disply() to show student details. Create two student objects and display their details. class Student {String name;int rollno;float marks; } public class Main {public static void main(String[] args) {\/\/ Creating two student objectsStudent s1 = new Student(&#8220;Amit&#8221;, 1, 85.5f);Student s2 = new Student(&#8220;Priya&#8221;, 2, 92.0f); }<\/p>\n","protected":false},"author":1,"featured_media":97,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,48],"tags":[25,26,49,30],"class_list":["post-150","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bca","category-java-programming-language","tag-bca","tag-bca-paper-solution","tag-java-programming-language","tag-object-oriented-programming-in-java"],"_links":{"self":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/comments?post=150"}],"version-history":[{"count":2,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":152,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/posts\/150\/revisions\/152"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/media\/97"}],"wp:attachment":[{"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/media?parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/categories?post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alpeshconnect.in\/blog\/wp-json\/wp\/v2\/tags?post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}